[m-dev.] for review: compile in hlc.gc using MSVC

Peter Ross petdr at cs.mu.OZ.AU
Thu Jun 8 02:43:52 AEST 2000


Hi,

This bootchecks in the grade hlc.gc using gcc under Linux.
I will check this in sometime tomorrow, unless I hear any major
objections.

Pete

===================================================================


Estimated hours taken: 40

Allow compilation of the mercury compiler *ONLY* in the grade hlc.gc
using the Microsoft Visual C++ compiler (MSVC).  This is still
work-in-progress.

configure.in:
    Test to see whether or not we are using the Microsoft compiler.
    Don't fail if we can't interpret return values from system.
    
boehm_gc/Mmakefile:
    Use NT_MAKEFILE if we are using MSVC.

boehm_gc/NT_MAKEFILE:
    Apply the the changes to boehm_gc/Makefile to this file.

browser/Mmakefile:
library/Mmakefile:
runtime/Mmakefile:
trace/Mmakefile:
    Use the correct executable to create libraries.
    Use AR_LIBFILE_OPT to name the library.
    
compiler/llds_out.m:
    Export output_c_file_intro_and_grade so that the correct header can
    be placed at the start of each C file.
    
compiler/mlds_to_c.m:
    Output the header at the start of each C file, so that configure
    doesn't delete the file when checking the compatability with
    the configured settings.
    When initializing empty arrays place a dummy entry in the array, so
    that the MSVC compiler generates a symbol for that array.
    
compiler/passes_aux.m:
    Add invoke_shell_command.  This predicate wraps commands with
    a bash -c 'command ' when shell scripts aren't supported by the
    target system.
    
compiler/mercury_compile.m:
compiler/modules.m:
    Use invoke_shell_command instead of invoke_system_command for shell
    scripts.

library/io.m:
    Call _unlink in io_rename_file, when compiling with MSVC.
    

runtime/mercury_wrapper.c:
    Initialise MR_runqueue_head so that the segment containing this
    variable is registered with the garbage collector.  This stops
    intermittent failures of the GC_is_visible() test.

runtime/mercury_conf.h.in:
    Define MR_WIN32 when we are using MSVC.
    
runtime/mercury_memory.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_prof.c:
runtime/mercury_reg_workarounds.c:
runtime/mercury_reg_workarounds.h:
runtime/mercury_signal.c:
runtime/mercury_timing.c:
runtime/mercury_timing.h:
runtime/mercury_trace_base.c:
util/mkinit.c:
    Only include unistd.h and sys/times.h when they exist.
    MSVC doesn't have SIGBUS so #ifdef sections which refer to it.

scripts/Mmake.rules:
    Use /Fo instead of -o to generate .o files if compiling with MSVC.

scripts/Mmake.vars.in:
    Define AR to use the autoconfed executable for linking.

scripts/mgnuc.in:
    Only add option -Wno-uninitialized if we are using gcc.

util/Mmakefile:
    Explicitly locate the getopt src, and use it in compiling the
    utilities.

Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.205
diff -u -r1.205 configure.in
--- configure.in	2000/05/25 16:00:26	1.205
+++ configure.in	2000/06/07 16:04:02
@@ -231,8 +231,71 @@
 
 AC_PROG_CPP
 AC_C_CROSS
-AC_PROG_RANLIB
 AC_RETSIGTYPE
+#-----------------------------------------------------------------------------#
+AC_MSG_CHECKING(for use of a Microsoft compiler)
+AC_EGREP_CPP(yes,
+[
+#ifdef _MSC_VER
+	yes
+#endif
+],
+[ac_microsoft=yes
+] AC_MSG_RESULT(yes), [ac_microsoft=no
+] AC_MSG_RESULT(no))
+
+if test "$ac_microsoft" = "yes" ; then
+	EXE_SUFFIX=".exe"
+	OBJ_SUFFIX="obj"
+	LIB_SUFFIX="lib"
+	LIB_PREFIX="lib"
+	LIB_LIBPATH="/LIBPATH:"
+	LINK_LIB=""
+	LINK_OPT_SEP="/link"
+
+	OBJFILE_OPT="/Fo"
+	AR="lib"
+	ARFLAGS=""
+	AR_LIBFILE_OPT="/OUT:"
+	BOEHMGC_MAKEFILE="-f NT_MAKEFILE"
+
+	AC_DEFINE(MR_WIN32)
+
+		# MS doesn't use a ranlib.
+	RANLIB="echo"
+	AC_SUBST(RANLIB)
+else
+	EXE_SUFFIX=""
+	OBJ_SUFFIX="o"
+	LIB_SUFFIX="a"
+	LIB_PREFIX=""
+	LIB_LIBPATH="-L"
+	LINK_LIB="-l"
+	LINK_OPT_SEP=""
+
+	OBJFILE_OPT="-o"
+	AR="ar"
+	ARFLAGS="cr"
+	AR_LIBFILE_OPT=""
+	BOEHMGC_MAKEFILE=""
+
+	AC_PROG_RANLIB
+fi
+
+AC_SUBST(OBJFILE_OPT)
+AC_SUBST(AR)
+AC_SUBST(ARFLAGS)
+AC_SUBST(AR_LIBFILE_OPT)
+AC_SUBST(BOEHMGC_MAKEFILE)
+AC_SUBST(EXE_SUFFIX)
+AC_SUBST(OBJ_SUFFIX)
+AC_SUBST(LIB_SUFFIX)
+AC_SUBST(LIB_PREFIX)
+AC_SUBST(LIB_LIBPATH)
+AC_SUBST(LINK_LIB)
+AC_SUBST(LINK_OPT_SEP)
+
+#-----------------------------------------------------------------------------#
 # Don't try to use mprotect() on gnu-win32, since it is broken
 # (at least for version b18, anyway) and trying it can crash Win95.
 case "$host" in
