[Haskell-cafe] Cabal bug? (was Re: Cabal: --enable-shared and executables)

Magnus Therning magnus at therning.org
Sun Nov 3 05:46:04 UTC 2013


On Thu, Oct 31, 2013 at 05:16:11PM -0400, Albert Y. C. Lai wrote:
> On 13-10-31 04:26 PM, Magnus Therning wrote:
> >We've had a discussion about DSOs on the arch-haskell mailing list[1]
> >and it made me realise one thing:
> >
> >   --enable-shared will cause the generation of DSOs for libraries, but
> >   it won't cause executables to be dynamically linked
> >
> >Is the only way to cause these executables to be dynamically linked
> >against their dependencies to pass the -dynamic flag to ghc (e.g. via
> >the --ghc-options flag when configuring the package)?
> 
> Have you seen --enable-executable-dynamic? It's there since cabal-install
> 0.14 or earlier. It is also available to Setup.hs since Cabal 1.14 or
> earlier, which came with GHC 7.4.
> 
> Have you done a "cabal install --help | less" lately? Also "cabal configure
> --help | less".

Now I have tried the `--enable-executable-dynamic` flag and have found
one problem with it, it doesn't work that well for packages that have
both executables and a library.

I tried it on pandoc.  Here's what I got:

    % file /usr/bin/pandoc
    % /usr/bin/pandoc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=bb046a49bb820ab4d592d154bd0a5064f40bba5b, stripped

So far so good, but

    % pandoc --help
    pandoc: error while loading shared libraries: libHSpandoc-1.12.1-ghc7.6.3.so: cannot open shared object file: No such file or directory

The DSO is installed though

    % pacman -Ql haskell-pandoc|grep libHSpandoc
    haskell-pandoc /usr/lib/ghc-7.6.3/site-local/pandoc-1.12.1/libHSpandoc-1.12.1-ghc7.6.3.so
    haskell-pandoc /usr/lib/ghc-7.6.3/site-local/pandoc-1.12.1/libHSpandoc-1.12.1.a
    haskell-pandoc /usr/lib/ghc-7.6.3/site-local/pandoc-1.12.1/libHSpandoc-1.12.1_p.a

It just can't be found

    % ldd /usr/bin/pandoc|grep libHSpandoc     
            libHSpandoc-1.12.1-ghc7.6.3.so => not found
            libHSpandoc-types-1.12.3-ghc7.6.3.so => /usr/lib/ghc-7.6.3/site-local/pandoc-types-1.12.3/libHSpandoc-types-1.12.3-ghc7.6.3.so (0x00007f60bf3e1000)

The problem is that RPATH doesn't contain the location where the *installed* pandoc lib ends up, but only the location where the pandoc lib is *built*:

    % readelf -d /usr/bin/pandoc|grep RPATH|head
     0x000000000000000f (RPATH)              Library rpath: [/build/haskell-pandoc/src/pandoc-1.12.1/dist/build:/usr/lib/ghc-7.6.3/site-local/zip-archive-0.1.4:/usr/lib/ghc...

Is there already a way to get Cabal to put in an RPATH such that an *installed*
executable works correctly, or is this a fairly serious bug in Cabal?

/M

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

Some operating systems are called 'user friendly', Linux however is
'expert friendly'.
-------------- 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/haskell-cafe/attachments/20131103/204235b0/attachment.sig>


More information about the Haskell-Cafe mailing list