commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Bundle library and dependencies in a single .so #2158

Open YPares opened 8 years ago

YPares commented 8 years ago

I have a library which should be linked with a C project. In order to simplify deployment, I'd like to have either one single shared object containing my haskell lib, the RTS and the dependencies, or statically link everything into the C project. I don't think stack can generate that, but for a start is there a way after building to get the list of the paths of every static library my project depends on? I.e a list of everything that would be linked into an executable depending on my library. Something à la stack list-dependencies, but file-oriented.

mgsloan commented 8 years ago

Stack uses invocations of Cabal to do all the building (via a compiled Setup.hs file). So, if stack is to provide this info, we'd need a way for Cabal to provide the info, and I'm not sure if there is a way.

YPares commented 8 years ago

Concerning libraries combination, maybe this discussion can provide pointers: http://stackoverflow.com/questions/1762427/how-to-combine-shared-libraries

AleXoundOS commented 8 years ago

I have a similar issue. I create a shared library that depends on other haskell libraries. I need to link dependencies statically, but get lots of linker errors in this manner: relocation R_X86_64_32S against undefined symbol 'stg_upd_frame_info' can not be used when making a shared object; recompile with -fPIC There exist manual rebuild tips, but it does not make sense in case of using Stack. It's especially annoying like in a project of mine that is simply a plugin for a video player, but I have to ship it with all 20+ haskell libraries as well.

AleXoundOS commented 8 years ago

NixOS also provides some tips for creating a statically linked binary by making use of specific Cabal options: --disable-executable-dynamic and --ghc-option=-optl=-static --ghc-option=-optl=-pthread. Can Stack make use of such Cabal facility?