@@ -242,6 +305,11 @@
 AC_HAVE_FUNCS(sysconf getpagesize memalign mprotect sigaction setitimer)
 AC_HAVE_FUNCS(strerror memmove fileno fdopen fstat)
 #-----------------------------------------------------------------------------#
+AC_CHECK_HEADER(unistd.h, HAVE_UNISTD_H=1)
+if test "$HAVE_UNISTD_H" = 1; then
+	AC_DEFINE(HAVE_UNISTD_H)
+fi
+#-----------------------------------------------------------------------------#
 AC_CHECK_HEADER(sys/wait.h, HAVE_SYS_WAIT_H=1)
 if test "$HAVE_SYS_WAIT_H" = 1; then
 	AC_DEFINE(HAVE_SYS_WAIT)
@@ -1234,8 +1302,8 @@
 )
 AC_MSG_RESULT($mercury_cv_normal_system_retval)
 if test "$mercury_cv_normal_system_retval" = no; then
-	AC_MSG_ERROR(Unable to interpret return values from system)
-	exit 1
+		# Warn since VC++6 compiler fails this test
+	AC_MSG_WARN(Unable to interpret return values from system)
 fi
 #-----------------------------------------------------------------------------#
 AC_MSG_CHECKING(for tempnam)
Index: boehm_gc/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/Mmakefile,v
retrieving revision 1.9
diff -u -r1.9 Mmakefile
--- boehm_gc/Mmakefile	1999/09/18 04:38:03	1.9
+++ boehm_gc/Mmakefile	2000/06/07 16:04:03
@@ -31,15 +31,16 @@
 #	We don't use `unset', since the Ultrix /bin/sh doesn't have `unset'.
 submake: force
 	MAKEFLAGS=""; export MAKEFLAGS; \
-	$(MAKE) $(MMAKEFLAGS) GRADE=$(GRADE) PROF=$(PROF) libgc$(PROF).a \
-		libgc$(PROF).$(EXT_FOR_SHARED_LIB) $(EXT_FOR_SHARED_LIB)
+	$(MAKE) $(BOEHMGC_MAKEFILE) $(MMAKEFLAGS) GRADE=$(GRADE) PROF=$(PROF) \
+		libgc$(PROF).a libgc$(PROF).$(EXT_FOR_SHARED_LIB) \
+		$(EXT_FOR_SHARED_LIB)
 
 .PHONY: force
 force:
 
 clean_local:
 	MAKEFLAGS=""; export MAKEFLAGS; \
-	$(MAKE) $(MMAKEFLAGS) clean
+	$(MAKE) $(BOEHMGC_MAKEFILE) $(MMAKEFLAGS) clean
 	rm -f libgc.a libgc.so
 
 #-----------------------------------------------------------------------------#
Index: boehm_gc/NT_MAKEFILE
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/NT_MAKEFILE,v
retrieving revision 1.4
diff -u -r1.4 NT_MAKEFILE
--- boehm_gc/NT_MAKEFILE	1996/12/06 11:48:11	1.4
+++ boehm_gc/NT_MAKEFILE	2000/06/07 16:04:03
@@ -1,32 +1,61 @@
+
 # Makefile for Windows NT.  Assumes Microsoft compiler, and a single thread.
 # DLLs are included in the root set under NT, but not under win32S.
 # Use "nmake nodebug=1 all" for optimized versions of library, gctest and editor.
-
+# ddw Tue Dec 01 13:58:12 1998 
+# Modified to include stuff fjh had put in Unix Makefile
+#-------------------------------------------------------
+MERCURY_DIR=..
+include ../Mmake.common
+
+CC=../scripts/mgnuc --grade $(GRADE) --no-ansi --no-check
+cc=$(CC)
+cdebug=
+LINK=link
+link=$(LINK)
 CPU= i386
-!include <ntwin32.mak>
+#!include <ntwin32.mak>
 
 OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_rts.obj headers.obj mark.obj obj_map.obj blacklst.obj finalize.obj new_hblk.obj dbg_mlc.obj malloc.obj stubborn.obj dyn_load.obj typd_mlc.obj ptr_chck.obj gc_cpp.obj mallocx.obj
 
 all: gctest.exe cord\de.exe test_cpp.exe
 
