my haskell project spends lots of time in linking dist/build/myapp/myapp ...
, in loading shared libraries when executing templatehaskell
code.
i suspect because ld
slow.
how can improve link times switching gold
linker?
link 3x faster gold
since ghc 7.8, can tell ghc , cabal (at run time without having recompile ghc) link gnu gold.
you need in .cabal
file:
library: ghc-options: -optl-fuse-ld=gold ld-options: -fuse-ld=gold executable myexecutable ghc-options: -optl-fuse-ld=gold ld-options: -fuse-ld=gold
(note might want pass these flags stack
/cabal
/setup.hs
on command line instead of hardcoding them in .cabal file in order not reduce portability of package.)
for me it's 3.5x
faster, bringing down total link time of project 150 seconds 40 seconds.
update: link 10x faster lld
see https://github.com/nh2/link-with-lld-example full example; key parts:
library ghc-options: "-pgmp clang" "-pgmc clang" "-pgma clang" "-pgml clang" "-optl-fuse-ld=lld" ld-options: -fuse-ld=lld executable myexecutable ghc-options: "-pgmp clang" "-pgmc clang" "-pgma clang" "-pgml clang" ld-options: -fuse-ld=lld
comparison of link time final executable link times project:
ld 124 seconds gold 36 seconds lld 11 seconds
Comments
Post a Comment