[m-rev.] for review: fix executable stripping on Mac OS X
Julien Fischer
jfischer at opturion.com
Mon May 5 03:47:01 AEST 2014
Branches: master, 14.01
I'll re-enable executable stripping on Mac OS X after this change has
bootstrapped.
========================
Fix executable stripping on Mac OS X.
Stripping executables on Mac OS X that were built with --mercury-linkage=shared
was resulting in the symbols for the global variables introduced for runtime
trace goal env flags being incorrectly removed. We need to pass the "-x" flag
to strip to prevent this happening. This diff adds the ability to pass
different flags to strip depending on the value of --mercury-linkage.
compiler/options.m:
Add two new options, --strip-executable-{shared,static}-flags, that
specify what flags are passed to the strip command when --mercury-linkage
is set to shared or static respectively.
Add a new option to test that the compiler is sufficiently up-to-date.
compiler/compile_target_code.m:
Implement the new options.
doc/user_guide.texi:
Document the new options.
NEWS:
Adjust the entry for the --strip-executable-command option to mention
the additional two new options.
Julien.
diff --git a/NEWS b/NEWS
index 3f1f9f5..7e371ef 100644
--- a/NEWS
+++ b/NEWS
@@ -15,8 +15,9 @@ This is a bug-fix release.
Changes to the Mercury compiler:
* The compiler now supports stripping of executables in a separate
- post-link step. A new option, --strip-executable-command, is used
- to control this.
+ post-link step. The new options, --strip-executable-command,
+ --strip-executable-shared-flags and --strip-executable-static-flags
+ are used to control this.
(This is now the default on Mac OS X systems.)
diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index 276b9bf..db24324 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -1941,10 +1941,19 @@ link_exe_or_shared_lib(Globals, ErrorStream, LinkTargetType, ModuleName,
globals.lookup_string_option(Globals, linker_strip_flag,
LinkerStripOpt),
globals.lookup_string_option(Globals, strip_executable_command,
- StripExeCommand)
+ StripExeCommand),
+ globals.lookup_string_option(Globals, mercury_linkage,
+ MercuryLinkage),
+ ( MercuryLinkage = "shared" ->
+ StripExeFlagsOpt = strip_executable_shared_flags
+ ;
+ StripExeFlagsOpt = strip_executable_static_flags
+ ),
+ globals.lookup_string_option(Globals, StripExeFlagsOpt, StripExeFlags)
;
LinkerStripOpt = "",
- StripExeCommand = ""
+ StripExeCommand = "",
+ StripExeFlags = ""
),
globals.lookup_bool_option(Globals, target_debug, TargetDebug),
@@ -2135,7 +2144,8 @@ link_exe_or_shared_lib(Globals, ErrorStream, LinkTargetType, ModuleName,
StripExeCommand \= ""
->
string.append_list([
- StripExeCommand, " ", quote_arg(OutputFileName)
+ StripExeCommand, " ", StripExeFlags, " ",
+ quote_arg(OutputFileName)
], StripCmd),
invoke_system_command_maybe_filter_output(Globals, ErrorStream,
cmd_verbose_commands, StripCmd, no, Succeeded, !IO)
diff --git a/compiler/options.m b/compiler/options.m
index 53d3ce3..abe55dc 100644
--- a/compiler/options.m
+++ b/compiler/options.m
@@ -964,6 +964,8 @@
; shlib_linker_install_name_flag
; shlib_linker_install_name_path
; strip_executable_command
+ ; strip_executable_shared_flags
+ ; strip_executable_static_flags
; java_archive_command
% Build system options
@@ -1873,6 +1875,8 @@ option_defaults_2(link_option, [
shlib_linker_install_name_flag - string("-install_name "),
shlib_linker_install_name_path - string(""),
strip_executable_command - string(""),
+ strip_executable_shared_flags - string(""),
+ strip_executable_static_flags - string(""),
java_archive_command - string("jar")
]).
option_defaults_2(build_system_option, [
@@ -2848,6 +2852,8 @@ 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).
long_option("strip-executable-command", strip_executable_command).
+long_option("strip-executable-shared-flags", strip_executable_shared_flags).
+long_option("strip-executable-static-flags", strip_executable_static_flags).
long_option("java-archive-command", java_archive_command).
% build system options
@@ -2936,6 +2942,8 @@ long_option("store-at-ref-impure-2008-09-11",
long_option("java-export-ref-out", compiler_sufficiently_recent).
long_option("java-generics-2010-04-13",
compiler_sufficiently_recent).
+long_option("strip-executable-2014-05-05",
+ compiler_sufficiently_recent).
long_option("experiment", experiment).
long_option("ignore-par-conjunctions",
ignore_par_conjunctions).
@@ -5657,8 +5665,6 @@ options_help_link -->
"\tAppend <init-file> to the list of `.init' files to",
"\tbe passed to c2init when tracing is enabled.",
- "--no-strip",
- "\tDon't strip executables.",
"--no-demangle",
"\tDon't pipe link errors through the Mercury demangler.",
"--no-main",
@@ -5684,9 +5690,17 @@ options_help_link -->
"\tSpecify the command used to invoke the linker when linking",
"\ta shared library.",
+ "--no-strip",
+ "\tDo not strip executables.",
"--strip-executable-command <command>",
"\tSpecify the command used to strip executables if no linker",
"\tflag to do so is available. This option has no effect on ml.",
+ "--strip-executable-shared-flags <options>",
+ "\tSpecify options to pass to the strip executable command when",
+ "\tlinking against Mercury shared libraries.",
+ "--strip-executable-static-flags <options>",
+ "\tSpecify options to pass to strip executable command when",
+ "\tlinking against Mercury static libraries.",
"--java-archive-command <command>",
"\tSpecify the command used to produce Java archive (JAR) files.",
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 6031c1d..05c66f6 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -9652,11 +9652,6 @@ linking an executable with Mercury libraries.
Shared libraries are always linked with @samp{--mercury-linkage shared}.
@sp 1
- at item --no-strip
- at findex --no-strip
-Don't strip executables.
-
- at sp 1
@item --no-demangle
@findex --no-demangle
Don't pipe link errors through the Mercury demangler.
@@ -9704,12 +9699,29 @@ Specify the command used to invoke the linker when linking an executable.
Specify the command used to invoke the linker when linking a shared library.
@sp 1
+ at item --no-strip
+ at findex --no-strip
+Do not strip executables.
+
+ at sp 1
@item --strip-executable-command @var{command}
@findex --strip-executable-command
Specify the command used to strip executables if no linker
flag to do so is available. This option has no effect on @samp{ml}.
@sp 1
+ at item --strip-executable-shared-flags @var{options}
+ at findex --strip-executable-shared-flags
+Specify options to pass to the strip executable command when
+linking against Mercury shared libraries.
+
+ at sp 1
+ at item --stripe-executable-static-flags @var{options}
+ at findex --strip-executable-static-flags
+Specify options to pass to the strip executable command when
+linking against Mercury static libraries.
+
+ at sp 1
@item --java-archive-command @var{command}
@findex --java-archive-command
Specify the command used to produce Java archive (JAR) files.
More information about the reviews
mailing list