-.c.obj:
-	$(cc) $(cdebug) $(cflags) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj
+dll: libgcd$(PROF)$(DLL_DEF_LIB).dll
+libgc$(PROF)$(DLL_DEF_LIB).dll: libgcd.dll
+# had -DSMALL_CONFIG
+%.obj:%.c
+	$(cc) $(cdebug) $(CFLAGS) $(cvars)  -DSILENT -DLARGE_CONFIG -DALL_INTERIOR_POINTERS -D__STDC__  /c /Fo$*.obj $*.c
 
-.cpp.obj:
-	$(cc) $(cdebug) $(cflags) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj
+%.obj:%.cpp
+	$(cc) $(cdebug) $(CFLAGS) $(cvars) -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /c  /Fo$*.obj
 
 $(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
 
 gc.lib: $(OBJS)
 	lib /MACHINE:i386 /out:gc.lib $(OBJS)
+# a .def defining exports should be made....
+libgcd$(PROF)$(DLL_DEF_LIB).dll: $(OBJS)
+#	$(link) /MACHINE:i386 /DLL /out:libgcd.dll $(OBJS)
+
 # The original NT SDK used lib32 instead of lib
+
 
-gctest.exe: test.obj gc.lib
+libgc$(PROF)$(DLL_DEF_LIB).lib: gc.lib
+	rm -f libgc$(PROF)$(DLL_DEF_LIB).lib
+	# `ln -s' here doesn't work with gnu-win32, so we use `cp' instead
+	cp gc.lib libgc$(PROF)$(DLL_DEF_LIB).lib
+
+libgc$(PROF)$(DLL_DEF_LIB).a: gc.lib
+	rm -f libgc$(PROF)$(DLL_DEF_LIB).a
+	# `ln -s' here doesn't work with gnu-win32, so we use `cp' instead
+	cp gc.lib libgc$(PROF)$(DLL_DEF_LIB).a
+
+gctest.exe: test.obj libgc.lib
 #	The following works for win32 debugging.  For win32s debugging use debugtype:coff
 #	and add mapsympe line.
 #  This produces a "GUI" applications that opens no windows and writes to the log file
 #  "gc.log".  This is done to make the result runnable under win32s.
-	$(link) -debug:full -debugtype:cv $(guiflags) -stack:131072 -out:$*.exe test.obj $(guilibs) gc.lib
+	$(link) -debug:full -debugtype:cv $(guiflags) -stack:131072 -out:gctest.exe test.obj $(guilibs) libgc.lib
 #	mapsympe -n -o gctest.sym gctest.exe
 
 cord\de_win.rbj: cord\de_win.res
@@ -38,22 +67,37 @@
 	$(rc) $(rcvars) -r -fo cord\de_win.res $(cvars) cord\de_win.rc
 
 # Cord/de is a real win32 gui application.
-cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib
-	$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:cord\de.exe  cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib $(guilibs)
+cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj libgc.lib
+	$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:cord\de.exe  cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj libgc.lib $(guilibs)
 
 gc_cpp.obj: gc_cpp.h gc.h
 
 gc_cpp.cpp: gc_cpp.cc
-	copy gc_cpp.cc gc_cpp.cpp
+	cp gc_cpp.cc gc_cpp.cpp
 
 test_cpp.cpp: test_cpp.cc
-	copy test_cpp.cc test_cpp.cpp
+	cp test_cpp.cc test_cpp.cpp
 
 # This generates the C++ test executable.  The executable expects
 # a single numeric argument, which is the number of iterations.
 # The output appears in the file "gc.log".
-test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib
-	$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:test_cpp.exe test_cpp.obj gc.lib $(guilibs)
-
-
+test_cpp.exe: test_cpp.obj gc_cpp.h gc.h libgc.lib
+	$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:test_cpp.exe test_cpp.obj libgc.lib $(guilibs)
 
+.PHONY: clean
+clean:
+	-rm -f *.lib *.dll *.obj 
+
+# The Mmakefile invokes `make $(EXT_FOR_SHARED_LIB)',
+# so we need targets `a', `so', and `dll'.
+
+.PHONY: a
+a: libgc$(PROF).a
+
+.PHONY: so
+so:
+	echo "Unable to build DLL yet!"
+
+.PHONY: dll
+dll:
+	echo "Unable to build DLL yet!"
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.9
diff -u -r1.9 Mmakefile
--- browser/Mmakefile	2000/05/15 06:09:49	1.9
+++ browser/Mmakefile	2000/06/07 16:04:03
@@ -131,7 +131,9 @@
 
 lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a : $(mdb.os)
 	rm -f lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a
-	ar cr lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a $(mdb.os)
+	$(AR) $(ALL_ARFLAGS) \
+		$(AR_LIBFILE_OPT)lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a \
+		$(mdb.os)
 	$(RANLIB) lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).a
 
 RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.143
diff -u -r1.143 llds_out.m
--- compiler/llds_out.m	2000/05/10 18:06:26	1.143
+++ compiler/llds_out.m	2000/06/07 16:04:10
@@ -31,6 +31,9 @@
 		io__state, io__state).
 :- mode output_llds(in, in, in, di, uo) is det.
 
