gentooLTO icon indicating copy to clipboard operation
gentooLTO copied to clipboard

sys-libs/compiler-rt fails with -flto in CXXFLAGS

Open mid-kid opened this issue 3 years ago • 2 comments

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 with default-lld enabled
  • Build sys-devel/llvm with gold enabled (not enabled by default, I believe it's deprecated?)
  • Build sys-libs/compiler-rt without the clang 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.

mid-kid avatar Jul 01 '21 11:07 mid-kid

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!

acjones8 avatar Oct 03 '21 09:10 acjones8

+1 for adding a note that recommends setting the default-lld flag in the instructions

haimeh avatar Oct 05 '21 22:10 haimeh