[Haskell-cafe] Haskell plugin dynamic linking issue

Lana Black lanablack at amok.cc
Fri Apr 14 13:55:19 UTC 2017


On 13/04/17 18:42, Albert Y. C. Lai wrote:
> On 2017-04-11 03:20 AM, Lana Black wrote:
>>> cabal configure
>> Resolving dependencies...
>> Configuring cabal-bug-0.1...
>> cabal: Missing dependency on a foreign library:
>> * Missing C library: HSrts-ghc8.0.2
>> This problem can usually be solved by installing the system package that
>> provides this library (you may need the "-dev" version). If the
>> library is
>> already installed but in a non-standard location then you can use the
>> flags
>> --extra-include-dirs= and --extra-lib-dirs= to specify where it is.
>>
>> However, that doesn't prevent cabal build from succeeding, and now I
>> have a shared library linked to RTS.
> 
> [...]
> 
>> However, if I run cabal build without calling cabal configure first, the
>> latter fails and the build process is stopped at that point. This also
>> prevents me from building my project with stack.
> 
> Here is the thing. I cannot reproduce either outcome.

Disregard my previous email. The cause of this issue is that cabal tries
to link a test executable with only libraries specified in extra-libs.
Therefore the test build fails, because RTS isn't linked to base or
ghc-prim.

Now, here's the fun part. Because the test code supplied by cabal has no
actual calls to any library functions, ld may filter out any unused
libraries, which includes RTS in our case. This behaviour is controlled
by --as-needed option and is enabled by default in Ubuntu, which, I
assume, you are using.

In my case, the workaround here would be to enable --as-needed by
default in the system.


More information about the Haskell-Cafe mailing list