gentooLTO
gentooLTO copied to clipboard
sys-libs/compiler-rt fails with -flto in CXXFLAGS
When raw -flto
is added to CXXFLAGS (NOTE: not -flto=n
, like is default in this configuration), sys-devel/clang
is built without the default-lld
USE flag, and this package is emerged, it fails to build with an error stating that LLVMgold.so
can't be found.
This is because strip-unsupported-flags
doesn't strip this flag (as it's compatible with both GCC and Clang), and no suitable LTO linker is installed for Clang.
This can be fixed in a bunch of different ways:
- Remove
-flto
from CXXFLAGS for this package and any other package forcing itself to be built using Clang - Build
sys-devel/clang
withdefault-lld
enabled - Build
sys-devel/llvm
withgold
enabled (not enabled by default, I believe it's deprecated?) - Build
sys-libs/compiler-rt
without theclang
USE flag. I'm not sure how well supported this is.
I'm not entirely sure what should be done about this, as besides this, the only package I have that forces itself to use clang
is firefox. Firefox forces the use of LLD, compiler-rt doesn't. It could be patched in ::gentoo, but I believe at least having a note around here on making sure to enable default-lld
for clang, for example, would be a good thing.
I specify -flto
and -flto=n
both, specifically so packages that force themselves to build with clang pick it up regardless of strip-unsupported-flags
.
Yeah I think a note in the documentation somewhere would be really helpful. I just ran into this issue myself today, and I was completely stumped until I found this bug report. Setting the default-lld
flag on clang worked a treat, and it completely resolved the issue - many thanks!
+1 for adding a note that recommends setting the default-lld flag in the instructions