This should be a comment, but I cannot format code like this in comments:
I managed to use gold as the linker used by GHC, working around standard ghc-with-gold errors like /usr/bin/ld.gold: --hash-size=31: unknown option
, by installing binutils-gold
(as suggested in Michael Snoyman's answer) and then replacing the symlink /usr/bin/ld
by the following script (made executable with chmod +x
):
#!/usr/bin/env python2
import sys
import os
import subprocess
tofilter = [
"--hash-size",
"--reduce-memory-overheads",
]
filtered = [ a for a in sys.argv if not any(a.startswith(p) for p in tofilter) ]
filtered[0] = "/usr/bin/ld.gold"
subprocess.check_call(subprocess.list2cmdline(filtered))
Note that trying to set the linker with ghc -pgml /usr/bin/ld.gold
or ghc -pgml /usr/bin/ld.whateverElse
is not sufficient because the argument to -pgml
needs to be a replacement for GCC, not LD. GHC calls GCC, which calls /usr/bin/ld
; this is why the above script works.
ld
is slow, but it doesn't help that, since ghc does static linking and tries to link in a lot of stuff, there's a lot of work for the linker to do. On my slightly old macbook with 1GB ram,ld
will often run out of memory and start swapping. – Jessiajessica