I have a project that takes about 8 seconds to link with g++ and ld.
It uses a bunch of static libraries, most of the code is c++.
I’m interested in a general list of tips on how to reduce link time.
Anything from “dont include debug symbols” to “make your code less spagetti”
I dealt with this for years at a previous job. The GNU linker simply has serious performance problems when linking large numbers of static libraries. At one point, link time was on par with compile time, which we found so strange we actually investigated this and figured it out.
You can try to merge your static libraries into a “super-object” before linking. Instead of linking like this:
You could try this:
Note that this method gives the linker less opportunity to exclude unused object code, so your binaries may increase in size somewhat.