Hadrian: remove unneeded rpaths.
authorDavid Eichmann <EichmannD@gmail.com>
Tue, 12 Mar 2019 17:06:04 +0000 (17:06 +0000)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Fri, 15 Mar 2019 14:05:38 +0000 (10:05 -0400)
Issue #12770

hadrian/src/Settings/Builders/Ghc.hs

index 76c44ef..92f1e68 100644 (file)
@@ -74,8 +74,15 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
         dynamic = Dynamic `wayUnit` way
         distPath = libPath' -/- distDir
         originToLibsDir = makeRelativeNoSysLink originPath distPath
         dynamic = Dynamic `wayUnit` way
         distPath = libPath' -/- distDir
         originToLibsDir = makeRelativeNoSysLink originPath distPath
-        rpath | darwin = "@loader_path" -/- originToLibsDir
-              | otherwise = "$ORIGIN" -/- originToLibsDir
+        rpath
+            -- Programs will end up in the bin dir ($ORIGIN) and will link to
+            -- libraries in the lib dir.
+            | isProgram pkg = metaOrigin -/- originToLibsDir
+            -- libraries will all end up in the lib dir, so just use $ORIGIN
+            | otherwise     = metaOrigin
+            where
+                metaOrigin | darwin    = "@loader_path"
+                           | otherwise = "$ORIGIN"
 
         -- TODO: an alternative would be to generalize by linking with extra
         -- bundled libraries, but currently the rts is the only use case. It is
 
         -- TODO: an alternative would be to generalize by linking with extra
         -- bundled libraries, but currently the rts is the only use case. It is
@@ -92,8 +99,10 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
                 [ arg "-dynamic"
                 -- TODO what about windows?
                 , isLibrary pkg ? pure [ "-shared", "-dynload", "deploy" ]
                 [ arg "-dynamic"
                 -- TODO what about windows?
                 , isLibrary pkg ? pure [ "-shared", "-dynload", "deploy" ]
-                , hostSupportsRPaths ? arg ("-optl-Wl,-rpath," ++ rpath)
-                , hostSupportsRPaths ? arg ("-optl-Wl,-rpath,$ORIGIN")
+                , hostSupportsRPaths ? pure
+                    [ "-optl-Wl,-rpath," ++ rpath
+                    , "-optl-Wl,-zorigin"
+                    ]
                 ]
             , arg "-no-auto-link-packages"
             ,      nonHsMainPackage pkg  ? arg "-no-hs-main"
                 ]
             , arg "-no-auto-link-packages"
             ,      nonHsMainPackage pkg  ? arg "-no-hs-main"