Cabal provides additional runtime library paths to executables it runs
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
When building a Haskell project that uses foreign libraries, Cabal allows one to specify additional _compile-time_ paths that will be passed to the linker to produce libraries and executables. This is particularly convenient when those libraries are bundled as part of the Haskell project as one can use package-relative paths which are resolved by Cabal. In a [recent project](https://github.com/CardanoSolutions/cardano-node/tree/release/8.1.2/cddl) which mixes Haskell and Rust, we have been using a custom `Setup.hs` to compile the Rust library and link it to the Haskell _test_ executable.
However, this does not help when _running_ the executable with `cabal test`: If the library is not installed in a location the system dynamic loader already knows, it won't be found. The usual workaround is to set some environment variable, eg. `LD_LIBRARY_PATH` on linux, or `DYLD_FALLBACK_LIBRARY_PATH` on Mac OS X, but this is of course unwieldy esp. as one needs to set those paths either absolute or relative to the directory from which the executable is run, which in a multi-package project, can be different from the directory one runs the command.
Therefore, it would be great if cabal could provide this information directly to the executable it runs, for example through an `extra-lib-dir` field. The `build-tools-depend` mechanism for tests and benchmarks provides something similar for runtime dependencies which are executable.
Contributor guide
Assessment
This issue has not been assessed yet.