Hadrian: Fix rpath so shared objects work after being copied
authorMatthew Pickering <matthewtpickering@gmail.com>
Sun, 10 Mar 2019 17:37:48 +0000 (17:37 +0000)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Tue, 12 Mar 2019 13:04:52 +0000 (09:04 -0400)
After being copied all the shared objects end up in the same directory.
Therefore the correct rpath is `$ORIGIN` rather than the computed
path which is relative to the directory where it is built.

hadrian/src/Settings/Builders/Ghc.hs

index 7fb3082..0d0d58a 100644 (file)
@@ -82,8 +82,8 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
                 [ arg "-dynamic"
                 -- TODO what about windows?
                 , isLibrary pkg ? pure [ "-shared", "-dynload", "deploy" ]
-                , notStage0 ?
-                  hostSupportsRPaths ? arg ("-optl-Wl,-rpath," ++ rpath)
+                , hostSupportsRPaths ? arg ("-optl-Wl,-rpath," ++ rpath)
+                , hostSupportsRPaths ? arg ("-optl-Wl,-rpath,$ORIGIN")
                 ]
             , arg "-no-auto-link-packages"
             ,      nonHsMainPackage pkg  ? arg "-no-hs-main"