How to selectively link certain system libraries statically into Haskell program binary?

前端 未结 2 1234
轮回少年
轮回少年 2021-02-05 12:47

I\'m currently developing some web application written in Haskell. All Haskell libraries are statically linked; although this "bloats" the executable, it not so much o

2条回答
  •  伪装坚强ぢ
    2021-02-05 12:55

    You can use -optl to pass options directly to the linker, so to link everything statically, you can use:

    ghc --make Main.hs -optl-static -optl-pthread
    

    or put these in GHC-Options if you're using Cabal.

    You can probably tweak this futher to have more fine grained control over what to link statically or dynamically. The -v (verbose) option is helpful here to see the final linker command.

提交回复
热议问题