[CMAKE] Use gold as a linker when available
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