+:- pred output_c_file_intro_and_grade(string, string, io__state, io__state).
+:- mode output_c_file_intro_and_grade(in, in, di, uo) is det.
+
 	% output_rval_decls(Rval, FirstIndent, LaterIndent, N0, N,
 	% DeclSet0, DeclSet) outputs the declarations of any static constants,
 	% etc. that need to be declared before output_rval(Rval) is called.
@@ -415,9 +418,6 @@
 	;
 		io__write_string("#include ""mercury_imp.h""\n")
 	).
-
-:- pred output_c_file_intro_and_grade(string, string, io__state, io__state).
-:- mode output_c_file_intro_and_grade(in, in, di, uo) is det.
 
 output_c_file_intro_and_grade(SourceFileName, Version) -->
 	globals__io_lookup_int_option(num_tag_bits, NumTagBits),
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.165
diff -u -r1.165 mercury_compile.m
--- compiler/mercury_compile.m	2000/05/24 06:25:30	1.165
+++ compiler/mercury_compile.m	2000/06/07 16:04:19
@@ -2699,7 +2699,7 @@
 	    join_module_list(Modules, ".c", ["> ", InitCFileName], MkInitCmd0),
 	    { string__append_list(["c2init ", TraceOpt | MkInitCmd0],
 	    	MkInitCmd) },
-	    invoke_system_command(MkInitCmd, MkInitOK),
+	    invoke_shell_command(MkInitCmd, MkInitOK),
 	    maybe_report_stats(Stats),
 	    ( { MkInitOK = no } ->
 		report_error("creation of init file failed.")
@@ -2746,7 +2746,7 @@
 			LinkObjects, " ",
 			LinkLibraryDirectories, " ", LinkLibraries],
 			LinkCmd) },
