[m-rev.] diff: fix mmc --make and shared libraries on darwin
Julien Fischer
juliensf at cs.mu.OZ.AU
Wed Feb 8 04:44:40 AEDT 2006
Estimated hours taken: 3.5
Branches: main
Fix a bug with mmc --make and shared libraries on Darwin. The problem was
that the install_name for the library was being incorrectly set was
compiler/modules.m:
Set the value of the install-name path correctly. If the user doesn't
specify a value then generate one based on the current value of
INSTALL_PREFIX.
compiler/options.m:
Delete the bogus default value for the shlib-linker-install-name-path
option.
compiler/compile_target_code.m:
When linking a shared library on Darwin set the install-name path
correctly, in particular we need to set it to the directory we
are going to install the library in, *not* where the library is
being built.
compiler/make.program_target.m:
Mention that any changes to modules.get_install_name_option need to
be reflected here.
Julien.
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.80
diff -u -r1.80 compile_target_code.m
--- compiler/compile_target_code.m 7 Feb 2006 07:40:24 -0000 1.80
+++ compiler/compile_target_code.m 7 Feb 2006 17:18:07 -0000
@@ -1287,12 +1287,19 @@
RpathOpts = ""
),
- % Set up the installed name for shared libraries.
+ % Set up the install name for shared libraries.
(
UseInstallName = yes,
LinkTargetType = shared_library
- ->
- get_install_name_option(OutputFileName, InstallNameOpt, !IO)
+ ->
+ % NOTE: `ShLibFileName' must *not* be prefixed with a directory.
+ % get_install_name_option will prefix it with the correct
+ % directory which is the one where the library is going to
+ % be installed, *not* where it is going to be built.
+ %
+ sym_name_to_string(ModuleName, BaseFileName),
+ ShLibFileName = "lib" ++ BaseFileName ++ SharedLibExt,
+ get_install_name_option(ShLibFileName, InstallNameOpt, !IO)
;
InstallNameOpt = ""
),
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.40
diff -u -r1.40 make.program_target.m
--- compiler/make.program_target.m 7 Feb 2006 00:06:20 -0000 1.40
+++ compiler/make.program_target.m 7 Feb 2006 17:18:11 -0000
@@ -894,8 +894,11 @@
),
globals__io_set_globals(unsafe_promise_unique(OrigGlobals), !IO).
- % Install the `.a', `.so', `.jar', `.opt' and `.mih' files
- % for the current grade.
+ % Install the `.a', `.so', `.jar', `.opt' and `.mih' files for the current
+ % grade.
+ %
+ % NOTE: changes here may require changes to
+ % modules.get_install_name_option/4.
%
:- pred install_library_grade_files(bool::in, string::in, module_name::in,
list(module_name)::in, bool::out, make_info::in, make_info::out,
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.371
diff -u -r1.371 modules.m
--- compiler/modules.m 7 Feb 2006 00:06:20 -0000 1.371
+++ compiler/modules.m 7 Feb 2006 17:18:37 -0000
@@ -7967,14 +7967,23 @@
%-----------------------------------------------------------------------------%
+% Changes to the following predicate may require similar changes to
+% make.program_target.install_library_grade_files/9.
+
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.
+ globals.io_get_globals(Globals, !IO),
+ globals.lookup_string_option(Globals, shlib_linker_install_name_flag,
+ InstallNameFlag),
+ globals.lookup_string_option(Globals, shlib_linker_install_name_path,
+ InstallNamePath0),
+ ( InstallNamePath0 = "" ->
+ globals.lookup_string_option(Globals, install_prefix, InstallPrefix),
+ grade_directory_component(Globals, GradeDir),
+ InstallNamePath = InstallPrefix / "lib" / "mercury" / "lib" / GradeDir
+ ;
+ InstallNamePath = InstallNamePath0
+ ),
+ InstallNameOpt = InstallNameFlag ++ InstallNamePath / OutputFileName.
%-----------------------------------------------------------------------------%
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.495
diff -u -r1.495 options.m
--- compiler/options.m 7 Feb 2006 09:41:33 -0000 1.495
+++ compiler/options.m 7 Feb 2006 17:19:14 -0000
@@ -1453,7 +1453,7 @@
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("$(INSTALL_MERC_LIB_DIR)")
+ shlib_linker_install_name_path - string("")
]).
option_defaults_2(build_system_option, [
% Build System Options
--------------------------------------------------------------------------
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