[m-rev.] for review: Do not set rpath for --mercury-linkage static.

Peter Wang novalazy at gmail.com
Thu Mar 31 17:50:32 AEDT 2016


When linking to static Mercury libraries, there is no need to set the
runtime search path to find said libraries, so don't.

compiler/handle_options.m:
	As above.

NEWS:
	Mention the new behaviour.
---
 NEWS                      |  3 +++
 compiler/handle_options.m | 25 +++++++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index ca54e01..4ab9d6c 100644
--- a/NEWS
+++ b/NEWS
@@ -322,6 +322,9 @@ Changes to the Mercury compiler:
 * The -generate-module-order and --imports-graph options no longer imply
   --generate-dependencies.
 
+* The compiler does not set the runtime search path when
+  --mercury-linkage=static is used.
+
 Change to the Mercury debugger:
 
 * Interactive queries are now supported on OS X.
diff --git a/compiler/handle_options.m b/compiler/handle_options.m
index 3793e98..a02b7dc 100644
--- a/compiler/handle_options.m
+++ b/compiler/handle_options.m
@@ -1909,6 +1909,7 @@ convert_options_to_globals(OptionTable0, OpMode, Target,
     ),
 
     globals.lookup_string_option(!.Globals, target_arch, TargetArch),
+    globals.lookup_string_option(!.Globals, mercury_linkage, MercuryLinkage),
 
     % Add the standard library directory.
     globals.lookup_maybe_string_option(!.Globals,
@@ -1926,10 +1927,14 @@ convert_options_to_globals(OptionTable0, OpMode, Target,
         globals.set_option(link_library_directories,
             accumulating([StdLibDir/"lib" | LinkLibDirs0]), !Globals),
 
-        globals.lookup_accumulating_option(!.Globals,
-            runtime_link_library_directories, Rpath0),
-        globals.set_option(runtime_link_library_directories,
-            accumulating([StdLibDir/"lib" | Rpath0]), !Globals)
+        ( if MercuryLinkage = "shared" then
+            globals.lookup_accumulating_option(!.Globals,
+                runtime_link_library_directories, Rpath0),
+            globals.set_option(runtime_link_library_directories,
+                accumulating([StdLibDir/"lib" | Rpath0]), !Globals)
+        else
+            true
+        )
     ;
         MaybeStdLibDir = no
     ),
@@ -1982,10 +1987,14 @@ convert_options_to_globals(OptionTable0, OpMode, Target,
         globals.set_option(link_library_directories,
             accumulating(LinkLibDirs1 ++ ExtraLinkLibDirs), !Globals),
 
-        globals.lookup_accumulating_option(!.Globals,
-            runtime_link_library_directories, Rpath),
-        globals.set_option(runtime_link_library_directories,
-            accumulating(Rpath ++ ExtraLinkLibDirs), !Globals),
+        ( if MercuryLinkage = "shared" then
+            globals.lookup_accumulating_option(!.Globals,
+                runtime_link_library_directories, Rpath),
+            globals.set_option(runtime_link_library_directories,
+                accumulating(Rpath ++ ExtraLinkLibDirs), !Globals)
+        else
+            true
+        ),
 
         ExtraIncludeDirs = list.map(
             ( func(MercuryLibDir) =
-- 
2.6.4



More information about the reviews mailing list