I’ve tried to tightly follow the development of ROS1 buildtools and the work OSRF is doing to try to make robotics software systems build faster, and in the process have come across some other alternatives to the core Catkin2 mechanism which speed up large, complex builds. One such alternative was mentioned to me by Thibault Kruse is GNU Gold after finding a thread on the Orocos mailing lists:
Some guys at Google thought that GNU ld was a bit slow on C++ programs. Guess what, they were right and wrote a new C++ linker from scratch. Enter GNU gold. It links about 10x faster than traditional ld.3
GNU Gold4 (beta) is the sucessor to ld and it’s meant to link
libraries and executables significantly faster than its predecessor. On Ubuntu
12.04, gold isn’t installed by default, but you can install a fairly recent
version of it (2.22) quickly and easily with aptitude:
sudo apt-get install binutils-goldIf you’re on another platform, or just want to see if you’re already using gold,
you can check just by checking which version your system’s ld points to:
ld --versionIf you’re using gold, it will say “gold” in the first line.
I tried building some things including Orocos, and Gold definitely sped up
the process of building a large workspace. It failed, however, when it tried
linking a target against some proprietary, closed-source libraries that were
installed to /usr/local/lib instead of /usr/lib. It turns out this is a
side-effect of an intentional change in the sources from which gold gathers
library search paths over the way standard ld does.5
Specifically, while both standard ld and gold will search:
/lib/usr/lib$LIBRARY_PATH
ld will also search the runtime shared library path, $LD_LIBRARY_PATH but
gold will not. This means that if you had been relying on ld.so.conf or
$LD_LIBRARY_PATH to locate libraries at build time, this will no longer work.
An easy fix for this, is to add the necessary paths to $LIBRARY_PATH:
export LIBRARY_PATH=/usr/local/libOnce I worked out my PATH problems, GNU Gold works like a dream.