Skip to content

[backport] [CMAKE] Use gold as a linker when available

This is 2 related backports in 1: D5465 and D5479. Original messages follow (in ascending chronological order):


Summary: This diff adds an USE_LD_GOLD option that attempts to use gold instead of the default toolchain linker. It is ON by default since it has a safe fallback path. Note that it works when cross compiling too. The option is also available with MinGw but supposedly has no effect since gold is ELF-only.

Building with debug on my machine (with ccache so linking time is more relevant), before:

real    1m28.916s
user    1m46.125s
sys     0m46.567s

After:

real    1m5.641s
user    1m21.068s
sys     0m42.618s

Test Plan: On Linux and OSX: ninja all check

Run the Gitian builds twice and check the build is still deterministic.

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5465


Summary: For some reason, gold will produce a bad executable on linux when building against the static depends. The build runs fine, is deterministic, but running bitcoind or bitcoin-qt make them stuck - they won't return, no error, won't shutdown and need to be killed. The last debug.log line is:

Using at most 125 automatic connections (1024 file descriptors available)

This needs to be investigated, but for now the gold linker is disabled.

Test Plan: Run the linux Gitian build then launch the bitcoind executable.

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D5479

Merge request reports