https://lld.llvm.org/#features point 7 says that passing LLVM bitcode directly to lld allows it to "see" the entire program, and it can better optimize the binary.
That would be linker plugin LTO which you can enable using -Clinker-plugin-lto
. Make sure to use the same LLVM version for rustc, LLVM and lld however. Older LLVM versions can't read bitcode of newer LLVM versions. Also linker plugin LTO is only necessary when you include C or C++ code. RIf you only have Rust code, regular -Clto
will already do LTO across all code.
3 Likes