[m-rev.] Sorry, wrong diff format. For review: Shared Mercury libs on Mac OS X
Julien Fischer
juliensf at cs.mu.OZ.AU
Sun Oct 10 05:08:07 AEST 2004
On Fri, 8 Oct 2004, Ian MacLarty wrote:
> Please ignore the previous posting - I included the diff in the wrong format.
>
> Changes to get shared versions of the Mercury libraries working on Mac OS X.
>
> This diff needs to be applied in 2 stages: first the handling of the extra
> options in the compiler(compiler/options.m, compiler/compile_target_code.m and
> compiler/modules.m), then the changes to the configuration scripts and make
> files that use these extra options. I am posting the diffs together so the
> changes can be reviewed as a whole.
>
> Also the following issues still need clarification:
>
> 1. The -undefined_suppress linker option doesn't work with two level
> namespaces which is the default on Darwin. Is the
> --allow-undefined ml option used? If so should shared libs
> rather use flat namespaces. Alternatively the ALLOW_UNDEFINED
> configuration variable can be set to "-undefined
> dynamic_lookup", but that'll only work for Mac OS >= 10.3. I
> didn't get any undefined symbols when compiling the compiler.
>
At the moment we should probably just support versions >= 10.3.
> 2. Does the shared library built in the analysis directory currently
> get installed anywhere? If so where?
>
No, although the shared library is built but the compiler
is then linked against the static one. There's probably not a lot
of point changing that at the moment because the compiler is the only
thing that uses the analysis library.
> For review by anyone.
>
> Estimated hours taken: 20
> Branches: main
>
> Changes to get shared libraries to work on Mac OS X (Darwin).
>
> Darwin shared libraries have the extension `dylib' instead of `so'. Also
> objects that link to a shared library on Darwin don't need to be told the
> runtime path in which they should look for the libraries, instead the
> shared libraries themselves remember where they will be eventually installed
> (called the install-name) and any object which links in the shared library will
> get the install-name from the shared library at link time. When a shared
> library is built it has to be told where it will be installed which is what
> the libtool -install_name option is used for on Darwin.
>
You should probably an XXX somewhere to this log message that this change
is not sufficient to get dynamic linking working on OS X (and consequently
queries in the debugger still won't work).
> Added three new compiler options :
>
> --shlib-linker-use-install-name :
> A boolean flag to tell the compiler to use the -install_name option
> when building shared libraries. When this flag is set the following
> options have no effect: --linker-rpath-flag, --linker-rpath-separator,
> --shlib-linker-rpath-flag, --shlib-linker-rpath-separator.
>
> --shlib-linker-install-name-flag :
> The flag name to use ("-install_name" for Darwin).
>
> --shlib-linker-install-name-path :
> The path where the shared library will eventually end up, excluding the
> file name. The file name is appended to the end before the option
> is passed on to the linker.
Do I need to provide these to the compiler or will mmake do it for me?
>
> Mmake.common.in
> Added variables used for install-name on/off switch and flag name.
>
Do you need to make any changes to Mmake.workspace?
> configure.in
> Make shared libs the default when on Darwin and the compiler is gcc.
>
Is there a way that I can use static linking if I really want it?
> boehm_gc/Makefile
> boehm_gc/Makefile.direct
> Added rule to make libgc.dylib and set the install-name correctly.
>
> boehm_gc/Mmakefile
> Set variable used in boehm_gc/Makefile to get the final install path
> of the gc shared lib.
>
> browser/Mercury.options
> Added mer_mdbcomp library for target libmer_browser.dylib.
>
> browser/Mmakefile
> Added --shlib-linker-install-name-path option to MC options.
>
> compiler/compile_target_code.m
> Updated module qualifiers to `.'.
> Passed the install-name options to
> the linker and made RpathsOpts empty if the
> --shlib-linker-use-install-name flag is set.
>
It would have been better if you had not updated all the module
qualifiers - it's quite difficult to see the relevant changes amidst
all the syntax updates.
> compiler/modules.m
> Added get_install_name_option/4 predicate to get the option string to
> set the install-name for a shared library.
>
> compiler/options.m
> Added --shlib-linker-install-name-path,
> --shlib-linker-install-name-flag and --shlib-linker-use-install-name
> options.
>
> doc/user_guide.texi
> Documented the --shlib-linker-install-name-path option. The other
> options will be automatically set by the configure script and
> should never need to be set by the user, so they're not documented in
> the user guide.
Are there any changes that need to be made to the section on building
libraries?
>
> library/Mmakefile
> Added --shlib-linker-install-name-path option to MC flags.
>
> runtime/Mmakefile
> Added rule to make the Darwin shared library.
>
> scripts/Mercury.config.bootstrap.in
> Added default values for --shlib-linker-use-install-name and
> --shlib-linker-install-name-flag.
>
> scripts/Mercury.config.in
> Added default values for --shlib-linker-use-install-name and
> --shlib-linker-install-name-flag.
>
> trace/Mmakefile
> Added rule to make the Darwin shared library.
>
> Index: Mmake.common.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
> retrieving revision 1.78
> diff -u -r1.78 Mmake.common.in
> --- Mmake.common.in 24 Jun 2004 11:25:49 -0000 1.78
> +++ Mmake.common.in 8 Oct 2004 11:03:31 -0000
> @@ -105,6 +105,11 @@
> EXE_RPATH_OPT = @EXE_RPATH_OPT@''
> EXE_RPATH_SEP = ''@EXE_RPATH_SEP@''
>
> +# These variables can be used to set the install-name for the mercury
> +# shared libraries.
> +SHLIB_USE_INSTALL_NAME = @SHLIB_USE_INSTALL_NAME@
> +SHLIB_INSTALL_NAME_FLAG = @SHLIB_INSTALL_NAME_FLAG@''
> +
I'd suggest changing the above comment to mention that this is for
shared libraries on darwin.
> # Specify any extra libraries that must be linked in when linking shared
> # objects.
> SHARED_LIBS = @SHARED_LIBS@
> Index: configure.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/configure.in,v
> retrieving revision 1.404
> diff -u -r1.404 configure.in
> --- configure.in 5 Oct 2004 00:46:26 -0000 1.404
> +++ configure.in 8 Oct 2004 11:03:32 -0000
> @@ -227,14 +227,17 @@
> --halt-at-warn $link_static_opt conftest \
> </dev/null >&AC_FD_CC 2>&1 &&
> test "`./conftest 2>&1 | tr -d '\015'`" = "Hello, world" &&
> - # Test for the --record-term-sizes-as-words option.
> - # Note that we need to set --grade to an LLDS grade
> - # when doing this test because term size profiling
> - # requires an LLDS grade.
> + # Test for the --record-term-sizes-as-words option.
> + # Note that we need to set --grade to an LLDS grade
> + # when doing this test because term size profiling
> + # requires an LLDS grade.
> + # This also tests for the --shlib-linker-intall-name-flag
> + # option.
> $BOOTSTRAP_MC \
> --grade none.gc \
> --record-term-sizes-as-words \
> --output-grade-string \
> + --shlib-linker-install-name-flag "-dummy_flag" \
> </dev/null >&AC_FD_CC 2>&1
> then
> AC_MSG_RESULT(yes)
> @@ -2414,23 +2417,6 @@
> # enable conservative garbage collection by default.
> # We also allow users to override the default grade by setting
> # "DEFAULT_GRADE" in the environment before invoking configure.
> -
> -AC_ARG_WITH(default-grade,
> - AC_HELP_STRING([--with-default-grade=GRADE],
> - [Have the built compiler default to using GRADE]),
> - [case "$withval" in
> - # Handle `--with-default-grade' (no `=GRADE') and
> - # `--without-default-grade' flags.
> - yes|no)
> - AC_MSG_ERROR([Must supply a valid grade if using --with-default-grade.])
> - ;;
> - *)
> - # Perhaps do better checking on the supplied value here.
> - DEFAULT_GRADE="$withval"
> - export DEFAULT_GRADE
> - ;;
> - esac], [])
> -
Why are you deleting this, Ralph only added it the other day?
> if test "$DEFAULT_GRADE" = ""; then
> DEFAULT_GRADE=$DEFAULT_BASE_GRADE.gc
> fi
> @@ -2964,6 +2950,10 @@
> EXE_RPATH_SEP=" -Wl,-rpath,"
> SHLIB_RPATH_OPT="-Wl,-rpath,"
> SHLIB_RPATH_SEP=" -Wl,-rpath,"
> +
> +SHLIB_USE_INSTALL_NAME=""
> +SHLIB_INSTALL_NAME_FLAG="-install_name "
> +
> CFLAGS_FOR_PIC="-fpic -DMR_PIC"
> EXT_FOR_PIC_OBJECTS=pic_o
> # Object files with extension $EXT_FOR_LINK_WITH_PIC_OBJECTS are used
> @@ -3194,6 +3184,28 @@
> EXT_FOR_LINK_WITH_PIC_OBJECTS=o
> DEFAULT_LINKAGE=static
> ;;
> + *powerpc*apple*darwin*)
> + # If the compiler is gcc then use darwin style dynamic linking.
> + # Otherwise use static linking.
> + if test "$GCC_PROG" != ""; then
> + SHLIB_USE_INSTALL_NAME="--shlib-linker-use-install-name"
> + SHLIB_INSTALL_NAME_FLAG="-install_name "
> + LINK_SHARED_OBJ="$GCC_PROG -dynamiclib -single_module"
> + LINK_SHARED_OBJ_SH="$GCC_PROG -dynamiclib -single_module"
> + EXT_FOR_SHARED_LIB=dylib
> + EXT_FOR_LINK_WITH_PIC_OBJECTS=o
> + CFLAGS_FOR_PIC="-fPIC -DMR_PIC"
> + ERROR_UNDEFINED="-undefined error"
> + ALLOW_UNDEFINED="-undefined suppress"
> + AC_MSG_RESULT(yes)
> + else
> + CFLAGS_FOR_PIC=
> + EXT_FOR_PIC_OBJECTS=o
> + EXT_FOR_LINK_WITH_PIC_OBJECTS=o
> + DEFAULT_LINKAGE=static
> + AC_MSG_RESULT(no)
> + fi
> + ;;
> *)
As I mentioned above, there really ought to be a way to tell it
use static linking (perhaps an option to configure?).
> # CFLAGS_FOR_PIC is used by boehm_gc/Makefile when creating
> # libgc.a. If the system doesn't support shared libraries,
> @@ -3363,6 +3375,8 @@
> AC_SUBST(EXE_RPATH_SEP)
> AC_SUBST(SHLIB_RPATH_OPT)
> AC_SUBST(SHLIB_RPATH_SEP)
> +AC_SUBST(SHLIB_USE_INSTALL_NAME)
> +AC_SUBST(SHLIB_INSTALL_NAME_FLAG)
> AC_SUBST(CFLAGS_FOR_PIC)
> AC_SUBST(EXT_FOR_PIC_OBJECTS)
> AC_SUBST(EXT_FOR_LINK_WITH_PIC_OBJECTS)
> @@ -3887,6 +3901,9 @@
> # then don't do a `make clean' before running `make'.
> rm -f runtime/libmer_rt.so library/libmer_std.so bytecode/libmbi.so
> rm -f trace/libmer_trace.so browser/libmer_browse.so
> + rm -f runtime/libmer_rt.dylib library/libmer_std.dylib
> + rm -f boehm_gc/libgc.dylib bytecode/libmbi.dylib
> + rm -f trace/libmer_trace.dylib browser/libmer_browser.dylib
> ;;
> esac],
> [reconfiguring=$reconfiguring]
> Index: boehm_gc/Makefile
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/boehm_gc/Makefile,v
> retrieving revision 1.57
> diff -u -r1.57 Makefile
> --- boehm_gc/Makefile 28 Oct 2003 08:48:40 -0000 1.57
> +++ boehm_gc/Makefile 8 Oct 2004 11:03:32 -0000
> @@ -521,6 +521,11 @@
> ./if_not_there on_sparc_sunos5_so \
> $(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load.o -lc
>
> +# Darwin shared library version of the gc.
> +lib$(GC_GRADE).dylib: $(OBJS) $(UTILS)
> + $(LINK_SHARED_OBJ) -install_name \
> + $(FINAL_INSTALL_MERC_GC_LIB_DIR)/lib$(GC_GRADE).dylib \
> + -o lib$(GC_GRADE).dylib $(OBJS) dyn_load.o -lc
>
> # SunOS5 shared library version of the collector
> sunos5gc.so: $(OBJS) dyn_load_sunos53.o
> @@ -727,13 +732,16 @@
> #-----------------------------------------------------------------------------#
>
> # The Mmakefile invokes `make $(EXT_FOR_SHARED_LIB)',
> -# so we need targets `a', `so', and `dll'.
> +# so we need targets `a', `so', 'dylib' and `dll'.
>
> .PHONY: a
> a: lib$(GC_GRADE).a
>
> .PHONY: so
> so: lib$(GC_GRADE).so
> +
> +.PHONY: dylib
> +dylib: lib$(GC_GRADE).dylib
>
> #-----------------------------------------------------------------------------#
> # support for DLLs using gnu-win32
> Index: boehm_gc/Makefile.direct
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/boehm_gc/Makefile.direct,v
> retrieving revision 1.6
> diff -u -r1.6 Makefile.direct
> --- boehm_gc/Makefile.direct 28 Oct 2003 08:48:40 -0000 1.6
> +++ boehm_gc/Makefile.direct 8 Oct 2004 11:03:32 -0000
> @@ -521,6 +521,11 @@
> ./if_not_there on_sparc_sunos5_so \
> $(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load.o -lc
>
> +# Darwin shared library version of the gc.
> +lib$(GC_GRADE).dylib: $(OBJS) $(UTILS)
> + $(LINK_SHARED_OBJ) -install_name \
> + $(FINAL_INSTALL_MERC_GC_LIB_DIR)/lib$(GC_GRADE).dylib \
> + -o lib$(GC_GRADE).dylib $(OBJS) dyn_load.o -lc
>
> # SunOS5 shared library version of the collector
> sunos5gc.so: $(OBJS) dyn_load_sunos53.o
> @@ -734,6 +739,9 @@
>
> .PHONY: so
> so: lib$(GC_GRADE).so
> +
> +.PHONY: dylib
> +dylib: lib$(GC_GRADE).dylib
>
> #-----------------------------------------------------------------------------#
> # support for DLLs using gnu-win32
> Index: boehm_gc/Mmakefile
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/boehm_gc/Mmakefile,v
> retrieving revision 1.27
> diff -u -r1.27 Mmakefile
> --- boehm_gc/Mmakefile 11 Dec 2003 03:58:53 -0000 1.27
> +++ boehm_gc/Mmakefile 8 Oct 2004 11:03:32 -0000
> @@ -15,7 +15,6 @@
> MERCURY_DIR=..
> LINK_BOEHM_GC_ONLY=yes
> include $(MERCURY_DIR)/Mmake.common
> -
> #-----------------------------------------------------------------------------#
>
> .PHONY: lib$(GC_GRADE)
> @@ -38,6 +37,8 @@
>
> lib$(GC_GRADE).dll: submake
>
> +lib$(GC_GRADE).dylib: submake
> +
> endif
>
> MMAKEFLAGS=
> @@ -75,6 +76,7 @@
> MAKEFLAGS=""; export MAKEFLAGS; \
> $(MAKE) $(MMAKEFLAGS) -j1 GRADE=$(GRADE) GC_GRADE=$(GC_GRADE) \
> lib$(GC_GRADE).$A lib$(GC_GRADE).$(EXT_FOR_SHARED_LIB) \
> + FINAL_INSTALL_MERC_GC_LIB_DIR=$(FINAL_INSTALL_MERC_GC_LIB_DIR) \
> $(EXT_FOR_SHARED_LIB)
>
> clean_local:
> Index: browser/Mercury.options
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/browser/Mercury.options,v
> retrieving revision 1.3
> diff -u -r1.3 Mercury.options
> --- browser/Mercury.options 10 Dec 2003 07:04:21 -0000 1.3
> +++ browser/Mercury.options 8 Oct 2004 11:03:32 -0000
> @@ -10,3 +10,4 @@
> MCFLAGS-mer_mdbcomp = --no-warn-nothing-exported
>
> EXTRA_LIBRARIES-libmer_browser.so = mer_mdbcomp
> +EXTRA_LIBRARIES-libmer_browser.dylib = mer_mdbcomp
> Index: browser/Mmakefile
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
> retrieving revision 1.40
> diff -u -r1.40 Mmakefile
> --- browser/Mmakefile 2 Aug 2004 08:30:01 -0000 1.40
> +++ browser/Mmakefile 8 Oct 2004 11:03:32 -0000
> @@ -54,7 +54,8 @@
> MLFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
> -R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
> MCFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
> - -R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
> + -R$(FINAL_INSTALL_MERC_GC_LIB_DIR) \
> + --shlib-linker-install-name-path $(FINAL_INSTALL_MERC_LIB_DIR)
> MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
> $(READLINE_LIBRARIES)
>
> @@ -137,6 +138,7 @@
> exit $$status
>
> lib$(BROWSER_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
> +lib$(BROWSER_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
> lib$(BROWSER_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
> lib$(BROWSER_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
> lib$(BROWSER_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
> @@ -204,8 +206,8 @@
> # with the package name prefixed to the file name with a ".", not a "/".
> # So we copy the Java source files to where the Java compiler expects them to be.
> #
> -# XXX This is a hack. We ought to change the Mercury compiler so that it generates
> -# the Java files with the right names in the first place.
> +# XXX This is a hack. We ought to change the Mercury compiler so that it
> +# generates the Java files with the right names in the first place.
> #
>
> mdb/%.java: mdb.%.java
> Index: compiler/compile_target_code.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
> retrieving revision 1.62
> diff -u -r1.62 compile_target_code.m
> --- compiler/compile_target_code.m 28 Sep 2004 01:59:00 -0000 1.62
> +++ compiler/compile_target_code.m 8 Oct 2004 11:03:32 -0000
> @@ -10,14 +10,14 @@
> %
> %-----------------------------------------------------------------------------%
>
> -:- module backend_libs__compile_target_code.
> +:- module backend_libs.compile_target_code.
>
> :- interface.
>
> -:- import_module parse_tree__prog_data.
> -:- import_module parse_tree__prog_io.
> -:- import_module parse_tree__modules.
> -:- import_module libs__globals.
> +:- import_module parse_tree.prog_data.
> +:- import_module parse_tree.prog_io.
> +:- import_module parse_tree.modules.
> +:- import_module libs.globals.
>
> :- import_module bool, list, io, std_util.
>
> @@ -31,47 +31,47 @@
> ; non_pic.
>
> % compile_c_file(ErrorStream, PIC, CFile, ObjFile, Succeeded).
> -:- pred compile_c_file(io__output_stream::in, pic::in, string::in, string::in,
> +:- pred compile_c_file(io.output_stream::in, pic::in, string::in, string::in,
> bool::out, io::di, io::uo) is det.
>
> % compile_c_file(ErrorStream, PIC, ModuleName, Succeeded).
> -:- pred compile_c_file(io__output_stream::in, pic::in, module_name::in,
> +:- pred compile_c_file(io.output_stream::in, pic::in, module_name::in,
> bool::out, io::di, io::uo) is det.
>
> % assemble(ErrorStream, PIC, ModuleName, Succeeded).
> -:- pred assemble(io__output_stream::in, pic::in, module_name::in,
> +:- pred assemble(io.output_stream::in, pic::in, module_name::in,
> bool::out, io::di, io::uo) is det.
>
> % compile_java_file(ErrorStream, JavaFile, Succeeded).
> -:- pred compile_java_file(io__output_stream::in, string::in, bool::out,
> +:- pred compile_java_file(io.output_stream::in, string::in, bool::out,
> io::di, io::uo) is det.
>
> % il_assemble(ErrorStream, ModuleName, HasMain, Succeeded).
> -:- pred il_assemble(io__output_stream::in, module_name::in, has_main::in,
> +:- pred il_assemble(io.output_stream::in, module_name::in, has_main::in,
> bool::out, io::di, io::uo) is det.
>
> % il_assemble(ErrorStream, ILFile, DLLFile, HasMain, Succeeded).
> -:- pred il_assemble(io__output_stream::in, file_name::in, file_name::in,
> +:- pred il_assemble(io.output_stream::in, file_name::in, file_name::in,
> has_main::in, bool::out, io::di, io::uo) is det.
>
> % compile_managed_cplusplus_file(ErrorStream,
> % MCPPFile, DLLFile, Succeeded).
> -:- pred compile_managed_cplusplus_file(io__output_stream::in,
> +:- pred compile_managed_cplusplus_file(io.output_stream::in,
> file_name::in, file_name::in, bool::out, io::di, io::uo) is det.
>
> % compile_csharp_file(ErrorStream, C#File, DLLFile, Succeeded).
> -:- pred compile_csharp_file(io__output_stream::in, module_imports::in,
> +:- pred compile_csharp_file(io.output_stream::in, module_imports::in,
> file_name::in, file_name::in, bool::out, io::di, io::uo) is det.
>
> % make_init_file(ErrorStream, MainModuleName, ModuleNames, Succeeded).
> %
> % Make the `.init' file for a library containing the given modules.
> -:- pred make_init_file(io__output_stream::in, module_name::in,
> +:- pred make_init_file(io.output_stream::in, module_name::in,
> list(module_name)::in, bool::out, io::di, io::uo) is det.
>
> % make_init_obj_file(ErrorStream, MainModuleName,
> % AllModuleNames, MaybeInitObjFileName).
> -:- pred make_init_obj_file(io__output_stream::in, module_name::in,
> +:- pred make_init_obj_file(io.output_stream::in, module_name::in,
> list(module_name)::in, maybe(file_name)::out, io::di, io::uo) is det.
>
> :- type linked_target_type
> @@ -81,7 +81,7 @@
> ; java_archive.
>
> % link(TargetType, MainModuleName, ObjectFileNames, Succeeded).
> -:- pred link(io__output_stream::in, linked_target_type::in, module_name::in,
> +:- pred link(io.output_stream::in, linked_target_type::in, module_name::in,
> list(string)::in, bool::out, io::di, io::uo) is det.
>
> % link_module_list(ModulesToLink, FactTableObjFiles, Succeeded).
> @@ -104,7 +104,7 @@
>
> % split_c_to_obj(ErrorStream, ModuleName, NumChunks, Succeeded).
> % Compile the `.c' files produced for a module with `--split-c-files'.
> -:- pred split_c_to_obj(io__output_stream::in, module_name::in,
> +:- pred split_c_to_obj(io.output_stream::in, module_name::in,
> int::in, bool::out, io::di, io::uo) is det.
>
> % Write the number of `.c' files written by this
> @@ -148,7 +148,7 @@
> :- mode maybe_pic_object_file_extension(in, in, out) is det.
> :- mode maybe_pic_object_file_extension(in, out, in) is semidet.
>
> - % Same as above except the globals are obtained from the io__state.
> + % Same as above except the globals are obtained from the io.state.
> :- pred maybe_pic_object_file_extension(pic::in, string::out, io::di, io::uo)
> is det.
>
> @@ -156,15 +156,15 @@
>
> :- implementation.
>
> -:- import_module backend_libs__foreign.
> -:- import_module backend_libs__name_mangle.
> -:- import_module hlds__passes_aux.
> -:- import_module libs__globals.
> -:- import_module libs__handle_options.
> -:- import_module libs__options.
> -:- import_module libs__trace_params.
> -:- import_module parse_tree__error_util.
> -:- import_module parse_tree__prog_out.
> +:- import_module backend_libs.foreign.
> +:- import_module backend_libs.name_mangle.
> +:- import_module hlds.passes_aux.
> +:- import_module libs.globals.
> +:- import_module libs.handle_options.
> +:- import_module libs.options.
> +:- import_module libs.trace_params.
> +:- import_module parse_tree.error_util.
> +:- import_module parse_tree.prog_out.
>
> :- import_module char, dir, getopt, int, require, string.
>
> @@ -188,13 +188,13 @@
> ).
>
> il_assemble(ErrorStream, IL_File, TargetFile, HasMain, Succeeded, !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> - globals__io_lookup_bool_option(sign_assembly, SignAssembly, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(sign_assembly, SignAssembly, !IO),
> maybe_write_string(Verbose, "% Assembling `", !IO),
> maybe_write_string(Verbose, IL_File, !IO),
> maybe_write_string(Verbose, "':\n", !IO),
> - globals__io_lookup_string_option(il_assembler, ILASM, !IO),
> - globals__io_lookup_accumulating_option(ilasm_flags, ILASMFlagsList, !IO),
> + globals.io_lookup_string_option(il_assembler, ILASM, !IO),
> + globals.io_lookup_accumulating_option(ilasm_flags, ILASMFlagsList, !IO),
> join_string_list(ILASMFlagsList, "", "", " ", ILASMFlags),
> ( SignAssembly = yes ->
> SignOpt = "/keyf=mercury.sn "
> @@ -206,7 +206,7 @@
> ;
> VerboseOpt = "/quiet "
> ),
> - globals__io_lookup_bool_option(target_debug, Debug, !IO),
> + globals.io_lookup_bool_option(target_debug, Debug, !IO),
> ( Debug = yes ->
> DebugOpt = "/debug "
> ;
> @@ -217,7 +217,7 @@
> ;
> TargetOpt = "/dll "
> ),
> - string__append_list([ILASM, " ", SignOpt, VerboseOpt, DebugOpt,
> + string.append_list([ILASM, " ", SignOpt, VerboseOpt, DebugOpt,
> TargetOpt, ILASMFlags, " /out=", TargetFile,
> " ", IL_File], Command),
> invoke_system_command(ErrorStream, verbose_commands, Command,
> @@ -225,14 +225,14 @@
>
> compile_managed_cplusplus_file(ErrorStream, MCPPFileName, DLLFileName,
> Succeeded, !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> maybe_write_string(Verbose, "% Compiling `", !IO),
> maybe_write_string(Verbose, MCPPFileName, !IO),
> maybe_write_string(Verbose, "':\n", !IO),
> - globals__io_lookup_string_option(mcpp_compiler, MCPP, !IO),
> - globals__io_lookup_accumulating_option(mcpp_flags, MCPPFlagsList, !IO),
> + globals.io_lookup_string_option(mcpp_compiler, MCPP, !IO),
> + globals.io_lookup_accumulating_option(mcpp_flags, MCPPFlagsList, !IO),
> join_string_list(MCPPFlagsList, "", "", " ", MCPPFlags),
> - globals__io_lookup_bool_option(target_debug, Debug, !IO),
> + globals.io_lookup_bool_option(target_debug, Debug, !IO),
> (
> Debug = yes,
> DebugOpt = "/Zi "
> @@ -242,19 +242,19 @@
> ),
>
> % XXX Should we introduce a `--mcpp-include-directory' option?
> - globals__io_lookup_accumulating_option(c_include_directory,
> + globals.io_lookup_accumulating_option(c_include_directory,
> C_Incl_Dirs, !IO),
> - InclOpts = string__append_list(list__condense(list__map(
> + InclOpts = string.append_list(list.condense(list.map(
> (func(C_INCL) = ["-I", C_INCL, " "]), C_Incl_Dirs))),
>
> % XXX Should we use a separate dll_directories options?
> - globals__io_lookup_accumulating_option(link_library_directories,
> + globals.io_lookup_accumulating_option(link_library_directories,
> DLLDirs, !IO),
> DLLDirOpts = "-AIMercury/dlls " ++
> - string__append_list(list__condense(list__map(
> + string.append_list(list.condense(list.map(
> (func(DLLDir) = ["-AI", DLLDir, " "]), DLLDirs))),
>
> - string__append_list([MCPP, " -CLR ", DebugOpt, InclOpts,
> + string.append_list([MCPP, " -CLR ", DebugOpt, InclOpts,
> DLLDirOpts, MCPPFlags, " ", MCPPFileName,
> " -LD -o ", DLLFileName],
> Command),
> @@ -263,20 +263,20 @@
>
> compile_csharp_file(ErrorStream, Imports, CSharpFileName0, DLLFileName,
> Succeeded, !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> maybe_write_string(Verbose, "% Compiling `", !IO),
> maybe_write_string(Verbose, CSharpFileName, !IO),
> maybe_write_string(Verbose, "':\n", !IO),
> - globals__io_lookup_string_option(csharp_compiler, CSC, !IO),
> - globals__io_lookup_accumulating_option(csharp_flags, CSCFlagsList,
> + globals.io_lookup_string_option(csharp_compiler, CSC, !IO),
> + globals.io_lookup_accumulating_option(csharp_flags, CSCFlagsList,
> !IO),
> join_string_list(CSCFlagsList, "", "", " ", CSCFlags),
>
> % XXX This is because the MS C# compiler doesn't understand
> % / as a directory seperator.
> - CSharpFileName = string__replace_all(CSharpFileName0, "/", "\\\\"),
> + CSharpFileName = string.replace_all(CSharpFileName0, "/", "\\\\"),
>
> - globals__io_lookup_bool_option(target_debug, Debug, !IO),
> + globals.io_lookup_bool_option(target_debug, Debug, !IO),
> (
> Debug = yes,
> % XXX This needs testing before it can be enabled
> @@ -290,10 +290,10 @@
> ),
>
> % XXX Should we use a separate dll_directories options?
> - globals__io_lookup_accumulating_option(link_library_directories,
> + globals.io_lookup_accumulating_option(link_library_directories,
> DLLDirs, !IO),
> DLLDirOpts = "/lib:Mercury/dlls " ++
> - string__append_list(list__condense(list__map(
> + string.append_list(list.condense(list.map(
> (func(DLLDir) = ["/lib:", DLLDir, " "]), DLLDirs))),
>
> ( mercury_std_library_module_name(Imports ^ module_name) ->
> @@ -301,22 +301,22 @@
> ;
> Prefix = "/r:"
> ),
> - ForeignDeps = list__map(
> + ForeignDeps = list.map(
> (func(M) =
> foreign_import_module_name(M, Imports ^ module_name)
> ), Imports ^ foreign_import_module_info ),
> ReferencedDlls = referenced_dlls(Imports ^ module_name,
> Imports ^ int_deps ++ Imports ^ impl_deps ++ ForeignDeps),
> - list__map_foldl(
> + list.map_foldl(
> (pred(Mod::in, Result::out, IO0::di, IO::uo) is det :-
> module_name_to_file_name(Mod, ".dll", no, FileName,
> IO0, IO),
> Result = [Prefix, FileName, " "]
> ), ReferencedDlls, ReferencedDllsList, !IO),
> - ReferencedDllsStr = string__append_list(
> - list__condense(ReferencedDllsList)),
> + ReferencedDllsStr = string.append_list(
> + list.condense(ReferencedDllsList)),
>
> - string__append_list([CSC, DebugOpt,
> + string.append_list([CSC, DebugOpt,
> " /t:library ", DLLDirOpts, CSCFlags, ReferencedDllsStr,
> " /out:", DLLFileName, " ", CSharpFileName], Command),
> invoke_system_command(ErrorStream, verbose_commands, Command,
> @@ -328,7 +328,7 @@
> split_c_to_obj(ErrorStream, ModuleName, 0, NumChunks, Succeeded, !IO).
>
> % compile each of the C files in `<module>.dir'
> -:- pred split_c_to_obj(io__output_stream::in, module_name::in,
> +:- pred split_c_to_obj(io.output_stream::in, module_name::in,
> int::in, int::in, bool::out, io::di, io::uo) is det.
>
> split_c_to_obj(ErrorStream, ModuleName, Chunk, NumChunks, Succeeded, !IO) :-
> @@ -336,7 +336,7 @@
> Succeeded = yes
> ;
> % XXX should this use maybe_pic_object_file_extension?
> - globals__io_lookup_string_option(object_file_extension, Obj,
> + globals.io_lookup_string_option(object_file_extension, Obj,
> !IO),
> module_name_to_split_c_file_name(ModuleName, Chunk,
> ".c", C_File, !IO),
> @@ -365,18 +365,18 @@
> compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO).
>
> compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> - globals__io_lookup_string_option(c_flag_to_name_object_file,
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_string_option(c_flag_to_name_object_file,
> NameObjectFile, !IO),
> maybe_write_string(Verbose, "% Compiling `", !IO),
> maybe_write_string(Verbose, C_File, !IO),
> maybe_write_string(Verbose, "':\n", !IO),
> - globals__io_lookup_string_option(cc, CC, !IO),
> - globals__io_lookup_accumulating_option(cflags, C_Flags_List, !IO),
> + globals.io_lookup_string_option(cc, CC, !IO),
> + globals.io_lookup_accumulating_option(cflags, C_Flags_List, !IO),
> join_string_list(C_Flags_List, "", "", " ", CFLAGS),
>
> - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO),
> - globals__io_lookup_bool_option(split_c_files, SplitCFiles, !IO),
> + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO),
> + globals.io_lookup_bool_option(split_c_files, SplitCFiles, !IO),
> ( (UseSubdirs = yes ; SplitCFiles = yes) ->
> % the source file (foo.c) will be compiled in a subdirectory
> % (either Mercury/cs, foo.dir, or Mercury/dirs/foo.dir,
> @@ -387,67 +387,67 @@
> ;
> SubDirInclOpt = ""
> ),
> - globals__io_lookup_accumulating_option(c_include_directory,
> + globals.io_lookup_accumulating_option(c_include_directory,
> C_Incl_Dirs, !IO),
> - InclOpt = string__append_list(list__condense(list__map(
> + InclOpt = string.append_list(list.condense(list.map(
> (func(C_INCL) = ["-I", C_INCL, " "]), C_Incl_Dirs))),
> - globals__io_lookup_bool_option(split_c_files, Split_C_Files, !IO),
> + globals.io_lookup_bool_option(split_c_files, Split_C_Files, !IO),
> ( Split_C_Files = yes ->
> SplitOpt = "-DMR_SPLIT_C_FILES "
> ;
> SplitOpt = ""
> ),
> - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO),
> + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO),
> ( HighLevelCode = yes ->
> HighLevelCodeOpt = "-DMR_HIGHLEVEL_CODE "
> ;
> HighLevelCodeOpt = ""
> ),
> - globals__io_lookup_bool_option(gcc_nested_functions,
> + globals.io_lookup_bool_option(gcc_nested_functions,
> GCC_NestedFunctions, !IO),
> ( GCC_NestedFunctions = yes ->
> NestedFunctionsOpt = "-DMR_USE_GCC_NESTED_FUNCTIONS "
> ;
> NestedFunctionsOpt = ""
> ),
> - globals__io_lookup_bool_option(highlevel_data, HighLevelData, !IO),
> + globals.io_lookup_bool_option(highlevel_data, HighLevelData, !IO),
> ( HighLevelData = yes ->
> HighLevelDataOpt = "-DMR_HIGHLEVEL_DATA "
> ;
> HighLevelDataOpt = ""
> ),
> - globals__io_lookup_bool_option(gcc_global_registers, GCC_Regs, !IO),
> + globals.io_lookup_bool_option(gcc_global_registers, GCC_Regs, !IO),
> ( GCC_Regs = yes ->
> - globals__io_lookup_string_option(cflags_for_regs,
> + globals.io_lookup_string_option(cflags_for_regs,
> CFLAGS_FOR_REGS, !IO),
> RegOpt = "-DMR_USE_GCC_GLOBAL_REGISTERS "
> ;
> CFLAGS_FOR_REGS = "",
> RegOpt = ""
> ),
> - globals__io_lookup_bool_option(gcc_non_local_gotos, GCC_Gotos, !IO),
> + globals.io_lookup_bool_option(gcc_non_local_gotos, GCC_Gotos, !IO),
> ( GCC_Gotos = yes ->
> GotoOpt = "-DMR_USE_GCC_NONLOCAL_GOTOS ",
> - globals__io_lookup_string_option(cflags_for_gotos,
> + globals.io_lookup_string_option(cflags_for_gotos,
> CFLAGS_FOR_GOTOS, !IO)
> ;
> GotoOpt = "",
> CFLAGS_FOR_GOTOS = ""
> ),
> - globals__io_lookup_bool_option(asm_labels, ASM_Labels, !IO),
> + globals.io_lookup_bool_option(asm_labels, ASM_Labels, !IO),
> ( ASM_Labels = yes ->
> AsmOpt = "-DMR_USE_ASM_LABELS "
> ;
> AsmOpt = ""
> ),
> - globals__io_lookup_bool_option(parallel, Parallel, !IO),
> + globals.io_lookup_bool_option(parallel, Parallel, !IO),
> ( Parallel = yes ->
> - globals__io_lookup_string_option(cflags_for_threads,
> + globals.io_lookup_string_option(cflags_for_threads,
> CFLAGS_FOR_THREADS, !IO)
> ;
> CFLAGS_FOR_THREADS = ""
> ),
> - globals__io_get_gc_method(GC_Method, !IO),
> + globals.io_get_gc_method(GC_Method, !IO),
> (
> GC_Method = automatic,
> GC_Opt = ""
> @@ -464,33 +464,33 @@
> GC_Method = accurate,
> GC_Opt = "-DMR_NATIVE_GC "
> ),
> - globals__io_lookup_bool_option(profile_calls, ProfileCalls, !IO),
> + globals.io_lookup_bool_option(profile_calls, ProfileCalls, !IO),
> ( ProfileCalls = yes ->
> ProfileCallsOpt = "-DMR_MPROF_PROFILE_CALLS "
> ;
> ProfileCallsOpt = ""
> ),
> - globals__io_lookup_bool_option(profile_time, ProfileTime, !IO),
> + globals.io_lookup_bool_option(profile_time, ProfileTime, !IO),
> ( ProfileTime = yes ->
> ProfileTimeOpt = "-DMR_MPROF_PROFILE_TIME "
> ;
> ProfileTimeOpt = ""
> ),
> - globals__io_lookup_bool_option(profile_memory, ProfileMemory, !IO),
> + globals.io_lookup_bool_option(profile_memory, ProfileMemory, !IO),
> ( ProfileMemory = yes ->
> ProfileMemoryOpt = "-DMR_MPROF_PROFILE_MEMORY "
> ;
> ProfileMemoryOpt = ""
> ),
> - globals__io_lookup_bool_option(profile_deep, ProfileDeep, !IO),
> + globals.io_lookup_bool_option(profile_deep, ProfileDeep, !IO),
> ( ProfileDeep = yes ->
> ProfileDeepOpt = "-DMR_DEEP_PROFILING "
> ;
> ProfileDeepOpt = ""
> ),
> - globals__io_lookup_bool_option(record_term_sizes_as_words,
> + globals.io_lookup_bool_option(record_term_sizes_as_words,
> RecordTermSizesAsWords, !IO),
> - globals__io_lookup_bool_option(record_term_sizes_as_cells,
> + globals.io_lookup_bool_option(record_term_sizes_as_cells,
> RecordTermSizesAsCells, !IO),
> (
> RecordTermSizesAsWords = yes,
> @@ -513,7 +513,7 @@
> ),
> (
> PIC = pic,
> - globals__io_lookup_string_option(cflags_for_pic,
> + globals.io_lookup_string_option(cflags_for_pic,
> CFLAGS_FOR_PIC, !IO),
> PIC_Reg = yes
> ;
> @@ -523,7 +523,7 @@
> ;
> PIC = non_pic,
> CFLAGS_FOR_PIC = "",
> - globals__io_lookup_bool_option(pic_reg, PIC_Reg, !IO)
> + globals.io_lookup_bool_option(pic_reg, PIC_Reg, !IO)
> ),
> ( PIC_Reg = yes ->
> % This will be ignored for architectures/grades
> @@ -534,57 +534,57 @@
> PIC_Reg_Opt = ""
> ),
>
> - globals__io_get_tags_method(Tags_Method, !IO),
> + globals.io_get_tags_method(Tags_Method, !IO),
> ( Tags_Method = high ->
> TagsOpt = "-DMR_HIGHTAGS "
> ;
> TagsOpt = ""
> ),
> - globals__io_lookup_int_option(num_tag_bits, NumTagBits, !IO),
> - string__int_to_string(NumTagBits, NumTagBitsString),
> - string__append_list(
> + globals.io_lookup_int_option(num_tag_bits, NumTagBits, !IO),
> + string.int_to_string(NumTagBits, NumTagBitsString),
> + string.append_list(
> ["-DMR_TAGBITS=", NumTagBitsString, " "], NumTagBitsOpt),
> - globals__io_lookup_bool_option(decl_debug, DeclDebug, !IO),
> + globals.io_lookup_bool_option(decl_debug, DeclDebug, !IO),
> ( DeclDebug = yes ->
> DeclDebugOpt = "-DMR_DECL_DEBUG "
> ;
> DeclDebugOpt = ""
> ),
> - globals__io_lookup_bool_option(exec_trace, ExecTrace, !IO),
> + globals.io_lookup_bool_option(exec_trace, ExecTrace, !IO),
> ( ExecTrace = yes ->
> ExecTraceOpt = "-DMR_EXEC_TRACE "
> ;
> ExecTraceOpt = ""
> ),
> - globals__io_lookup_bool_option(target_debug, Target_Debug, !IO),
> + globals.io_lookup_bool_option(target_debug, Target_Debug, !IO),
> ( Target_Debug = yes ->
> - globals__io_lookup_string_option(cflags_for_debug,
> + globals.io_lookup_string_option(cflags_for_debug,
> Target_DebugOpt0, !IO),
> - string__append(Target_DebugOpt0, " ", Target_DebugOpt)
> + string.append(Target_DebugOpt0, " ", Target_DebugOpt)
> ;
> Target_DebugOpt = ""
> ),
> - globals__io_lookup_bool_option(low_level_debug, LL_Debug, !IO),
> + globals.io_lookup_bool_option(low_level_debug, LL_Debug, !IO),
> ( LL_Debug = yes ->
> LL_DebugOpt = "-DMR_LOW_LEVEL_DEBUG "
> ;
> LL_DebugOpt = ""
> ),
> - globals__io_lookup_bool_option(use_trail, UseTrail, !IO),
> + globals.io_lookup_bool_option(use_trail, UseTrail, !IO),
> ( UseTrail = yes ->
> UseTrailOpt = "-DMR_USE_TRAIL "
> ;
> UseTrailOpt = ""
> ),
> - globals__io_lookup_bool_option(reserve_tag, ReserveTag, !IO),
> + globals.io_lookup_bool_option(reserve_tag, ReserveTag, !IO),
> ( ReserveTag = yes ->
> ReserveTagOpt = "-DMR_RESERVE_TAG "
> ;
> ReserveTagOpt = ""
> ),
> - globals__io_lookup_bool_option(use_minimal_model_stack_copy,
> + globals.io_lookup_bool_option(use_minimal_model_stack_copy,
> MinimalModelStackCopy, !IO),
> - globals__io_lookup_bool_option(use_minimal_model_own_stacks,
> + globals.io_lookup_bool_option(use_minimal_model_own_stacks,
> MinimalModelOwnStacks, !IO),
> (
> MinimalModelStackCopy = yes,
> @@ -604,7 +604,7 @@
> MinimalModelOwnStacks = no,
> MinimalModelBaseOpt = ""
> ),
> - globals__io_lookup_bool_option(minimal_model_debug, MinimalModelDebug,
> + globals.io_lookup_bool_option(minimal_model_debug, MinimalModelDebug,
> !IO),
> (
> MinimalModelDebug = yes,
> @@ -620,34 +620,34 @@
> MinimalModelDebug = no,
> MinimalModelOpt = MinimalModelBaseOpt
> ),
> - globals__io_lookup_bool_option(type_layout, TypeLayoutOption, !IO),
> + globals.io_lookup_bool_option(type_layout, TypeLayoutOption, !IO),
> ( TypeLayoutOption = no ->
> TypeLayoutOpt = "-DMR_NO_TYPE_LAYOUT "
> ;
> TypeLayoutOpt = ""
> ),
> - globals__io_lookup_bool_option(c_optimize, C_optimize, !IO),
> + globals.io_lookup_bool_option(c_optimize, C_optimize, !IO),
> ( C_optimize = yes ->
> - globals__io_lookup_string_option(cflags_for_optimization,
> + globals.io_lookup_string_option(cflags_for_optimization,
> OptimizeOpt, !IO)
> ;
> OptimizeOpt = ""
> ),
> - globals__io_lookup_bool_option(ansi_c, Ansi, !IO),
> + globals.io_lookup_bool_option(ansi_c, Ansi, !IO),
> ( Ansi = yes ->
> - globals__io_lookup_string_option(cflags_for_ansi, AnsiOpt, !IO)
> + globals.io_lookup_string_option(cflags_for_ansi, AnsiOpt, !IO)
> ;
> AnsiOpt = ""
> ),
> - globals__io_lookup_bool_option(inline_alloc, InlineAlloc, !IO),
> + globals.io_lookup_bool_option(inline_alloc, InlineAlloc, !IO),
> ( InlineAlloc = yes ->
> InlineAllocOpt = "-DMR_INLINE_ALLOC -DSILENT "
> ;
> InlineAllocOpt = ""
> ),
> - globals__io_lookup_bool_option(warn_target_code, Warn, !IO),
> + globals.io_lookup_bool_option(warn_target_code, Warn, !IO),
> ( Warn = yes ->
> - globals__io_lookup_string_option(cflags_for_warnings,
> + globals.io_lookup_string_option(cflags_for_warnings,
> WarningOpt, !IO)
> ;
> WarningOpt = ""
> @@ -657,7 +657,7 @@
> % e.g. CFLAGS_FOR_REGS must come after OptimizeOpt so that
> % it can override -fomit-frame-pointer with -fno-omit-frame-pointer.
> % Also be careful that each option is separated by spaces.
> - string__append_list([CC, " ", SubDirInclOpt, InclOpt,
> + string.append_list([CC, " ", SubDirInclOpt, InclOpt,
> SplitOpt, " ", OptimizeOpt, " ",
> HighLevelCodeOpt, NestedFunctionsOpt, HighLevelDataOpt,
> RegOpt, GotoOpt, AsmOpt,
> @@ -676,15 +676,15 @@
> %-----------------------------------------------------------------------------%
>
> compile_java_file(ErrorStream, JavaFile, Succeeded, !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> maybe_write_string(Verbose, "% Compiling `", !IO),
> maybe_write_string(Verbose, JavaFile, !IO),
> maybe_write_string(Verbose, "':\n", !IO),
> - globals__io_lookup_string_option(java_compiler, JavaCompiler, !IO),
> - globals__io_lookup_accumulating_option(java_flags, JavaFlagsList, !IO),
> + globals.io_lookup_string_option(java_compiler, JavaCompiler, !IO),
> + globals.io_lookup_accumulating_option(java_flags, JavaFlagsList, !IO),
> join_string_list(JavaFlagsList, "", "", " ", JAVAFLAGS),
>
> - globals__io_lookup_accumulating_option(java_classpath,
> + globals.io_lookup_accumulating_option(java_classpath,
> Java_Incl_Dirs, !IO),
> % XXX PathSeparator should be ";" on Windows
> PathSeparator = ":",
> @@ -696,21 +696,21 @@
> ( ClassPath = "" ->
> InclOpt = ""
> ;
> - InclOpt = string__append_list([
> + InclOpt = string.append_list([
> "-classpath ", quote_arg(ClassPath), " "])
> ),
>
> - globals__io_lookup_bool_option(target_debug, Target_Debug, !IO),
> + globals.io_lookup_bool_option(target_debug, Target_Debug, !IO),
> ( Target_Debug = yes ->
> Target_DebugOpt = "-g "
> ;
> Target_DebugOpt = ""
> ),
>
> - globals__io_lookup_bool_option(use_subdirs, UseSubdirs, !IO),
> - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO),
> - globals__io_lookup_string_option(fullarch, FullArch, !IO),
> - globals__io_get_globals(Globals, !IO),
> + globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO),
> + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO),
> + globals.io_lookup_string_option(fullarch, FullArch, !IO),
> + globals.io_get_globals(Globals, !IO),
> ( UseSubdirs = yes ->
> ( UseGradeSubdirs = yes ->
> grade_directory_component(Globals, Grade),
> @@ -720,7 +720,7 @@
> ),
> % javac won't create the destination directory for
> % class files, so we need to do it.
> - dir__make_directory(DirName, _, !IO),
> + dir.make_directory(DirName, _, !IO),
> % Set destination directory for class files.
> DestDir = "-d " ++ DirName ++ " "
> ;
> @@ -729,7 +729,7 @@
>
> % Be careful with the order here! Some options may override others.
> % Also be careful that each option is separated by spaces.
> - string__append_list([JavaCompiler, " ", InclOpt, DestDir,
> + string.append_list([JavaCompiler, " ", InclOpt, DestDir,
> Target_DebugOpt, JAVAFLAGS, " ", JavaFile], Command),
> invoke_system_command(ErrorStream, verbose_commands, Command,
> Succeeded, !IO).
> @@ -746,7 +746,7 @@
> PIC = link_with_pic,
> % `--target asm' doesn't support any grades for
> % which `.lpic_o' files are needed.
> - error("compile_target_code__assemble: link_with_pic")
> + error("compile_target_code.assemble: link_with_pic")
> ;
> PIC = non_pic,
> AsmExt = ".s",
> @@ -757,20 +757,20 @@
> maybe_pic_object_file_extension(PIC, ObjExt, !IO),
> module_name_to_file_name(ModuleName, ObjExt, yes, ObjFile, !IO),
>
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> maybe_write_string(Verbose, "% Assembling `", !IO),
> maybe_write_string(Verbose, AsmFile, !IO),
> maybe_write_string(Verbose, "':\n", !IO),
> % XXX should we use new asm_* options rather than
> % reusing cc, cflags, c_flag_to_name_object_file?
> - globals__io_lookup_string_option(cc, CC, !IO),
> - globals__io_lookup_string_option(c_flag_to_name_object_file,
> + globals.io_lookup_string_option(cc, CC, !IO),
> + globals.io_lookup_string_option(c_flag_to_name_object_file,
> NameObjectFile, !IO),
> - globals__io_lookup_accumulating_option(cflags, C_Flags_List, !IO),
> + globals.io_lookup_accumulating_option(cflags, C_Flags_List, !IO),
> join_string_list(C_Flags_List, "", "", " ", CFLAGS),
> % Be careful with the order here.
> % Also be careful that each option is separated by spaces.
> - string__append_list([CC, " ", CFLAGS, " ", GCCFLAGS_FOR_PIC,
> + string.append_list([CC, " ", CFLAGS, " ", GCCFLAGS_FOR_PIC,
> GCCFLAGS_FOR_ASM, "-c ", AsmFile, " ",
> NameObjectFile, ObjFile], Command),
> invoke_system_command(ErrorStream, verbose_commands, Command,
> @@ -781,13 +781,13 @@
> make_init_file(ErrorStream, MainModuleName, AllModules, Succeeded, !IO) :-
> module_name_to_file_name(MainModuleName, ".init.tmp",
> yes, TmpInitFileName, !IO),
> - io__open_output(TmpInitFileName, InitFileRes, !IO),
> + io.open_output(TmpInitFileName, InitFileRes, !IO),
> (
> InitFileRes = ok(InitFileStream),
> - globals__io_lookup_bool_option(aditi, Aditi, !IO),
> - list__foldl(make_init_file_aditi(InitFileStream, Aditi),
> + globals.io_lookup_bool_option(aditi, Aditi, !IO),
> + list.foldl(make_init_file_aditi(InitFileStream, Aditi),
> AllModules, !IO),
> - globals__io_lookup_maybe_string_option(extra_init_command,
> + globals.io_lookup_maybe_string_option(extra_init_command,
> MaybeInitFileCommand, !IO),
> (
> MaybeInitFileCommand = yes(InitFileCommand),
> @@ -801,38 +801,38 @@
> Succeeded0 = yes
> ),
>
> - io__close_output(InitFileStream, !IO),
> + io.close_output(InitFileStream, !IO),
> module_name_to_file_name(MainModuleName, ".init",
> yes, InitFileName, !IO),
> update_interface(InitFileName, Succeeded1, !IO),
> Succeeded = Succeeded0 `and` Succeeded1
> ;
> InitFileRes = error(Error),
> - io__progname_base("mercury_compile", ProgName, !IO),
> - io__write_string(ErrorStream, ProgName, !IO),
> - io__write_string(ErrorStream, ": can't open `", !IO),
> - io__write_string(ErrorStream, TmpInitFileName, !IO),
> - io__write_string(ErrorStream, "' for output:\n", !IO),
> - io__nl(ErrorStream, !IO),
> - io__write_string(ErrorStream, io__error_message(Error), !IO),
> - io__nl(ErrorStream, !IO),
> + io.progname_base("mercury_compile", ProgName, !IO),
> + io.write_string(ErrorStream, ProgName, !IO),
> + io.write_string(ErrorStream, ": can't open `", !IO),
> + io.write_string(ErrorStream, TmpInitFileName, !IO),
> + io.write_string(ErrorStream, "' for output:\n", !IO),
> + io.nl(ErrorStream, !IO),
> + io.write_string(ErrorStream, io.error_message(Error), !IO),
> + io.nl(ErrorStream, !IO),
> Succeeded = no
> ).
>
> -:- pred make_init_file_aditi(io__output_stream::in, bool::in, module_name::in,
> +:- pred make_init_file_aditi(io.output_stream::in, bool::in, module_name::in,
> io::di, io::uo) is det.
>
> make_init_file_aditi(InitFileStream, Aditi, ModuleName, !IO) :-
> InitFuncName0 = make_init_name(ModuleName),
> InitFuncName = InitFuncName0 ++ "init",
> - io__write_string(InitFileStream, "INIT ", !IO),
> - io__write_string(InitFileStream, InitFuncName, !IO),
> - io__nl(InitFileStream, !IO),
> + io.write_string(InitFileStream, "INIT ", !IO),
> + io.write_string(InitFileStream, InitFuncName, !IO),
> + io.nl(InitFileStream, !IO),
> ( Aditi = yes ->
> RLName = make_rl_data_name(ModuleName),
> - io__write_string(InitFileStream, "ADITI_DATA ", !IO),
> - io__write_string(InitFileStream, RLName, !IO),
> - io__nl(InitFileStream, !IO)
> + io.write_string(InitFileStream, "ADITI_DATA ", !IO),
> + io.write_string(InitFileStream, RLName, !IO),
> + io.nl(InitFileStream, !IO)
> ;
> true
> ).
> @@ -840,7 +840,7 @@
> %-----------------------------------------------------------------------------%
>
> link_module_list(Modules, FactTableObjFiles, Succeeded, !IO) :-
> - globals__io_lookup_string_option(output_file_name, OutputFileName0,
> + globals.io_lookup_string_option(output_file_name, OutputFileName0,
> !IO),
> ( OutputFileName0 = "" ->
> ( Modules = [Module | _] ->
> @@ -854,16 +854,16 @@
>
> file_name_to_module_name(OutputFileName, MainModuleName),
>
> - globals__io_lookup_bool_option(compile_to_shared_lib,
> + globals.io_lookup_bool_option(compile_to_shared_lib,
> CompileToSharedLib, !IO),
> TargetType =
> (CompileToSharedLib = yes -> shared_library ; executable),
> get_object_code_type(TargetType, PIC, !IO),
> maybe_pic_object_file_extension(PIC, Obj, !IO),
>
> - globals__io_get_target(Target, !IO),
> - globals__io_lookup_bool_option(split_c_files, SplitFiles, !IO),
> - io__output_stream(OutputStream, !IO),
> + globals.io_get_target(Target, !IO),
> + globals.io_lookup_bool_option(split_c_files, SplitFiles, !IO),
> + io.output_stream(OutputStream, !IO),
> ( Target = asm ->
> % for --target asm, we generate everything into
> % a single object file
> @@ -874,11 +874,11 @@
> ),
> MakeLibCmdOK = yes
> ; SplitFiles = yes ->
> - globals__io_lookup_string_option(library_extension, LibExt,
> + globals.io_lookup_string_option(library_extension, LibExt,
> !IO),
> module_name_to_file_name(MainModuleName, LibExt, yes,
> SplitLibFileName, !IO),
> - string__append(".dir/*", Obj, DirObj),
> + string.append(".dir/*", Obj, DirObj),
> join_module_list(Modules, DirObj, ObjectList, !IO),
> create_archive(OutputStream, SplitLibFileName, no,
> ObjectList, MakeLibCmdOK, !IO),
> @@ -891,10 +891,10 @@
> Succeeded = no
> ;
> ( TargetType = executable ->
> - list__map(
> + list.map(
> (pred(ModuleStr::in, ModuleName::out) is det :-
> file_name_to_module_name(
> - dir__basename_det(ModuleStr),
> + dir.basename_det(ModuleStr),
> ModuleName)
> ), Modules, ModuleNames),
> MustCompile = yes,
> @@ -906,7 +906,7 @@
> ),
> (
> InitObjResult = yes(InitObjFileName),
> - globals__io_lookup_accumulating_option(link_objects,
> + globals.io_lookup_accumulating_option(link_objects,
> ExtraLinkObjectsList, !IO),
> AllObjects0 = ObjectsList ++ ExtraLinkObjectsList
> ++ FactTableObjFiles,
> @@ -925,25 +925,25 @@
> ).
>
> make_init_obj_file(ErrorStream, ModuleName, ModuleNames, Result, !IO) :-
> - globals__io_lookup_bool_option(rebuild, MustCompile, !IO),
> + globals.io_lookup_bool_option(rebuild, MustCompile, !IO),
> make_init_obj_file(ErrorStream,
> MustCompile, ModuleName, ModuleNames, Result, !IO).
>
> % WARNING: The code here duplicates the functionality of scripts/c2init.in.
> % Any changes there may also require changes here, and vice versa.
>
> -:- pred make_init_obj_file(io__output_stream::in, bool::in,
> +:- pred make_init_obj_file(io.output_stream::in, bool::in,
> module_name::in, list(module_name)::in, maybe(file_name)::out,
> io::di, io::uo) is det.
>
> make_init_obj_file(ErrorStream, MustCompile, ModuleName, ModuleNames, Result,
> !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> - globals__io_lookup_bool_option(statistics, Stats, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(statistics, Stats, !IO),
> maybe_write_string(Verbose, "% Creating initialization file...\n",
> !IO),
>
> - globals__io_get_globals(Globals, !IO),
> + globals.io_get_globals(Globals, !IO),
> compute_grade(Globals, Grade),
>
> get_object_code_type(executable, PIC, !IO),
> @@ -955,23 +955,23 @@
> module_name_to_file_name(ModuleName, InitObj, yes, InitObjFileName,
> !IO),
>
> - list__map_foldl(
> + list.map_foldl(
> (pred(ThisModule::in, CFileName::out, IO0::di, IO::uo) is det :-
> module_name_to_file_name(ThisModule, ".c", no,
> CFileName, IO0, IO)
> ), ModuleNames, CFileNameList, !IO),
> join_quoted_string_list(CFileNameList, "", "", " ", CFileNames),
>
> - globals__io_lookup_accumulating_option(init_file_directories,
> + globals.io_lookup_accumulating_option(init_file_directories,
> InitFileDirsList, !IO),
> join_quoted_string_list(InitFileDirsList, "-I ", "", " ",
> InitFileDirs),
>
> - globals__io_lookup_accumulating_option(init_files, InitFileNamesList0,
> + globals.io_lookup_accumulating_option(init_files, InitFileNamesList0,
> !IO),
> - globals__io_lookup_accumulating_option(trace_init_files,
> + globals.io_lookup_accumulating_option(trace_init_files,
> TraceInitFileNamesList0, !IO),
> - globals__io_lookup_maybe_string_option(
> + globals.io_lookup_maybe_string_option(
> mercury_standard_library_directory, MaybeStdLibDir, !IO),
> (
> MaybeStdLibDir = yes(StdLibDir),
> @@ -988,7 +988,7 @@
> TraceInitFileNamesList = TraceInitFileNamesList0
> ),
>
> - globals__io_get_trace_level(TraceLevel, !IO),
> + globals.io_get_trace_level(TraceLevel, !IO),
> ( given_trace_level_is_none(TraceLevel) = no ->
> TraceOpt = "-t",
> InitFileNamesList =
> @@ -999,24 +999,24 @@
> ),
> join_quoted_string_list(InitFileNamesList, "", "", " ", InitFileNames),
>
> - globals__io_lookup_accumulating_option(runtime_flags, RuntimeFlagsList,
> + globals.io_lookup_accumulating_option(runtime_flags, RuntimeFlagsList,
> !IO),
> join_quoted_string_list(RuntimeFlagsList, "-r ", "", " ",
> RuntimeFlags),
>
> - globals__io_lookup_bool_option(extra_initialization_functions,
> + globals.io_lookup_bool_option(extra_initialization_functions,
> ExtraInits, !IO),
> ExtraInitsOpt = ( ExtraInits = yes -> "-x" ; "" ),
>
> - globals__io_lookup_bool_option(main, Main, !IO),
> + globals.io_lookup_bool_option(main, Main, !IO),
> NoMainOpt = ( Main = no -> "-l" ; "" ),
>
> - globals__io_lookup_bool_option(aditi, Aditi, !IO),
> + globals.io_lookup_bool_option(aditi, Aditi, !IO),
> AditiOpt = ( Aditi = yes -> "-a" ; "" ),
>
> - globals__io_lookup_string_option(mkinit_command, Mkinit, !IO),
> + globals.io_lookup_string_option(mkinit_command, Mkinit, !IO),
> TmpInitCFileName = InitCFileName ++ ".tmp",
> - MkInitCmd = string__append_list(
> + MkInitCmd = string.append_list(
> [Mkinit, " -g ", Grade, " ", TraceOpt, " ", ExtraInitsOpt,
> " ", NoMainOpt, " ", AditiOpt, " ", RuntimeFlags,
> " -o ", quote_arg(TmpInitCFileName), " ", InitFileDirs,
> @@ -1032,9 +1032,9 @@
> Compile = yes
> ;
> MustCompile = no,
> - io__file_modification_time(InitCFileName,
> + io.file_modification_time(InitCFileName,
> InitCModTimeResult, !IO),
> - io__file_modification_time(InitObjFileName,
> + io.file_modification_time(InitObjFileName,
> InitObjModTimeResult, !IO),
> (
> InitObjModTimeResult =
> @@ -1080,14 +1080,14 @@
> % Any changes there may also require changes here, and vice versa.
>
> link(ErrorStream, LinkTargetType, ModuleName, ObjectsList, Succeeded, !IO) :-
> - globals__io_lookup_bool_option(verbose, Verbose, !IO),
> - globals__io_lookup_bool_option(statistics, Stats, !IO),
> + globals.io_lookup_bool_option(verbose, Verbose, !IO),
> + globals.io_lookup_bool_option(statistics, Stats, !IO),
>
> maybe_write_string(Verbose, "% Linking...\n", !IO),
> - globals__io_lookup_string_option(library_extension, LibExt, !IO),
> - globals__io_lookup_string_option(shared_library_extension,
> + globals.io_lookup_string_option(library_extension, LibExt, !IO),
> + globals.io_lookup_string_option(shared_library_extension,
> SharedLibExt, !IO),
> - globals__io_lookup_string_option(executable_file_extension, ExeExt,
> + globals.io_lookup_string_option(executable_file_extension, ExeExt,
> !IO),
> ( LinkTargetType = static_library ->
> Ext = LibExt,
> @@ -1111,14 +1111,14 @@
> ThreadFlagsOpt = shlib_linker_thread_flags,
> DebugFlagsOpt = shlib_linker_debug_flags,
> TraceFlagsOpt = shlib_linker_trace_flags,
> - globals__io_lookup_bool_option(allow_undefined,
> + globals.io_lookup_bool_option(allow_undefined,
> AllowUndef, !IO),
> ( AllowUndef = yes ->
> - globals__io_lookup_string_option(
> + globals.io_lookup_string_option(
> linker_allow_undefined_flag, UndefOpt,
> !IO)
> ;
> - globals__io_lookup_string_option(
> + globals.io_lookup_string_option(
> linker_error_undefined_flag, UndefOpt,
> !IO)
> ),
> @@ -1127,10 +1127,10 @@
> Ext, yes, OutputFileName, !IO)
> ;
> LinkTargetType = static_library,
> - error("compile_target_code__link")
> + error("compile_target_code.link")
> ;
> LinkTargetType = java_archive,
> - error("compile_target_code__link")
> + error("compile_target_code.link")
> ;
> LinkTargetType = executable,
> CommandOpt = link_executable_command,
> @@ -1149,17 +1149,17 @@
> %
> % Should the executable be stripped?
> %
> - globals__io_lookup_bool_option(strip, Strip, !IO),
> + globals.io_lookup_bool_option(strip, Strip, !IO),
> ( LinkTargetType = executable, Strip = yes ->
> - globals__io_lookup_string_option(linker_strip_flag,
> + globals.io_lookup_string_option(linker_strip_flag,
> StripOpt, !IO)
> ;
> StripOpt = ""
> ),
>
> - globals__io_lookup_bool_option(target_debug, TargetDebug, !IO),
> + globals.io_lookup_bool_option(target_debug, TargetDebug, !IO),
> ( TargetDebug = yes ->
> - globals__io_lookup_string_option(DebugFlagsOpt,
> + globals.io_lookup_string_option(DebugFlagsOpt,
> DebugOpts, !IO)
> ;
> DebugOpts = ""
> @@ -1168,9 +1168,9 @@
> %
> % Should the executable be statically linked?
> %
> - globals__io_lookup_string_option(linkage, Linkage, !IO),
> + globals.io_lookup_string_option(linkage, Linkage, !IO),
> ( LinkTargetType = executable, Linkage = "static" ->
> - globals__io_lookup_string_option(linker_static_flags,
> + globals.io_lookup_string_option(linker_static_flags,
> StaticOpts, !IO)
> ;
> StaticOpts = ""
> @@ -1181,7 +1181,7 @@
> %
> use_thread_libs(UseThreadLibs, !IO),
> ( UseThreadLibs = yes ->
> - globals__io_lookup_string_option(ThreadFlagsOpt,
> + globals.io_lookup_string_option(ThreadFlagsOpt,
> ThreadOpts, !IO)
> ;
> ThreadOpts = ""
> @@ -1190,7 +1190,7 @@
> %
> % Find the Mercury standard libraries.
> %
> - globals__io_lookup_maybe_string_option(
> + globals.io_lookup_maybe_string_option(
> mercury_standard_library_directory, MaybeStdLibDir,
> !IO),
> (
> @@ -1208,13 +1208,13 @@
> get_system_libs(LinkTargetType, SystemLibs, !IO),
>
> join_quoted_string_list(ObjectsList, "", "", " ", Objects),
> - globals__io_lookup_accumulating_option(LDFlagsOpt,
> + globals.io_lookup_accumulating_option(LDFlagsOpt,
> LDFlagsList, !IO),
> join_string_list(LDFlagsList, "", "", " ", LDFlags),
> - globals__io_lookup_accumulating_option(
> + globals.io_lookup_accumulating_option(
> link_library_directories,
> LinkLibraryDirectoriesList, !IO),
> - globals__io_lookup_string_option(linker_path_flag,
> + globals.io_lookup_string_option(linker_path_flag,
> LinkerPathFlag, !IO),
> join_quoted_string_list(LinkLibraryDirectoriesList,
> LinkerPathFlag, "", " ", LinkLibraryDirectories),
> @@ -1222,35 +1222,51 @@
> %
> % Set up the runtime library path.
> %
> + globals.io_lookup_bool_option(shlib_linker_use_install_name,
> + UseInstallName, !IO),
> (
> + UseInstallName = no,
> SharedLibExt \= LibExt,
> ( Linkage = "shared"
> ; LinkTargetType = shared_library
> )
> ->
> - globals__io_lookup_accumulating_option(
> + globals.io_lookup_accumulating_option(
> runtime_link_library_directories,
> RpathDirs, !IO),
> ( RpathDirs = [] ->
> RpathOpts = ""
> ;
> - globals__io_lookup_string_option(RpathSepOpt,
> - RpathSep, !IO),
> - globals__io_lookup_string_option(RpathFlagOpt,
> - RpathFlag, !IO),
> - RpathOpts0 = string__join_list(RpathSep,
> - RpathDirs),
> + globals.io_lookup_string_option(
> + RpathSepOpt, RpathSep, !IO),
> + globals.io_lookup_string_option(
> + RpathFlagOpt, RpathFlag, !IO),
> + RpathOpts0 = string.join_list(
> + RpathSep, RpathDirs),
> RpathOpts = RpathFlag ++ RpathOpts0
> )
> ;
> RpathOpts = ""
> ),
> +
> + %
> + % Set up the installed name for shared libraries.
> + %
> + (
> + UseInstallName = yes,
> + LinkTargetType = shared_library
> + ->
> + get_install_name_option(OutputFileName, InstallNameOpt,
> + !IO)
> + ;
> + InstallNameOpt = ""
> + ),
>
> - globals__io_get_trace_level(TraceLevel, !IO),
> + globals.io_get_trace_level(TraceLevel, !IO),
> ( given_trace_level_is_none(TraceLevel) = yes ->
> TraceOpts = ""
> ;
> - globals__io_lookup_string_option(TraceFlagsOpt,
> + globals.io_lookup_string_option(TraceFlagsOpt,
> TraceOpts, !IO)
> ),
>
> @@ -1259,21 +1275,21 @@
> % depending on whether we are linking with static or shared
> % Mercury libraries.
> %
> - globals__io_lookup_accumulating_option(
> + globals.io_lookup_accumulating_option(
> mercury_library_directories, MercuryLibDirs0, !IO),
> - globals__io_lookup_string_option(fullarch, FullArch, !IO),
> - globals__io_get_globals(Globals, !IO),
> + globals.io_lookup_string_option(fullarch, FullArch, !IO),
> + globals.io_get_globals(Globals, !IO),
> grade_directory_component(Globals, GradeDir),
> - MercuryLibDirs = list__map(
> + MercuryLibDirs = list.map(
> (func(LibDir) = LibDir/"lib"/GradeDir/FullArch),
> MercuryLibDirs0),
> - globals__io_lookup_accumulating_option(link_libraries,
> + globals.io_lookup_accumulating_option(link_libraries,
> LinkLibrariesList0, !IO),
> - list__map_foldl2(process_link_library(MercuryLibDirs),
> + list.map_foldl2(process_link_library(MercuryLibDirs),
> LinkLibrariesList0, LinkLibrariesList, yes,
> LibrariesSucceeded, !IO),
>
> - globals__io_lookup_string_option(linker_opt_separator,
> + globals.io_lookup_string_option(linker_opt_separator,
> LinkOptSep, !IO),
> (
> LibrariesSucceeded = yes,
> @@ -1282,23 +1298,23 @@
>
> % Note that LDFlags may contain `-l' options
> % so it should come after Objects.
> - globals__io_lookup_string_option(CommandOpt, Command,
> + globals.io_lookup_string_option(CommandOpt, Command,
> !IO),
> - string__append_list(
> + string.append_list(
> [Command, " ",
> StaticOpts, " ", StripOpt, " ", UndefOpt, " ",
> ThreadOpts, " ", TraceOpts, " ",
> " -o ", OutputFileName, " ", Objects, " ",
> LinkOptSep, " ", LinkLibraryDirectories, " ",
> - RpathOpts, " ", DebugOpts, " ", LDFlags, " ",
> - LinkLibraries, " ", MercuryStdLibs, " ",
> - SystemLibs],
> + RpathOpts, " ", InstallNameOpt, " ", DebugOpts,
> + " ", LDFlags, " ", LinkLibraries, " ",
> + MercuryStdLibs, " ", SystemLibs],
> LinkCmd),
>
> - globals__io_lookup_bool_option(demangle, Demangle,
> + globals.io_lookup_bool_option(demangle, Demangle,
> !IO),
> ( Demangle = yes ->
> - globals__io_lookup_string_option(
> + globals.io_lookup_string_option(
> demangle_command, DemamngleCmd, !IO),
> MaybeDemangleCmd = yes(DemamngleCmd)
> ;
> @@ -1313,15 +1329,15 @@
> )
> ),
> maybe_report_stats(Stats, !IO),
> - globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs,
> + globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs,
> !IO),
> (
> LinkSucceeded = yes,
> UseGradeSubdirs = yes
> ->
> % Link/copy the executable into the user's directory.
> - globals__io_set_option(use_subdirs, bool(no), !IO),
> - globals__io_set_option(use_grade_subdirs, bool(no), !IO),
> + globals.io_set_option(use_subdirs, bool(no), !IO),
> + globals.io_set_option(use_grade_subdirs, bool(no), !IO),
> ( LinkTargetType = executable ->
> module_name_to_file_name(ModuleName, Ext,
> no, UserDirFileName, !IO)
> @@ -1329,13 +1345,13 @@
> module_name_to_lib_file_name("lib", ModuleName, Ext,
> no, UserDirFileName, !IO)
> ),
> - globals__io_set_option(use_subdirs, bool(yes), !IO),
> - globals__io_set_option(use_grade_subdirs, bool(yes), !IO),
> + globals.io_set_option(use_subdirs, bool(yes), !IO),
> + globals.io_set_option(use_grade_subdirs, bool(yes), !IO),
>
> - io__set_output_stream(ErrorStream, OutputStream, !IO),
> + io.set_output_stream(ErrorStream, OutputStream, !IO),
> make_symlink_or_copy_file(OutputFileName, UserDirFileName,
> Succeeded, !IO),
> - io__set_output_stream(OutputStream, _, !IO)
> + io.set_output_stream(OutputStream, _, !IO)
> ;
> Succeeded = LinkSucceeded
> ).
> @@ -1346,10 +1362,10 @@
> io::di, io::uo) is det.
>
> get_mercury_std_libs(TargetType, StdLibDir, StdLibs, !IO) :-
> - globals__io_lookup_string_option(fullarch, FullArch, !IO),
> - globals__io_get_gc_method(GCMethod, !IO),
> - globals__io_lookup_string_option(library_extension, LibExt, !IO),
> - globals__io_get_globals(Globals, !IO),
> + globals.io_lookup_string_option(fullarch, FullArch, !IO),
> + globals.io_get_gc_method(GCMethod, !IO),
> + globals.io_lookup_string_option(library_extension, LibExt, !IO),
> + globals.io_get_globals(Globals, !IO),
> grade_directory_component(Globals, GradeDir),
>
> %
> @@ -1365,14 +1381,14 @@
> SharedGCLibs = ""
> ;
> GCMethod = boehm,
> - globals__io_lookup_bool_option(profile_time, ProfTime, !IO),
> - globals__io_lookup_bool_option(profile_deep, ProfDeep, !IO),
> + globals.io_lookup_bool_option(profile_time, ProfTime, !IO),
> + globals.io_lookup_bool_option(profile_deep, ProfDeep, !IO),
> ( ( ProfTime = yes ; ProfDeep = yes ) ->
> GCGrade0 = "gc_prof"
> ;
> GCGrade0 = "gc"
> ),
> - globals__io_lookup_bool_option(parallel, Parallel, !IO),
> + globals.io_lookup_bool_option(parallel, Parallel, !IO),
> ( Parallel = yes ->
> GCGrade = "par_" ++ GCGrade0
> ;
> @@ -1395,7 +1411,7 @@
> %
> % Trace libraries.
> %
> - globals__io_get_trace_level(TraceLevel, !IO),
> + globals.io_get_trace_level(TraceLevel, !IO),
> ( given_trace_level_is_none(TraceLevel) = yes ->
> StaticTraceLibs = "",
> SharedTraceLibs = ""
> @@ -1412,13 +1428,13 @@
> make_link_lib(TargetType, "mer_trace", TraceLib, !IO),
> make_link_lib(TargetType, "mer_browser", BrowserLib, !IO),
> make_link_lib(TargetType, "mer_mdbcomp", MdbCompLib, !IO),
> - SharedTraceLibs = string__join_list(" ",
> + SharedTraceLibs = string.join_list(" ",
> [TraceLib, BrowserLib, MdbCompLib])
> ),
>
> - globals__io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO),
> + globals.io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO),
> ( MercuryLinkage = "static" ->
> - StdLibs = string__join_list(" ",
> + StdLibs = string.join_list(" ",
> [StaticTraceLibs,
> quote_arg(StdLibDir/"lib"/GradeDir/FullArch/
> ("libmer_std" ++ LibExt)),
> @@ -1428,7 +1444,7 @@
> ; MercuryLinkage = "shared" ->
> make_link_lib(TargetType, "mer_std", StdLib, !IO),
> make_link_lib(TargetType, "mer_rt", RuntimeLib, !IO),
> - StdLibs = string__join_list(" ",
> + StdLibs = string.join_list(" ",
> [SharedTraceLibs, StdLib, RuntimeLib, SharedGCLibs])
> ;
> error("unknown linkage " ++ MercuryLinkage)
> @@ -1453,8 +1469,8 @@
> TargetType = static_library,
> error("make_link_lib: static_library")
> ),
> - globals__io_lookup_string_option(LinkLibFlag, LinkLibOpt, !IO),
> - globals__io_lookup_string_option(LinkLibSuffix, Suffix, !IO),
> + globals.io_lookup_string_option(LinkLibFlag, LinkLibOpt, !IO),
> + globals.io_lookup_string_option(LinkLibSuffix, Suffix, !IO),
> LinkOpt = quote_arg(LinkLibOpt ++ LibName ++ Suffix).
>
> :- pred get_system_libs(linked_target_type::in, string::out, io::di, io::uo)
> @@ -1464,15 +1480,15 @@
> %
> % System libraries used when tracing.
> %
> - globals__io_get_trace_level(TraceLevel, !IO),
> + globals.io_get_trace_level(TraceLevel, !IO),
> ( given_trace_level_is_none(TraceLevel) = yes ->
> SystemTraceLibs = ""
> ;
> - globals__io_lookup_string_option(trace_libs, SystemTraceLibs0,
> + globals.io_lookup_string_option(trace_libs, SystemTraceLibs0,
> !IO),
> - globals__io_lookup_bool_option(use_readline, UseReadline, !IO),
> + globals.io_lookup_bool_option(use_readline, UseReadline, !IO),
> ( UseReadline = yes ->
> - globals__io_lookup_string_option(readline_libs,
> + globals.io_lookup_string_option(readline_libs,
> ReadlineLibs, !IO),
> SystemTraceLibs =
> SystemTraceLibs0 ++ " " ++ ReadlineLibs
> @@ -1486,7 +1502,7 @@
> %
> use_thread_libs(UseThreadLibs, !IO),
> ( UseThreadLibs = yes ->
> - globals__io_lookup_string_option(thread_libs, ThreadLibs, !IO)
> + globals.io_lookup_string_option(thread_libs, ThreadLibs, !IO)
> ;
> ThreadLibs = ""
> ),
> @@ -1496,28 +1512,28 @@
> %
> (
> TargetType = shared_library,
> - globals__io_lookup_string_option(shared_libs, OtherSystemLibs,
> + globals.io_lookup_string_option(shared_libs, OtherSystemLibs,
> !IO)
> ;
> TargetType = static_library,
> - error("compile_target_code__get_std_libs: static library")
> + error("compile_target_code.get_std_libs: static library")
> ;
> TargetType = java_archive,
> - error("compile_target_code__get_std_libs: java archive")
> + error("compile_target_code.get_std_libs: java archive")
> ;
> TargetType = executable,
> - globals__io_lookup_string_option(math_lib, OtherSystemLibs,
> + globals.io_lookup_string_option(math_lib, OtherSystemLibs,
> !IO)
> ),
>
> - SystemLibs = string__join_list(" ",
> + SystemLibs = string.join_list(" ",
> [SystemTraceLibs, OtherSystemLibs, ThreadLibs]).
>
> :- pred use_thread_libs(bool::out, io::di, io::uo) is det.
>
> use_thread_libs(UseThreadLibs, !IO) :-
> - globals__io_lookup_bool_option(parallel, Parallel, !IO),
> - globals__io_get_gc_method(GCMethod, !IO),
> + globals.io_lookup_bool_option(parallel, Parallel, !IO),
> + globals.io_get_gc_method(GCMethod, !IO),
> UseThreadLibs = ( ( Parallel = yes ; GCMethod = mps ) -> yes ; no ).
>
> %-----------------------------------------------------------------------------%
> @@ -1526,37 +1542,37 @@
> bool::in, bool::out, io::di, io::uo) is det.
>
> process_link_library(MercuryLibDirs, LibName, LinkerOpt, !Succeeded, !IO) :-
> - globals__io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO),
> - globals__io_lookup_accumulating_option(mercury_libraries, MercuryLibs,
> + globals.io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO),
> + globals.io_lookup_accumulating_option(mercury_libraries, MercuryLibs,
> !IO),
> (
> MercuryLinkage = "static",
> - list__member(LibName, MercuryLibs)
> + list.member(LibName, MercuryLibs)
> ->
> % If we are linking statically with Mercury libraries,
> % pass the absolute pathname of the `.a' file for
> % the library.
> - globals__io_lookup_bool_option(use_grade_subdirs,
> + globals.io_lookup_bool_option(use_grade_subdirs,
> UseGradeSubdirs, !IO),
>
> file_name_to_module_name(LibName, LibModuleName),
> - globals__io_lookup_string_option(library_extension, LibExt,
> + globals.io_lookup_string_option(library_extension, LibExt,
> !IO),
>
> - globals__io_set_option(use_grade_subdirs, bool(no), !IO),
> + globals.io_set_option(use_grade_subdirs, bool(no), !IO),
> module_name_to_lib_file_name("lib", LibModuleName, LibExt,
> no, LibFileName, !IO),
> - globals__io_set_option(use_grade_subdirs,
> + globals.io_set_option(use_grade_subdirs,
> bool(UseGradeSubdirs), !IO),
>
> - io__input_stream(InputStream, !IO),
> + io.input_stream(InputStream, !IO),
> search_for_file_returning_dir(MercuryLibDirs, LibFileName,
> SearchResult, !IO),
> (
> SearchResult = ok(DirName),
> LinkerOpt = DirName/LibFileName,
> - io__set_input_stream(InputStream, LibInputStream, !IO),
> - io__close_input(LibInputStream, !IO)
> + io.set_input_stream(InputStream, LibInputStream, !IO),
> + io.close_input(LibInputStream, !IO)
> ;
> SearchResult = error(Error),
> LinkerOpt = "",
> @@ -1568,17 +1584,17 @@
> LinkerOpt = "-l" ++ LibName
> ).
>
> -:- pred create_archive(io__output_stream::in, file_name::in, bool::in,
> +:- pred create_archive(io.output_stream::in, file_name::in, bool::in,
> list(file_name)::in, bool::out, io::di, io::uo) is det.
>
> create_archive(ErrorStream, LibFileName, Quote, ObjectList, Succeeded, !IO) :-
> - globals__io_lookup_string_option(create_archive_command, ArCmd, !IO),
> - globals__io_lookup_accumulating_option(
> + globals.io_lookup_string_option(create_archive_command, ArCmd, !IO),
> + globals.io_lookup_accumulating_option(
> create_archive_command_flags, ArFlagsList, !IO),
> join_string_list(ArFlagsList, "", "", " ", ArFlags),
> - globals__io_lookup_string_option(
> + globals.io_lookup_string_option(
> create_archive_command_output_flag, ArOutputFlag, !IO),
> - globals__io_lookup_string_option(ranlib_command, RanLib, !IO),
> + globals.io_lookup_string_option(ranlib_command, RanLib, !IO),
> (
> Quote = yes,
> join_quoted_string_list(ObjectList, "", "", " ", Objects)
> @@ -1589,7 +1605,7 @@
> % Quoting would prevent that.
> join_string_list(ObjectList, "", "", " ", Objects)
> ),
> - MakeLibCmd = string__append_list([
> + MakeLibCmd = string.append_list([
> ArCmd, " ", ArFlags, " ", ArOutputFlag, " ",
> LibFileName, " ", Objects]),
> invoke_system_command(ErrorStream, verbose_commands,
> @@ -1601,12 +1617,12 @@
> ->
> Succeeded = MakeLibCmdSucceeded
> ;
> - RanLibCmd = string__append_list([RanLib, " ", LibFileName]),
> + RanLibCmd = string.append_list([RanLib, " ", LibFileName]),
> invoke_system_command(ErrorStream, verbose_commands,
> RanLibCmd, Succeeded, !IO)
> ).
>
> -:- pred create_java_archive(io__output_stream::in, module_name::in,
> +:- pred create_java_archive(io.output_stream::in, module_name::in,
> file_name::in, list(file_name)::in, bool::out, io::di, io::uo) is det.
>
> create_java_archive(ErrorStream, ModuleName, JarFileName, ObjectList,
> @@ -1617,7 +1633,7 @@
>
> join_quoted_string_list(ObjectList, "", "", " ", Objects),
> list_class_files_for_jar(ModuleName, Objects, ListClassFiles, !IO),
> - Cmd = string__append_list([
> + Cmd = string.append_list([
> Jar, " ", JarCreateFlags, " ", JarFileName, " ", ListClassFiles
> ]),
>
> @@ -1625,16 +1641,16 @@
> !IO).
>
> get_object_code_type(FileType, ObjectCodeType, !IO) :-
> - globals__io_lookup_string_option(pic_object_file_extension, PicObjExt,
> + globals.io_lookup_string_option(pic_object_file_extension, PicObjExt,
> !IO),
> - globals__io_lookup_string_option(link_with_pic_object_file_extension,
> + globals.io_lookup_string_option(link_with_pic_object_file_extension,
> LinkWithPicObjExt, !IO),
> - globals__io_lookup_string_option(object_file_extension, ObjExt, !IO),
> - globals__io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO),
> - globals__io_lookup_bool_option(gcc_global_registers, GCCGlobals, !IO),
> - globals__io_lookup_bool_option(highlevel_code, HighLevelCode, !IO),
> - globals__io_lookup_bool_option(pic, PIC, !IO),
> - globals__io_get_target(Target, !IO),
> + globals.io_lookup_string_option(object_file_extension, ObjExt, !IO),
> + globals.io_lookup_string_option(mercury_linkage, MercuryLinkage, !IO),
> + globals.io_lookup_bool_option(gcc_global_registers, GCCGlobals, !IO),
> + globals.io_lookup_bool_option(highlevel_code, HighLevelCode, !IO),
> + globals.io_lookup_bool_option(pic, PIC, !IO),
> + globals.io_get_target(Target, !IO),
> (
> PIC = yes,
> % We've been explicitly told to use position independent code.
> @@ -1688,9 +1704,9 @@
> :- pred standard_library_directory_option(string::out, io::di, io::uo) is det.
>
> standard_library_directory_option(Opt, !IO) :-
> - globals__io_lookup_maybe_string_option(
> + globals.io_lookup_maybe_string_option(
> mercury_standard_library_directory, MaybeStdLibDir, !IO),
> - globals__io_lookup_maybe_string_option(
> + globals.io_lookup_maybe_string_option(
> mercury_configuration_directory, MaybeConfDir, !IO),
> (
> MaybeStdLibDir = yes(StdLibDir),
> @@ -1721,10 +1737,10 @@
> join_string_list([], _Prefix, _Suffix, _Separator, "").
> join_string_list([String | Strings], Prefix, Suffix, Separator, Result) :-
> ( Strings = [] ->
> - string__append_list([Prefix, String, Suffix], Result)
> + string.append_list([Prefix, String, Suffix], Result)
> ;
> join_string_list(Strings, Prefix, Suffix, Separator, Result0),
> - string__append_list([Prefix, String, Suffix, Separator,
> + string.append_list([Prefix, String, Suffix, Separator,
> Result0], Result)
> ).
>
> @@ -1751,7 +1767,7 @@
>
> join_module_list([], _Extension, [], !IO).
> join_module_list([Module | Modules], Extension, [FileName | Rest], !IO) :-
> - file_name_to_module_name(dir__basename_det(Module), ModuleName),
> + file_name_to_module_name(dir.basename_det(Module), ModuleName),
> module_name_to_file_name(ModuleName, Extension, no, FileName, !IO),
> join_module_list(Modules, Extension, Rest, !IO).
>
> @@ -1760,34 +1776,34 @@
> write_num_split_c_files(ModuleName, NumChunks, Succeeded, !IO) :-
> module_name_to_file_name(ModuleName, ".num_split", yes,
> NumChunksFileName, !IO),
> - io__open_output(NumChunksFileName, Res, !IO),
> + io.open_output(NumChunksFileName, Res, !IO),
> ( Res = ok(OutputStream) ->
> - io__write_int(OutputStream, NumChunks, !IO),
> - io__nl(OutputStream, !IO),
> - io__close_output(OutputStream, !IO),
> + io.write_int(OutputStream, NumChunks, !IO),
> + io.nl(OutputStream, !IO),
> + io.close_output(OutputStream, !IO),
> Succeeded = yes
> ;
> Succeeded = no,
> - io__progname_base("mercury_compile", ProgName, !IO),
> - io__write_string(ProgName, !IO),
> - io__write_string(": can't open `", !IO),
> - io__write_string(NumChunksFileName, !IO),
> - io__write_string("' for output\n", !IO)
> + io.progname_base("mercury_compile", ProgName, !IO),
> + io.write_string(ProgName, !IO),
> + io.write_string(": can't open `", !IO),
> + io.write_string(NumChunksFileName, !IO),
> + io.write_string("' for output\n", !IO)
> ).
>
> read_num_split_c_files(ModuleName, MaybeNumChunks, !IO) :-
> module_name_to_file_name(ModuleName, ".num_split", no,
> NumChunksFileName, !IO),
> - io__open_input(NumChunksFileName, Res, !IO),
> + io.open_input(NumChunksFileName, Res, !IO),
> (
> Res = ok(FileStream),
> - io__read_word(FileStream, MaybeNumChunksString, !IO),
> - io__close_input(FileStream, !IO),
> + io.read_word(FileStream, MaybeNumChunksString, !IO),
> + io.close_input(FileStream, !IO),
> (
> MaybeNumChunksString = ok(NumChunksString),
> (
> - string__to_int(
> - string__from_char_list(NumChunksString),
> + string.to_int(
> + string.from_char_list(NumChunksString),
> NumChunks)
> ->
> MaybeNumChunks = ok(NumChunks)
> @@ -1812,7 +1828,7 @@
> )
> ;
> Res = error(Error),
> - MaybeNumChunks = error(io__error_message(Error))
> + MaybeNumChunks = error(io.error_message(Error))
> ).
>
> remove_split_c_output_files(ModuleName, NumChunks, !IO) :-
> @@ -1823,14 +1839,14 @@
>
> remove_split_c_output_files(ModuleName, ThisChunk, NumChunks, !IO) :-
> ( ThisChunk =< NumChunks ->
> - globals__io_lookup_string_option(object_file_extension, Obj,
> + globals.io_lookup_string_option(object_file_extension, Obj,
> !IO),
> module_name_to_split_c_file_name(ModuleName, ThisChunk,
> ".c", CFileName, !IO),
> module_name_to_split_c_file_name(ModuleName, ThisChunk,
> Obj, ObjFileName, !IO),
> - io__remove_file(CFileName, _, !IO),
> - io__remove_file(ObjFileName, _, !IO),
> + io.remove_file(CFileName, _, !IO),
> + io.remove_file(ObjFileName, _, !IO),
> remove_split_c_output_files(ModuleName, ThisChunk, NumChunks,
> !IO)
> ;
> @@ -1841,15 +1857,15 @@
>
> make_all_module_command(Command0, MainModule, AllModules, Command, !IO) :-
> % Pass the main module first.
> - list__map_foldl(
> + list.map_foldl(
> (pred(Module::in, FileName::out, IO0::di, IO::uo) is det :-
> module_name_to_file_name(Module, ".m", no, FileName,
> IO0, IO)
> ),
> - [MainModule | list__delete_all(AllModules, MainModule)],
> + [MainModule | list.delete_all(AllModules, MainModule)],
> ModuleNameStrings, !IO),
> - Command = string__join_list(" ",
> - list__map(quote_arg, [Command0 | ModuleNameStrings])).
> + Command = string.join_list(" ",
> + list.map(quote_arg, [Command0 | ModuleNameStrings])).
>
> %-----------------------------------------------------------------------------%
>
> @@ -1858,15 +1874,15 @@
> maybe_pic_object_file_extension(Globals::in, PIC::in, Ext::out) :-
> (
> PIC = non_pic,
> - globals__lookup_string_option(Globals,
> + globals.lookup_string_option(Globals,
> object_file_extension, Ext)
> ;
> PIC = pic,
> - globals__lookup_string_option(Globals,
> + globals.lookup_string_option(Globals,
> pic_object_file_extension, Ext)
> ;
> PIC = link_with_pic,
> - globals__lookup_string_option(Globals,
> + globals.lookup_string_option(Globals,
> link_with_pic_object_file_extension, Ext)
> ).
> maybe_pic_object_file_extension(Globals::in, PIC::out, Ext::in) :-
> @@ -1874,17 +1890,17 @@
> % This test must come first -- if the architecture doesn't
> % need special treatment for PIC, we should always return
> % `non_pic'. `mmc --make' depends on this.
> - globals__lookup_string_option(Globals,
> + globals.lookup_string_option(Globals,
> object_file_extension, Ext)
> ->
> PIC = non_pic
> ;
> - globals__lookup_string_option(Globals,
> + globals.lookup_string_option(Globals,
> pic_object_file_extension, Ext)
> ->
> PIC = pic
> ;
> - globals__lookup_string_option(Globals,
> + globals.lookup_string_option(Globals,
> link_with_pic_object_file_extension, Ext)
> ->
> PIC = link_with_pic
> @@ -1893,7 +1909,7 @@
> ).
>
> maybe_pic_object_file_extension(PIC, ObjExt, !IO) :-
> - globals__io_get_globals(Globals, !IO),
> + globals.io_get_globals(Globals, !IO),
> maybe_pic_object_file_extension(Globals, PIC, ObjExt).
>
> %-----------------------------------------------------------------------------%
> Index: compiler/modules.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
> retrieving revision 1.306
> diff -u -r1.306 modules.m
> --- compiler/modules.m 27 Sep 2004 06:43:59 -0000 1.306
> +++ compiler/modules.m 8 Oct 2004 11:03:32 -0000
> @@ -759,6 +759,15 @@
>
> :- pred get_env_classpath(string::out, io::di, io::uo) is det.
>
> + % get_install_name_option(FileName, Option, !IO):
> + % Get the option string for setting the install-name of the
> + % shared library FileName.
> + % This is only used for systems which support the install-name
> + % option for shared libraries (such as Darwin).
> +
> +:- pred get_install_name_option(string::in, string::out, io::di, io::uo)
> + is det.
> +
> %-----------------------------------------------------------------------------%
> %-----------------------------------------------------------------------------%
>
> @@ -956,11 +965,13 @@
> ; Ext = ".a"
> ; Ext = ".$A"
> ; Ext = ".so"
> + ; Ext = ".dylib"
> ; Ext = ".$(EXT_FOR_SHARED_LIB)"
> ; Ext = ".jar"
> ; Ext = ".split.a"
> ; Ext = ".split.$A"
> ; Ext = ".split.so"
> + ; Ext = ".split.dylib"
> ; Ext = ".split.$(EXT_FOR_SHARED_LIB)"
> ; Ext = ".init"
> % mercury_update_interface
> @@ -4756,12 +4767,25 @@
> module_name_to_lib_file_name("lib", ModuleName, "", no, LibTargetName),
> module_name_to_lib_file_name("lib", ModuleName, ".$A", yes,
> LibFileName),
> - module_name_to_lib_file_name("lib", ModuleName, ".so", yes,
> - SharedLibFileName),
> + module_name_to_lib_file_name("lib", ModuleName,
> + ".$(EXT_FOR_SHARED_LIB)", yes, SharedLibFileName),
> module_name_to_lib_file_name("lib", ModuleName,
> ".$(EXT_FOR_SHARED_LIB)", no, MaybeSharedLibFileName),
> module_name_to_file_name(ModuleName, ".jar", no, JarFileName),
>
> + %
> + % Set up the installed name for shared libraries.
> + %
> + globals.io_lookup_bool_option(shlib_linker_use_install_name,
> + UseInstallName),
> + (
> + { UseInstallName = yes }
> + ->
> + get_install_name_option(SharedLibFileName, InstallNameOpt)
> + ;
> + { InstallNameOpt = "" }
> + ),
> +
> { AllInts = [
> "$(", MakeVarName, ".ints) ",
> "$(", MakeVarName, ".int3s) ",
> @@ -4805,7 +4829,8 @@
> "$(", MakeVarName, ".pic_os) ",
> All_MLPicObjsString, " ", All_MLLibsDepString, "\n",
> "\t$(ML) --make-shared-lib $(ALL_GRADEFLAGS) $(ALL_MLFLAGS) ",
> - "-- $(ALL_LD_LIBFLAGS) -o ", SharedLibFileName, " \\\n",
> + "-- ", InstallNameOpt, " $(ALL_LD_LIBFLAGS) -o ",
> + SharedLibFileName, " \\\n",
> "\t\t$(", MakeVarName, ".pic_os) ", All_MLPicObjsString,
> " $(ALL_MLLIBS)\n\n"
> ]),
> @@ -7219,4 +7244,15 @@
> )
> ).
>
> +get_install_name_option(OutputFileName, InstallNameOpt, !IO) :-
> + globals.io_lookup_string_option(
> + shlib_linker_install_name_flag,
> + InstallNameFlag, !IO),
> + globals.io_lookup_string_option(
> + shlib_linker_install_name_path,
> + InstallNamePath, !IO),
> + dir.directory_separator(Slash),
> + InstallNameOpt = InstallNameFlag++InstallNamePath++
> + char_to_string(Slash)++OutputFileName.
> +
> %-----------------------------------------------------------------------------%
> Index: compiler/options.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
> retrieving revision 1.430
> diff -u -r1.430 options.m
> --- compiler/options.m 16 Aug 2004 08:51:10 -0000 1.430
> +++ compiler/options.m 8 Oct 2004 11:03:33 -0000
> @@ -648,6 +648,9 @@
> ; shlib_linker_rpath_separator
> ; linker_allow_undefined_flag
> ; linker_error_undefined_flag
> + ; shlib_linker_use_install_name
> + ; shlib_linker_install_name_flag
> + ; shlib_linker_install_name_path
>
> % Build system options
> ; make
> @@ -1270,7 +1273,10 @@
> shlib_linker_rpath_flag - string("-Wl,-rpath"),
> shlib_linker_rpath_separator - string(" -Wl,-rpath"),
> linker_allow_undefined_flag - string(""),
> - linker_error_undefined_flag - string("-Wl,-no-undefined")
> + linker_error_undefined_flag - string("-Wl,-no-undefined"),
> + shlib_linker_use_install_name - bool(no),
> + shlib_linker_install_name_flag - string("-install_name "),
> + shlib_linker_install_name_path - string(".")
> ]).
> option_defaults_2(build_system_option, [
> % Build System Options
> @@ -1939,6 +1945,9 @@
> long_option("shlib-linker-rpath-separator", shlib_linker_rpath_separator).
> long_option("linker-allow-undefined-flag", linker_allow_undefined_flag).
> long_option("linker-error-undefined-flag", linker_error_undefined_flag).
> +long_option("shlib-linker-use-install-name", shlib_linker_use_install_name).
> +long_option("shlib-linker-install-name-flag", shlib_linker_install_name_flag).
> +long_option("shlib-linker-install-name-path", shlib_linker_install_name_path).
>
> % build system options
> long_option("make", make).
> @@ -3932,6 +3941,11 @@
> "-R <directory>, --runtime-library-directory <directory>",
> "\tAppend <directory> to the list of directories in which",
> "\tto search for shared libraries at runtime.",
> + "--shlib-linker-install-name-path <directory>",
> + "\tSpecify the path where a shared library will be installed.",
> + "\tThis option is useful on systems where the runtime search",
> + "\tpath is obtained from the shared library and not via the",
> + "\t-R option above (such as Mac OS X).",
> "-l <library>, --library <library>",
> "\tLink with the specified library.",
> "--link-object <object-file>",
> @@ -4014,6 +4028,8 @@
> % --shlib-linker-rpath-flag, --shlib-linker-rpath-separator,
> % --linker-allow-undefined-flag and
> % --linker-error-undefined-flag,
> + % --shlib-linker-install-name-flag,
> + % --shlib-linker-use-install-name,
> % options are reserved for use by the `Mercury.config' file;
> % they are deliberately not documented.
> ]).
> Index: doc/user_guide.texi
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
> retrieving revision 1.391
> diff -u -r1.391 user_guide.texi
> --- doc/user_guide.texi 20 Sep 2004 04:50:23 -0000 1.391
> +++ doc/user_guide.texi 8 Oct 2004 11:03:34 -0000
> @@ -6921,6 +6921,16 @@
> Append @var{directory} to the list of directories in which
> to search for shared libraries at runtime.
>
> + at sp 1
> + at item --shlib-linker-install-name-path @var{directory}
> + at findex --shlib-linker-install-name-path
> + at cindex Mac OS X, Darwin, Install name
> +Specify the path where a shared library will be installed.
> +This option is useful on systems where the runtime search
> +path is obtained from the shared library and not via the
> +-R option (such as Mac OS X).
> +
Do I need to pass this option to the compiler myself or
will mmake (or mmc --make) do it for me?
> + at sp 1
> @item -l @var{library}
> @itemx --library @var{library}
> @findex -l
> Index: library/Mmakefile
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
> retrieving revision 1.135
> diff -u -r1.135 Mmakefile
> --- library/Mmakefile 31 May 2004 04:13:00 -0000 1.135
> +++ library/Mmakefile 8 Oct 2004 11:03:35 -0000
> @@ -106,7 +106,8 @@
> MLFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
> -R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
> MCFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
> - -R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
> + -R$(FINAL_INSTALL_MERC_GC_LIB_DIR) \
> + --shlib-linker-install-name-path $(FINAL_INSTALL_MERC_LIB_DIR)
>
> MTAGS = $(SCRIPTS_DIR)/mtags
>
> Index: runtime/Mmakefile
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
> retrieving revision 1.113
> diff -u -r1.113 Mmakefile
> --- runtime/Mmakefile 20 Jul 2004 04:41:20 -0000 1.113
> +++ runtime/Mmakefile 8 Oct 2004 11:03:35 -0000
> @@ -331,6 +331,14 @@
> $(LDFLAGS) $(LDLIBS) $(THREADLIBS) \
> $(SHARED_LIBS)
>
> +# For Darwin we should pass the -install_name option.
> +lib$(RT_LIB_NAME).dylib: $(PIC_OBJS)
> + $(LINK_SHARED_OBJ) $(ERROR_UNDEFINED) \
> + -o lib$(RT_LIB_NAME).dylib $(PIC_OBJS) \
> + -install_name $(FINAL_INSTALL_MERC_LIB_DIR)/lib$(RT_LIB_NAME).dylib \
> + $(LDFLAGS) $(LDLIBS) $(THREADLIBS) \
> + $(SHARED_LIBS)
> +
> endif
> endif
>
> Index: scripts/Mercury.config.bootstrap.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/scripts/Mercury.config.bootstrap.in,v
> retrieving revision 1.4
> diff -u -r1.4 Mercury.config.bootstrap.in
> --- scripts/Mercury.config.bootstrap.in 12 Feb 2004 02:48:17 -0000 1.4
> +++ scripts/Mercury.config.bootstrap.in 8 Oct 2004 11:03:35 -0000
> @@ -91,6 +91,8 @@
> --linker-rpath-separator "@EXE_RPATH_SEP@" \
> --shlib-linker-rpath-flag "@SHLIB_RPATH_OPT@" \
> --shlib-linker-rpath-separator "@SHLIB_RPATH_SEP@" \
> + @SHLIB_USE_INSTALL_NAME@ \
> + --shlib-linker-install-name-flag "@SHLIB_INSTALL_NAME_FLAG@" \
> --linker-allow-undefined-flag "@ALLOW_UNDEFINED@" \
> --linker-error-undefined-flag "@ERROR_UNDEFINED@" \
> --fullarch "@FULLARCH@" \
> Index: scripts/Mercury.config.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/scripts/Mercury.config.in,v
> retrieving revision 1.9
> diff -u -r1.9 Mercury.config.in
> --- scripts/Mercury.config.in 12 Feb 2004 02:48:17 -0000 1.9
> +++ scripts/Mercury.config.in 8 Oct 2004 11:03:35 -0000
> @@ -94,6 +94,8 @@
> --linker-rpath-separator "@EXE_RPATH_SEP@" \
> --shlib-linker-rpath-flag "@SHLIB_RPATH_OPT@" \
> --shlib-linker-rpath-separator "@SHLIB_RPATH_SEP@" \
> + @SHLIB_USE_INSTALL_NAME@ \
> + --shlib-linker-install-name-flag "@SHLIB_INSTALL_NAME_FLAG@" \
> --linker-allow-undefined-flag "@ALLOW_UNDEFINED@" \
> --linker-error-undefined-flag "@ERROR_UNDEFINED@" \
> --fullarch "@FULLARCH@" \
> Index: scripts/mgnuc.in
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
> retrieving revision 1.105
> diff -u -r1.105 mgnuc.in
> --- scripts/mgnuc.in 20 Jul 2004 04:41:31 -0000 1.105
> +++ scripts/mgnuc.in 8 Oct 2004 11:03:35 -0000
> @@ -502,6 +502,11 @@
> ;;
> esac
> ;;
> + *powerpc*apple*darwin*)
> + # This environment variable needs to be set on Darwin so the
> + # executable knows where to find the mercury shared libraries.
> + dyld_LIBRARY_PATH=@LIBDIR@
> + ;;
> esac
>
Shouldn't that be DYLD_LIBRARY_PATH there? This doesn't really
look like the right spot for this. Is it needed by every executable
that uses shared libraries or just the Mercury compiler?
I assume that everything still works on Linux after this change
has been applied? That's all for now.
Cheers,
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list