-		    invoke_system_command(LinkCmd, LinkCmdOK),
+		    invoke_shell_command(LinkCmd, LinkCmdOK),
 		    maybe_report_stats(Stats),
 		    ( { LinkCmdOK = no } ->
 			report_error("link failed.")
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.38
diff -u -r1.38 mlds_to_c.m
--- compiler/mlds_to_c.m	2000/06/06 05:45:20	1.38
+++ compiler/mlds_to_c.m	2000/06/07 16:04:23
@@ -32,8 +32,9 @@
 
 :- import_module llds.		% XXX needed for C interface types
 :- import_module llds_out.	% XXX needed for llds_out__name_mangle,
-				% llds_out__sym_name_mangle, and
-				% llds_out__make_base_typeclass_info_name.
+				% llds_out__sym_name_mangle,
+				% llds_out__make_base_typeclass_info_name,
+				% output_c_file_intro_and_grade.
 :- import_module rtti.		% for rtti__addr_to_string.
 :- import_module rtti_to_mlds.	% for mlds_rtti_type_name.
 :- import_module hlds_pred.	% for pred_proc_id.
@@ -44,7 +45,8 @@
 :- import_module builtin_ops, c_util, modules.
 :- import_module prog_data, prog_out, type_util.
 
-:- import_module bool, int, string, list, assoc_list, term, std_util, require.
+:- import_module bool, int, string, library, list.
+:- import_module assoc_list, term, std_util, require.
 
 %-----------------------------------------------------------------------------%
 
@@ -198,6 +200,9 @@
 
 mlds_output_src_file(Indent, MLDS) -->
 	{ MLDS = mlds(ModuleName, ForeignCode, Imports, Defns) },
+	{ library__version(Version) },
+	module_name_to_file_name(ModuleName, ".m", no, OrigFileName),
+	output_c_file_intro_and_grade(OrigFileName, Version),
 	mlds_output_src_start(Indent, ModuleName), io__nl,
 	mlds_output_src_imports(Indent, Imports), io__nl,
 	mlds_output_c_decls(Indent, ForeignCode), io__nl,
@@ -753,13 +758,21 @@
 :- mode mlds_output_initializer(in, in, di, uo) is det.
 
 mlds_output_initializer(_Type, Initializer) -->
-	( { Initializer = no_initializer } ->
-		[]
-	;
+	( { mlds_needs_initialization(Initializer) = yes } ->
 		io__write_string(" = "),
 		mlds_output_initializer_body(Initializer)
+	;
+		[]
 	).
 
+:- func mlds_needs_initialization(mlds__initializer) = bool.
+
+mlds_needs_initialization(no_initializer) = no.
+mlds_needs_initialization(init_obj(_)) = yes.
+mlds_needs_initialization(init_struct([])) = no.
+mlds_needs_initialization(init_struct([_|_])) = yes.
+mlds_needs_initialization(init_array(_)) = yes.
+
 :- pred mlds_output_initializer_body(mlds__initializer, io__state, io__state).
 :- mode mlds_output_initializer_body(in, di, uo) is det.
 
@@ -772,7 +785,16 @@
 	io__write_string("}").
 mlds_output_initializer_body(init_array(ElementInits)) -->
 	io__write_string("{\n\t\t"),
-	io__write_list(ElementInits, ",\n\t\t", mlds_output_initializer_body),
+	(
+		{ ElementInits = [] }
+	->
+			% The MS VC++ compiler only generates a symbol, if
+			% the array has a known size.
+		io__write_string("NULL")
+	;
+		io__write_list(ElementInits,
+				",\n\t\t", mlds_output_initializer_body)
+	),
 	io__write_string("}").
 
 %-----------------------------------------------------------------------------%
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.128
diff -u -r1.128 modules.m
--- compiler/modules.m	2000/05/24 06:04:48	1.128
+++ compiler/modules.m	2000/06/07 16:04:29
@@ -1112,7 +1112,7 @@
 		{ Command = "mercury_update_interface " }
 	),
 	{ string__append(Command, OutputFileName, ShellCommand) },
-	invoke_system_command(ShellCommand, Succeeded),
+	invoke_shell_command(ShellCommand, Succeeded),
 	( { Succeeded = no } ->
 		report_error("problem updating interface files.")
 	;
Index: compiler/passes_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.34
diff -u -r1.34 passes_aux.m
--- compiler/passes_aux.m	1999/08/13 01:43:08	1.34
+++ compiler/passes_aux.m	2000/06/07 16:04:30
@@ -146,6 +146,11 @@
 
 :- pred report_error(string::in, io__state::di, io__state::uo) is det.
 
+	% Invoke a shell script.
+:- pred invoke_shell_command(string::in, bool::out,
+	io__state::di, io__state::uo) is det.
+
+	% Invoke an executable.
 :- pred invoke_system_command(string::in, bool::out,
 	io__state::di, io__state::uo) is det.
 
@@ -168,7 +173,7 @@
 :- import_module options, globals, hlds_out, prog_out, mode_util.
 :- import_module mercury_to_mercury.
 :- import_module varset.
-:- import_module int, map, tree234, require.
+:- import_module int, map, tree234, require, string.
 
 process_all_nonimported_procs(Task, ModuleInfo0, ModuleInfo) -->
 	{ True = lambda([_PredInfo::in] is semidet, true) },
@@ -398,6 +403,16 @@
 		State9 = State2
 	).
 
+invoke_shell_command(Command0, Succeeded) -->
+	{
+		use_win32
+	->
+		string__append_list(["bash -c '", Command0, " '"], Command)
+	;
+		Command = Command0
+	},
+	invoke_system_command(Command, Succeeded).
+
 invoke_system_command(Command, Succeeded) -->
 	globals__io_lookup_bool_option(verbose, Verbose),
 	( { Verbose = yes } ->
@@ -419,6 +434,18 @@
 		report_error("unable to invoke system command."),
 		{ Succeeded = no }
 	).
+
+	% Are we compiling in a win32 environment?
+:- pred use_win32 is semidet.
+:- pragma c_code(use_win32,
+	[will_not_call_mercury],
+"
+#ifdef MR_WIN32
+	SUCCESS_INDICATOR = 1;
+#else
+	SUCCESS_INDICATOR = 0;
+#endif
+").
 
 maybe_report_sizes(HLDS) -->
 	globals__io_lookup_bool_option(statistics, Statistics),
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.49
diff -u -r1.49 Mmakefile
--- library/Mmakefile	2000/05/17 17:31:07	1.49
+++ library/Mmakefile	2000/06/07 16:04:31
@@ -195,7 +195,9 @@
 
 lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a : $(library.os)
 	rm -f lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a
-	ar cr lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a $(library.os)
+	$(AR) $(ALL_ARFLAGS) \
+		$(AR_LIBFILE_OPT)lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a \
+		$(library.os)
 	$(RANLIB) lib$(STD_LIB_NAME)$(DLL_DEF_LIB).a
 
 RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.197
diff -u -r1.197 io.m
--- library/io.m	2000/05/08 13:48:35	1.197
+++ library/io.m	2000/06/07 16:04:41
@@ -1544,7 +1544,9 @@
 %	otherwise Size is -1.
 
 :- pragma c_header_code("
+#ifdef HAVE_UNISTD_H
 	#include <unistd.h>
+#endif
 #ifdef HAVE_SYS_STAT_H
 	#include <sys/stat.h>
 #endif
@@ -3389,7 +3391,9 @@
 %#include <stdio.h>
 
 :- pragma c_header_code("
+#ifdef HAVE_UNISTD_H
 	#include <unistd.h>
+#endif
 	#include <sys/types.h>
 	#include <sys/stat.h>
 	#include <fcntl.h>
@@ -3533,6 +3537,10 @@
 		RetVal::out, RetStr::out, IO0::di, IO::uo),
 		[will_not_call_mercury, thread_safe],
 "{
+#ifdef _MSC_VER
+		/* VC++ runtime fix */
+	_unlink(NewFileName);
+#endif
 	RetVal = rename(OldFileName, NewFileName);
 	ML_maybe_make_err_msg(RetVal != 0, ""rename failed: "",
 		MR_PROC_LABEL, RetStr);
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.55
diff -u -r1.55 Mmakefile
--- runtime/Mmakefile	2000/05/08 14:01:02	1.55
+++ runtime/Mmakefile	2000/06/07 16:04:43
@@ -203,7 +203,8 @@
 
 lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a: $(OBJS)
 	rm -f lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a
-	ar cr lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
+	$(AR) $(ALL_ARFLAGS) \
+		$(AR_LIBFILE_OPT)lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
 	$(RANLIB) lib$(RT_LIB_NAME)$(DLL_DEF_LIB).a
 
 lib$(RT_LIB_NAME).so: $(PIC_OBJS)
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.25
diff -u -r1.25 mercury_conf.h.in
--- runtime/mercury_conf.h.in	2000/01/05 16:40:15	1.25
+++ runtime/mercury_conf.h.in	2000/06/07 16:04:43
@@ -98,6 +98,7 @@
 **	HAVE_SYS_UCONTEXT	we have <sys/ucontext.h>
 **	HAVE_ASM_SIGCONTEXT	we have <asm/sigcontext.h> (e.g. i386 Linux)
 **	HAVE_SYS_TIME		we have <sys/time.h>
+**	HAVE_UNISTD_H		we have <unistd.h>
 **	HAVE_SYS_PARAM		we have <sys/param.h>
 **	HAVE_SYS_WAIT		we have <sys/wait.h>
 **	HAVE_SYS_STAT_H		we have <sys/stat.h>
@@ -110,6 +111,7 @@
 #undef	HAVE_SYS_UCONTEXT
 #undef	HAVE_ASM_SIGCONTEXT
 #undef	HAVE_SYS_TIME
+#undef	HAVE_UNISTD_H
 #undef	HAVE_SYS_PARAM
 #undef	HAVE_SYS_WAIT
 #undef	HAVE_SYS_STAT_H
@@ -343,6 +345,12 @@
 #undef  MR_NO_USE_READLINE
 #undef  HAVE_READLINE_READLINE
 #undef  HAVE_READLINE_HISTORY
+
+/*
+** MR_WIN32
+**	Set this if you are using Microsoft Visual C++ as your C compiler.
+*/	
+#undef	MR_WIN32
 
 /*---------------------------------------------------------------------------*/
 
Index: runtime/mercury_memory.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory.c,v
retrieving revision 1.17
diff -u -r1.17 mercury_memory.c
--- runtime/mercury_memory.c	1999/10/18 15:46:56	1.17
+++ runtime/mercury_memory.c	2000/06/07 16:04:44
@@ -64,7 +64,10 @@
   #include <signal.h>
 #endif
 
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 
Index: runtime/mercury_memory_handlers.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_handlers.c,v
retrieving revision 1.10
diff -u -r1.10 mercury_memory_handlers.c
--- runtime/mercury_memory_handlers.c	2000/03/09 07:27:45	1.10
+++ runtime/mercury_memory_handlers.c	2000/06/07 16:04:45
@@ -15,7 +15,10 @@
 
 #include "mercury_imp.h"
 
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 
@@ -259,8 +262,10 @@
 void
 setup_signals(void)
 {
+#ifdef SIGBUS
 	MR_setup_signal(SIGBUS, (Code *) bus_handler, TRUE,
 		"Mercury runtime: cannot set SIGBUS handler");
+#endif
 	MR_setup_signal(SIGSEGV, (Code *) segv_handler, TRUE,
 		"Mercury runtime: cannot set SIGSEGV handler");
 }
@@ -357,11 +362,13 @@
 			}
 			break;
 
+#ifdef SIGBUS
 		case SIGBUS:
 			fflush(stdout);
 			fprintf(stderr, "\n*** Mercury runtime: "
 					"caught bus error ***\n");
 			break;
+#endif
 
 		default:
 			fflush(stdout);
@@ -518,9 +525,11 @@
 
 	switch (sig)
 	{
+#ifdef SIGBUS
 	case SIGBUS:
 		fprintf(stderr, "caught bus error ***\n");
 		break;
+#endif
 
 	case SIGSEGV:
 		fprintf(stderr, "caught segmentation violation ***\n");
Index: runtime/mercury_memory_zones.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_zones.c,v
retrieving revision 1.9
diff -u -r1.9 mercury_memory_zones.c
--- runtime/mercury_memory_zones.c	2000/03/09 07:27:46	1.9
+++ runtime/mercury_memory_zones.c	2000/06/07 16:04:45
@@ -24,7 +24,10 @@
 
 #include "mercury_imp.h"
 
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 
Index: runtime/mercury_prof.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_prof.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_prof.c
--- runtime/mercury_prof.c	1998/05/15 05:15:15	1.7
+++ runtime/mercury_prof.c	2000/06/07 16:04:46
@@ -12,8 +12,11 @@
 
 #include        "mercury_imp.h"
 
+#ifdef HAVE_UNISTD_H
+  #include	<unistd.h>
+#endif
+
 #include	<stdio.h>
-#include	<unistd.h>
 #include	<errno.h>
 #include	<string.h>
 
Index: runtime/mercury_reg_workarounds.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_reg_workarounds.c,v
retrieving revision 1.3
diff -u -r1.3 mercury_reg_workarounds.c
--- runtime/mercury_reg_workarounds.c	2000/05/08 14:01:00	1.3
+++ runtime/mercury_reg_workarounds.c	2000/06/07 16:04:46
@@ -18,7 +18,10 @@
 
 #include <sys/types.h>	/* for fd_set and FD_ZERO() */
 #include <sys/time.h>	/* for FD_ZERO() */
-#include <unistd.h>	/* for FD_ZERO() */
+
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>	/* for FD_ZERO() */
+#endif
 
 void
 MR_fd_zero(fd_set *fdset)
Index: runtime/mercury_reg_workarounds.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_reg_workarounds.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_reg_workarounds.h
--- runtime/mercury_reg_workarounds.h	2000/05/08 14:01:00	1.3
+++ runtime/mercury_reg_workarounds.h	2000/06/07 16:04:46
@@ -18,6 +18,8 @@
   #include <sys/time.h>			/* for FD_ZERO() */
 #endif
 
+#include <stdlib.h>			/* for size_t */
+
 /*
 ** We use our own version of memcpy because gcc recognises calls to the
 ** standard memcpy (even in things that do not mention memcpy by name, e.g.
Index: runtime/mercury_signal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_signal.c,v
retrieving revision 1.5
diff -u -r1.5 mercury_signal.c
--- runtime/mercury_signal.c	1998/05/27 06:12:03	1.5
+++ runtime/mercury_signal.c	2000/06/07 16:04:46
@@ -40,7 +40,10 @@
   #include <signal.h>
 #endif
 
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
Index: runtime/mercury_timing.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_timing.c,v
retrieving revision 1.2
diff -u -r1.2 mercury_timing.c
--- runtime/mercury_timing.c	1997/11/23 07:21:39	1.2
+++ runtime/mercury_timing.c	2000/06/07 16:04:46
@@ -13,7 +13,9 @@
 
 #include "mercury_imp.h"
 
-#include <sys/times.h>		/* for times() and `struct tms' */
+#ifdef HAVE_SYS_TIMES_H
+  #include <sys/times.h>		/* for times() and `struct tms' */
+#endif
 
 #include "mercury_timing.h"
 
Index: runtime/mercury_timing.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_timing.h,v
retrieving revision 1.2
diff -u -r1.2 mercury_timing.h
--- runtime/mercury_timing.h	1997/11/23 07:21:39	1.2
+++ runtime/mercury_timing.h	2000/06/07 16:04:46
@@ -19,7 +19,10 @@
 #include <sys/param.h>		/* for HZ */
 #endif
 
-#include <unistd.h>		/* for sysconf() and _SC_CLK_TCK */
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>		/* for sysconf() and _SC_CLK_TCK */
+#endif
+
 #include <limits.h>		/* CLK_TCK defined here, on some systems */
 
 /* 
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.24
diff -u -r1.24 mercury_trace_base.c
--- runtime/mercury_trace_base.c	2000/01/03 08:53:08	1.24
+++ runtime/mercury_trace_base.c	2000/06/07 16:04:47
@@ -25,8 +25,11 @@
 #include "mercury_signal.h"	/* for MR_setup_signal() */
 #include <signal.h>		/* for SIGINT */
 #include <stdio.h>
-#include <unistd.h>		/* for the write system call */
 #include <errno.h>
+
+#ifdef HAVE_UNISTD_H
+  #include <unistd.h>		/* for the write system call */
+#endif
 
 /*
 ** Do we want to use the debugger within this process, or do want to use
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.61
diff -u -r1.61 mercury_wrapper.c
--- runtime/mercury_wrapper.c	2000/05/18 04:10:29	1.61
+++ runtime/mercury_wrapper.c	2000/06/07 16:04:48
@@ -366,6 +366,16 @@
 void
 MR_init_conservative_GC(void)
 {
+	/*
+	** sometimes mercury apps fail the GC_is_visible() test.
+	** dyn_load.c traverses the entire address space and registers
+	** all segments that could possibly have been written to, which
+	** makes us suspect that &MR_runqueue_head is not in the registered
+	** roots.  So we force a write to that address, which seems to make
+	** the problem go away.
+	*/
+	MR_runqueue_head = NULL;
+
 	GC_quiet = TRUE;
 
 	/*
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.81
diff -u -r1.81 Mmake.rules
--- scripts/Mmake.rules	2000/05/19 07:17:32	1.81
+++ scripts/Mmake.rules	2000/06/07 16:04:49
@@ -186,14 +186,15 @@
 $(os_subdir)%.o : %.m
 	$(MMAKE_MAKE_CMD) $(MFLAGS) MC="$(MC)" ALL_MCFLAGS="$(ALL_MCFLAGS)" \
 		ALL_GRADEFLAGS="$(ALL_GRADEFLAGS)" $(cs_subdir)$*.c
-	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $(cs_subdir)$*.c -o $@
+	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $(cs_subdir)$*.c \
+		$(OBJFILE_OPT)$@
 	$(RM_C) $(cs_subdir)$*.c
 
 $(os_subdir)%.pic_o : %.m
 	$(MMAKE_MAKE_CMD) $(MFLAGS) MC="$(MC)" ALL_MCFLAGS="$(ALL_MCFLAGS)" \
 		ALL_GRADEFLAGS="$(ALL_GRADEFLAGS)" $(cs_subdir)$*.c
 	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
-		-c $(cs_subdir)$*.c -o $@
+		-c $(cs_subdir)$*.c $(OBJFILE_OPT)$@
 
 endif # RM_C != :
 
@@ -225,11 +226,11 @@
 #
 
 .c.o:
-	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $< -o $@
+	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $< $(OBJFILE_OPT)$@
 
 .c.pic_o:
 	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
-		-c $< -o $@
+		-c $< $(OBJFILE_OPT)$@
 
 .c.s:
 	$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -S $< -o $@
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.31
diff -u -r1.31 Mmake.vars.in
--- scripts/Mmake.vars.in	2000/05/11 03:46:23	1.31
+++ scripts/Mmake.vars.in	2000/06/07 16:04:49
@@ -179,10 +179,11 @@
 MSPFLAGS	=
 EXTRA_MSPFLAGS	=
 
-AR		= ar
+AR		= @AR@
 ALL_ARFLAGS	= $(ARFLAGS) $(EXTRA_ARFLAGS) $(TARGET_ARFLAGS)
-ARFLAGS		= cr
+ARFLAGS		= @ARFLAGS@
 EXTRA_ARFLAGS	=
+AR_LIBFILE_OPT	= @AR_LIBFILE_OPT@
 
 RANLIB		= @RANLIB@
 ALL_RANLIBFLAGS	= $(RANLIBFLAGS) $(EXTRA_RANLIBFLAGS) $(TARGET_RANLIBFLAGS)
@@ -472,5 +473,13 @@
 
 # Specify the additional compilation models to install by default
 LIBGRADES		= @LIBGRADES@
+
+#-----------------------------------------------------------------------------#
+
+OBJFILE_OPT=@OBJFILE_OPT@
+BOEHMGC_MAKEFILE=@BOEHMGC_MAKEFILE@
+
+O=@OBJ_SUFFIX@
+A=@LIB_SUFFIX@
 
 #-----------------------------------------------------------------------------#
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.68
diff -u -r1.68 mgnuc.in
--- scripts/mgnuc.in	1999/12/21 09:56:45	1.68
+++ scripts/mgnuc.in	2000/06/07 16:04:50
@@ -366,7 +366,11 @@
 		# about using possibly uninitialized variables;
 		# there's no easy way to supress them except by
 		# disabling the warning.
-		CHECK_OPTS="$CHECK_OPTS -Wno-uninitialized"
+		case "$CC" in
+	    		*gcc*)
+				CHECK_OPTS="$CHECK_OPTS -Wno-uninitialized"
+			;;
+		esac
 		;;
 	*-solaris*|*-sunos*)
 		# The solaris headers for pthreads are not ANSI :-(
Index: trace/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/Mmakefile,v
retrieving revision 1.13
diff -u -r1.13 Mmakefile
--- trace/Mmakefile	2000/03/21 06:52:55	1.13
+++ trace/Mmakefile	2000/06/07 16:04:51
@@ -124,7 +124,8 @@
 
 lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a: $(OBJS)
 	rm -f lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a
-	ar cr lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
+	$(AR) $(ALL_ARFLAGS) \
+		$(AR_LIBFILE_OPT)lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a $(OBJS)
 	$(RANLIB) lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).a
 
 lib$(TRACE_LIB_NAME).so: $(PIC_OBJS)
Index: util/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/util/Mmakefile,v
retrieving revision 1.7
diff -u -r1.7 Mmakefile
--- util/Mmakefile	1999/09/16 04:46:30	1.7
+++ util/Mmakefile	2000/06/07 16:04:52
@@ -23,12 +23,15 @@
 PROGS=mkinit mdemangle info_to_mdb
 PROGFILENAMES=$(PROGS:%=%$(EXT_FOR_EXE))
 
+
+GETOPT_SRC=$(RUNTIME_DIR)/GETOPT/getopt.c $(RUNTIME_DIR)/GETOPT/getopt1.c
+
 #-----------------------------------------------------------------------------#
 
 all:	$(PROGS)
 
 .c:
-	$(MGNUC) $(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ $<
+	$(MGNUC) $(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ $< $(GETOPT_SRC)
 
 #-----------------------------------------------------------------------------#
 
Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.63
diff -u -r1.63 mkinit.c
--- util/mkinit.c	2000/05/08 16:11:22	1.63
+++ util/mkinit.c	2000/06/07 16:04:53
@@ -23,8 +23,12 @@
 #include	<string.h>
 #include	<ctype.h>
 #include	<errno.h>
-#include	<unistd.h>
 #include	<sys/stat.h>
+
+#ifdef HAVE_UNISTD_H
+  #include	<unistd.h>
+#endif
+
 #include	"getopt.h"
 #include	"mercury_conf.h"
 #include	"mercury_std.h"

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list