Make -dynload sysdep mean to embed rpaths in shared libs as well as binaries
authorDuncan Coutts <duncan@well-typed.com>
Tue, 19 May 2009 12:05:33 +0000 (12:05 +0000)
committerDuncan Coutts <duncan@well-typed.com>
Tue, 19 May 2009 12:05:33 +0000 (12:05 +0000)
Previously it only did it for binaries. This was presumably on the
theory that the binary could specify the rpath for all the libs.
However when it is the shared lib that is the final product (ie to
link into a bigger project) then we need the rpaths for the shared
lib to be self-contianed.

compiler/main/DriverPipeline.hs

index 225fc60..c8cf4c9 100644 (file)
@@ -1561,7 +1561,13 @@ linkDynLib dflags o_files dep_packages = do
     let pkgs_no_rts = pkgs
 #endif
     let pkg_lib_paths = collectLibraryPaths pkgs_no_rts
-    let pkg_lib_path_opts = map ("-L"++) pkg_lib_paths
+    let pkg_lib_path_opts = concatMap get_pkg_lib_path_opts pkg_lib_paths
+#ifdef linux_TARGET_OS
+        get_pkg_lib_path_opts l | (dynLibLoader dflags)==SystemDependent && not opt_Static = ["-L" ++ l, "-Wl,-rpath", "-Wl," ++ l]
+                                | otherwise = ["-L" ++ l]
+#else
+        get_pkg_lib_path_opts l = ["-L" ++ l]
+#endif
 
     let lib_paths = libraryPaths dflags
     let lib_path_opts = map ("-L"++) lib_paths