[arch-haskell] Dynamic executables and RPATH

Magnus Therning magnus at therning.org
Sat Nov 9 19:44:09 UTC 2013


This patch shows how I propose dealing with Cabal's inability to build
dynamically linked installable executables.

In short:

  - Create links to all DSOs from /usr/lib/ghc-7.6.3/shared.
  - Rewrite rpath of executables to only contain
    /usr/lib/ghc-7.6.3/shared.

Any comments?  (Besides the hard coded ghc version in the path ;-)

/M

~~~~
From 6882788bb3df039c9b17a2eef831698030e9cc02 Mon Sep 17 00:00:00 2001
From: Magnus Therning <magnus at therning.org>
Date: Sat, 9 Nov 2013 20:25:29 +0100
Subject: [PATCH] Deal with Cabal's deficiencies in linking dynamically.

With this change PKGBUILDs of libs create symbolic links to the DSO at
/usr/lib/ghc-7.6.3/shared.  They also modify the rpath of all executables,
replacing the one put in place by Cabal with one of a single entry:
/usr/lib/ghc-7.6.3/shared.

Signed-off-by: Magnus Therning <magnus at therning.org>
---
 src/Util/Translation.hs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/Util/Translation.hs b/src/Util/Translation.hs
index 074d364..3d57b6a 100644
--- a/src/Util/Translation.hs
+++ b/src/Util/Translation.hs
@@ -219,7 +219,17 @@ instance Pretty ArchPkg where
                         text "ln -s \"/usr/share/doc/${pkgname}/html\" \"${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}\"" <$>
                         text "runhaskell Setup copy --destdir=\"${pkgdir}\"" <$>
                         (maybe empty (\ _ -> text "install -D -m644 \"${_licensefile}\" \"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE\"" <$>
-                            text "rm -f \"${pkgdir}/usr/share/doc/${pkgname}/${_licensefile}\"") licenseFile)
+                            text "rm -f \"${pkgdir}/usr/share/doc/${pkgname}/${_licensefile}\"") licenseFile) <$>
+                        empty <$>
+                        text "mkdir ${pkgdir}/usr/lib/ghc-7.6.3/shared" <$>
+                        text "(cd ${pkgdir}/usr/lib/ghc-7.6.3/shared;" <$>
+                        text "    for f in $(find .. -name \\*-ghc7.6.3.so); do" <$>
+                        text "        ln -s $f" <$>
+                        text "    done" <$>
+                        text ")" <$>
+                        text "for f in ${pkgdir}/usr/bin/*; do" <$>
+                        text "    chrpath -r /usr/lib/ghc-7.6.3/shared $f" <$>
+                        text "done"
                         ) <$>
                     char '}'
 
@@ -300,7 +310,7 @@ translate db fa pd = let
         pkgDesc = synopsis pd
         url = if null (homepage pd) then "http://hackage.haskell.org/package/${_hkgname}" else (homepage pd)
         lic = display (license pd)
-        makeDepends = if hasLib then [] else [ghcVersionDep] ++ calcExactDeps db pd
+        makeDepends = if hasLib then ["chrpath"] else [ghcVersionDep] ++ calcExactDeps db pd
         depends = if hasLib then [ghcVersionDep] ++ calcExactDeps db pd else []
         extraLibDepends = maybe [] (extraLibs . libBuildInfo) (library pd)
         install = if hasLib then (apShInstall ap) else Nothing
-- 
1.8.4.2

~~~~

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus

There's a big difference between making something easy to use and
making it productive.
     -- Adam Bosworth
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/arch-haskell/attachments/20131109/ac5d00f1/attachment.sig>


More information about the arch-haskell mailing list