Skip to content

Make it easier to use the gold linker

As pointed out in #4862 (closed), the gold linker is significantly faster than BFD ld. Currently we use whatever linker gcc uses by default. This is an unfortunate situation for users as few packagers take the effort to configure their builds to use gold.

I think we should consider the following,

Introduce a configure flag (to both the source distribution, and the distributed binary distributions), --enable-gold. When enabled, configure will check for the functioning of gcc -fuse-ld=gold. If found to work -fuse-ld=gold would be added to GHC's optlc. The flag would throw an error on non-ELF platforms (which are not supported by gold).

While there is admittedly not a whole lot of precedent for this, the status quo means we are leaving a significant bit of compiler performance on the table in a majority of cases. Given that stack uses GHC's official bindists, we should try to improve this situation.

In fact, I would even weakly suggest that we might consider enabling --enable-gold the default behavior, requiring the user to explicitly pass --disable-gold if they want the current behavior.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information