I recently discovered the LLVM's linker, lld
that was praised for very fast linking. Indeed, I tested it and the results were awesome, the linking time in my case being reduced dramatically comparing to gold
.
However, when speaking about link-time optimization, my knowledge is limited. As far as I understood by reading stuff on the internet, there is some extra-code produced in the object files, representing some internal compiler structures which is then used in the linking stage. Thus, my concern is if the link-time optimization (and it's benefits) is affected by this compiler/linker mix. I would appreciate some explanation on the matter!
I used gcc
version 9.2.0
and lld
version 10.0.0
.
Command I used for generating object files:
/opt/gcc/9.2.0/bin/c++ -fPIE -flto -ffat-lto-objects -fuse-linker-plugin -m64 -O3 -g -DNDEBUG -o my_object.cpp.o -c my_source_file.cpp
For linking:
#-fuse-ld=gold
/opt/gcc/9.2.0/bin/c++ -fPIE -flto -ffat-lto-objects -fuse-linker-plugin -m64 -pie -fuse-ld=gold -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -static-libstdc++ -static-libgcc -Wl,--threads -Wl,--thread-count,1
#-fuse-ld=lld
/opt/gcc/9.2.0/bin/c++ -fPIE -flto -ffat-lto-objects -fuse-linker-plugin -m64 -pie -fuse-ld=lld -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -static-libstdc++ -static-libgcc -Wl,--threads -Wl,