[commit: ghc] master, wip/rejig-stages: Hadrian: remove unneeded rpaths. (4df7577)

git at git.haskell.org git at git.haskell.org
Fri Mar 15 19:06:31 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branches: master,wip/rejig-stages
Link       : http://ghc.haskell.org/trac/ghc/changeset/4df757729dab0a5be07f111843ed3ca9de6c3771/ghc

>---------------------------------------------------------------

commit 4df757729dab0a5be07f111843ed3ca9de6c3771
Author: David Eichmann <EichmannD at gmail.com>
Date:   Tue Mar 12 17:06:04 2019 +0000

    Hadrian: remove unneeded rpaths.
    
    Issue #12770


>---------------------------------------------------------------

4df757729dab0a5be07f111843ed3ca9de6c3771
 hadrian/src/Settings/Builders/Ghc.hs | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index 76c44ef..92f1e68 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -74,8 +74,15 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
         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
@@ -92,8 +99,10 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
                 [ 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"



More information about the ghc-commits mailing list