Open kayhayen opened 2 years ago
LTO on Windows should work with lld, for both MSVC and MinGW; you might need to explicitly specify -fuse-ld=lld to enable that.
Not sure whether the gold plugin works with the MinGW linker, but even if it does, I probably wouldn't recommend that; lld-link is more well tested.
Retitled to something actionable.
When I tried LTO with the https://github.com/mstorsjo/llvm-mingw toolchain some time ago, adding -flto=thin
(you can also use -flto
for full LTO) to CXXFLAGS
and LDFLAGS
just works. This toolchain uses LLD by default.
I don't know about the MSVC target, but https://clang.llvm.org/docs/ThinLTO.html#basic does have documented usage with clang-cl
and lld-link
so I assume it should work.
I don't think gold supports Windows or COFF at all, am I right?
I don't think gold supports Windows or COFF at all, am I right?
The "gold plugin" got its name back when the plugin API was only supported by gold, but regular binutils ld also got support for the plugin API at some point.
I am using LTO with Clang on many platforms with my Python compiler (https://nuitka.net) Nuitka.
On Windows, I didn't manage to get LTO to work, neither with winlibs, nor with the official Windows download:
It gives an "unknown file format" error with winlibs, and with LLVM official download from above, a localize error that indicates "invalid or damaged file" (localized, I didn't figure out how to disable that yet). With
file
it states the file isLLVM IR bitcode
.I am assuming that the gold LLVM plugin is not available or something. But it's absolutely not obvious to me, otherwise than
find
not revealing anything*gold*
.Can you confirm or deny if LTO is supposed to work with the official download on Windows. I assume the GPLv3 nature might be an issue for you?