While emerging firefox, I got the following compile error:
0:06.05 DEBUG: Executing: `/usr/lib/llvm/11/bin/x86_64-pc-linux-gnu-clang /var/tmp/portage/www-client/firefox-78.7.0/temp/conftest.n4tp1rsi.c -E`
0:06.05 DEBUG: The command returned non-zero exit status 127.
0:06.05 DEBUG: Its error output was:
0:06.05 DEBUG: | /usr/lib/llvm/11/bin/x86_64-pc-linux-gnu-clang: symbol lookup error: /usr/lib/llvm/11/bin/x86_64-pc-linux-gnu-clang: undefined symbol: LLVMInitializeNVPTXTargetInfo, version LLVM_11
0:06.05 ERROR: Command `/usr/lib/llvm/11/bin/x86_64-pc-linux-gnu-clang /var/tmp/portage/www-client/firefox-78.7.0/temp/conftest.n4tp1rsi.c -E` failed with exit status 127.
I think this may be related to the fact that I did not build the NVPTX LLVM target for the last clang update (I do not have a Nvidia GPU).
(I wanted to attach the build log, but Bugzilla errors out when I try that.)
Is this a duplicate of bug 767700?
(In reply to Emily Rowlands from comment #2)
> Is this a duplicate of bug 767700?
Close, but there's a difference with lld in that it doesn't define LLVM_TARGETS yet still needs a rebuild.
Given there's no mechanism (in current eapi) to force rebuilds on USE-based ABI changes you do preferably need to update everything that use LLVM_TARGETS together using --changed-use or similar.
(In reply to Ionen Wolkens from comment #3)
> (In reply to Emily Rowlands from comment #2)
> > Is this a duplicate of bug 767700?
> Close, but there's a difference with lld in that it doesn't define
> LLVM_TARGETS yet still needs a rebuild.
What do I need to rebuild? (I tried lld, but that does not fix it.)
(In reply to Erik Quaeghebeur from comment #4)
> What do I need to rebuild? (I tried lld, but that does not fix it.)
I think clang, I'm testing myself to find more proper steps to reproduce.
My guess is that something along those lines happened:
1. have clang and llvm with NVPTX
2. rebuilt clang without NVPTX first (llvm still has it, causing clang to use the symbol)
3. rebuilt llvm without NVPTX (symbol is gone)
(In reply to Ionen Wolkens from comment #5)
> My guess is that something along those lines happened:
> 1. have clang and llvm with NVPTX
> 2. rebuilt clang without NVPTX first (llvm still has it, causing clang to
> use the symbol)
> 3. rebuilt llvm without NVPTX (symbol is gone)
Can confirm this successfully breaks clang like what you're getting.
$ clang -o hello hello.c
clang: symbol lookup error: clang: undefined symbol: LLVMInitializeNVPTXTargetInfo, version LLVM_11
Similarly to lld, rebuilding clang will fix this (thankfully gcc is default, as rebuilding clang with clang wouldn't work here).
This has nothing to do with firefox so I'll tentatively assign to clang (but it's more of a generalized issue).
(In reply to Ionen Wolkens from comment #5)
> (In reply to Erik Quaeghebeur from comment #4)
> > What do I need to rebuild? (I tried lld, but that does not fix it.)
> I think clang, […]
I can confirm as well. I can emerge Firefox again after remerging clang.
Did you have sys-devel/clang built with NVPTX backend before? Did Portage somehow allow you to rebuild sys-devel/llvm without it while breaking clang's dependency graph or is that a case of automagic dep?
(In reply to Michał Górny from comment #8)
> Did you have sys-devel/clang built with NVPTX backend before?
Yes, I think so.
> Did Portage somehow allow you to rebuild sys-devel/llvm without it while
> breaking clang's dependency graph or is that a case of automagic dep?
I just put -NVPTX and emerged -U both. So I guess they were remerged in the wrong order?
It's kind of automagic I guess.
Building clang[-nvptx] against llvm[nvptx] does not break deps (the other way around would). And despite -nvptx, clang will still use the nvptx symbols if llvm has them.
At this point nothing stops you from rebuilding llvm without nvptx and losing the symbols. The same happens with lld despite it doesn't even use LLVM_TARGETS.
Well, more like ABI breakage than automagic I guess.
See the see also bug #767700 if haven't yet, had more logs/details, and lld is quicker to test than clang.
the LLVM_TARGETS flags for clang don't work. clang will always be built with references to all llvm symbols for all targets even if those use flags are not set in clang. thus clang gets stuck in the following state if you remove some flags from llvm and clang:
clang: symbol lookup error: clang: undefined symbol: LLVMInitializeVETargetInfo, version LLVM_12
symbols in clang after rebuild, even with the use flags for those targets unset:
$ strings /usr/lib/llvm/12/bin/clang-12 | grep -e 'LLVMInitialize.*TargetInfo' | sort
llvm target flags set during rebuild:
$ equery u sys-devel/clang | grep targets
The problem was probably not caused by the following commit, but the commit made my llvm and clang have to be rebuilt with fewer targets. Thus it seems to have made the problem more obvious.
I can see in my emerge output that the cmake command has the targets flag with the correct subset of LLVM_TARGETS that I specified, rather than the larger set of all targets:
And yet, the clang binary is linked against all the targets in the lib/Basic/Targets directory, including ones that it does not need:
# ls /var/tmp/portage/sys-devel/clang-12.0.1/work/clang/lib/Basic/Targets
AArch64.cpp ARM.h Lanai.cpp MSP430.h PPC.cpp SPIR.h WebAssembly.cpp
AArch64.h AVR.cpp Lanai.h NVPTX.cpp PPC.h SystemZ.cpp WebAssembly.h
AMDGPU.cpp AVR.h Le64.cpp NVPTX.h RISCV.cpp SystemZ.h X86.cpp
AMDGPU.h BPF.cpp Le64.h OSTargets.cpp RISCV.h TCE.cpp X86.h
ARC.cpp BPF.h Mips.cpp OSTargets.h Sparc.cpp TCE.h XCore.cpp
ARC.h Hexagon.cpp Mips.h PNaCl.cpp Sparc.h VE.cpp XCore.h
ARM.cpp Hexagon.h MSP430.cpp PNaCl.h SPIR.cpp VE.h
This results in the clang undefined symbol error (see previous comment) unless I always build llvm with LLVM_TARGETS='*', which I no longer want to do.
I was getting this problem with the thunderbird rebuild after changing the LLVM_TARGETS to not include the NVPTX target. I was able to resolve it by rebuilding the linker package - "sys-devel/lld". It seems that it doesn't depend on LLVM_TARGETS and it seems the reverse dependency code in portage didn't detect that it needs to be rebuilt after this change to LLVM_TARGETS.