Summary: | sys-devel/llvm-11.0.0 ABI_X86=32 on AMD fam15h fails to compile with clang | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Markus Peloquin <markus> |
Component: | Current packages | Assignee: | LLVM support project <llvm> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jstein |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | AMD64 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
APInt-074daf.cpp.xz
APInt-074daf.sh |
Description
Markus Peloquin
2020-12-08 21:05:09 UTC
Created attachment 677290 [details]
APInt-074daf.cpp.xz
Created attachment 677293 [details]
APInt-074daf.sh
So it's not lost, let me repeat from the bug description: Here's where I drilled into this and finally found the problem: https://forums.gentoo.org/viewtopic-p-8541220.html#8541220 I'm not sure how clang decides to use XOP. I'm currently attempting the build llvm:11 without 'xop' in my make.conf. I'm thinking I may need to build clang:10 without it, then build llvm:11... It isn't enough to disable that flag in CPU_FLAGS_X86. -march=native enables it, seemingly regardless of how clang/llvm were built. % clang '-###' -march=native x.cpp 2>&1 | sed 's/"//g' clang version 10.0.1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm/10/bin /usr/lib/llvm/10/bin/clang-10 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name x.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu bdver1 -target-feature +sse2 -target-feature +cx16 -target-feature +sahf -target-feature -tbm -target-feature -avx512ifma -target-feature -sha -target-feature -gfni -target-feature +fma4 -target-feature -vpclmulqdq -target-feature +prfchw -target-feature -bmi2 -target-feature -cldemote -target-feature -fsgsbase -target-feature -ptwrite -target-feature -xsavec -target-feature +popcnt -target-feature +aes -target-feature -avx512bitalg -target-feature -movdiri -target-feature -xsaves -target-feature -avx512er -target-feature -avx512vnni -target-feature -avx512vpopcntdq -target-feature -pconfig -target-feature -clwb -target-feature -avx512f -target-feature -clzero -target-feature -pku -target-feature +mmx -target-feature +lwp -target-feature -rdpid -target-feature +xop -target-feature -rdseed -target-feature -waitpkg -target-feature -movdir64b -target-feature +sse4a -target-feature -avx512bw -target-feature -clflushopt -target-feature +xsave -target-feature -avx512vbmi2 -target-feature +64bit -target-feature -avx512vl -target-feature -invpcid -target-feature -avx512cd -target-feature +avx -target-feature -vaes -target-feature +cx8 -target-feature -fma -target-feature -rtm -target-feature -bmi -target-feature -enqcmd -target-feature -rdrnd -target-feature -mwaitx -target-feature +sse4.1 -target-feature +sse4.2 -target-feature -avx2 -target-feature +fxsr -target-feature -wbnoinvd -target-feature +sse -target-feature +lzcnt -target-feature +pclmul -target-feature -prefetchwt1 -target-feature -f16c -target-feature +ssse3 -target-feature -sgx -target-feature -shstk -target-feature +cmov -target-feature -avx512vbmi -target-feature -avx512bf16 -target-feature -movbe -target-feature -xsaveopt -target-feature -avx512dq -target-feature -adx -target-feature -avx512pf -target-feature +sse3 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm/10/bin/../../../../lib/clang/10.0.1 -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm/10/bin/../../../../lib/clang/10.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /root -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o /tmp/x-7c892e.o -x c++ x.cpp It looks like gcc/clang support the option -mno-xop. Including that causes the corresponding -target-feature argument to drop entirely. So I think I can just stuff that into my CFLAGS and everything will work. I can finally confirm that adding -mno-xop to my CFLAGS (after -march=native, I'm not sure if order matters) allows multilib LLVM 11 to compile on my AMD 15h CPU. If I had to decide the best place to put this hack for all Gentoo users, I'd say it'd be to add -mno-xop in an eclass, since it appears to be a bug in clang (otherwise, what's with the backtrace). But I know that's obtrusive. Maybe instead have the llvm build abort immediately if it detects XOP is enabled with the provided CFLAGS and tells the user to disable it in their make.conf? I'm going to try to file an upstream bug, but I'm not sure what the turnaround time for creating an account with bugs.llvm.org is. Self service account creation is disabled. Also, here's a minimal test-case: // clang -m32 -march=native -c test.cpp // clang -m32 -march=native -mno-xop -c test.cpp // test.cpp: int main(int argc, char **argv) { return __builtin_bitreverse64(argc); } If the first command fails with 'terminating with uncaught exception of type std::length_error: vector' while the second succeeds, XOP code generation is broken. (Correction: the first command needs -mxop if you aren't running an amd 15h CPU.) Filed upstream: https://bugs.llvm.org/show_bug.cgi?id=48451 It looks like it may be fixed in LLVM 12, which isn't finalized yet: https://reviews.llvm.org/rG57c0c4a27575840ae0a48eb9f8455a5ed087c857 https://github.com/llvm/llvm-project/commit/57c0c4a27575840ae0a48eb9f8455a5ed087c857 However, the -mno-xop flag would still be necessary to build LLVM/clang 12 the first time. upstream bug report says the fix has been backported to llvm-11.0.1? (In reply to tt_1 from comment #10) > upstream bug report says the fix has been backported to llvm-11.0.1? It looks like it is. The commit (referenced in the upstream bug) is shown on the first page of 11.0.1's commits on GitHub. https://github.com/llvm/llvm-project/commits/llvmorg-11.0.1 https://github.com/llvm/llvm-project/commit/ca8de9ad8895ab1368135f6fc63f29fe92b75c76 I guess that means I can probably get rid of my -mno-xop flag since I'm on 11.1 now... |