Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with Kernel 6.13 and recent Clang-20git snapshot #2066

Closed
ms178 opened this issue Jan 21, 2025 · 12 comments
Closed

Crash with Kernel 6.13 and recent Clang-20git snapshot #2066

ms178 opened this issue Jan 21, 2025 · 12 comments
Labels
Compiler crash This bug makes Clang crash, emitting a backtrace Extra flags The use of additional, non-standard CFLAGS causes this issue Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.

Comments

@ms178
Copy link

ms178 commented Jan 21, 2025

On a very fresh LLVM-20 git snapshot (e4f03b158c97098e1835cc1f00d0175398974f98), I see the following crash if I want to compile the 6.13 Linux Kernel from CachyOS:

HOSTCC  scripts/asn1_compiler
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /home/marcus/llvm20/bin/clang-20 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir scripts/asn1_compiler- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name asn1_compiler.c -function-alignment 5 -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -ffp-contract=fast -fno-rounding-math -ffp-exception-behavior=ignore -mconstructor-aliases -funwind-tables=2 -target-cpu raptorlake -target-feature +prfchw -target-feature -cldemote -target-feature +avx -target-feature +sahf -target-feature -xop -target-feature +crc32 -target-feature -amx-fp8 -target-feature +xsaves -target-feature -avx512fp16 -target-feature -usermsr -target-feature -sm4 -target-feature -egpr -target-feature +sse4.1 -target-feature -avx512ifma -target-feature +xsave -target-feature +sse4.2 -target-feature -tsxldtrk -target-feature -sm3 -target-feature +ptwrite -target-feature +widekl -target-feature -movrs -target-feature +invpcid -target-feature +64bit -target-feature +xsavec -target-feature -avx10.1-512 -target-feature -avx512vpopcntdq -target-feature +cmov -target-feature -avx512vp2intersect -target-feature -avx512cd -target-feature +movbe -target-feature -avxvnniint8 -target-feature -ccmp -target-feature -amx-int8 -target-feature +kl -target-feature -avx10.1-256 -target-feature -sha512 -target-feature +avxvnni -target-feature -rtm -target-feature +adx -target-feature +avx2 -target-feature +hreset -target-feature +movdiri -target-feature +serialize -target-feature +vpclmulqdq -target-feature -avx512vl -target-feature -uintr -target-feature -cf -target-feature +clflushopt -target-feature -raoint -target-feature -cmpccxadd -target-feature +bmi -target-feature -amx-tile -target-feature +sse -target-feature -avx10.2-256 -target-feature +gfni -target-feature -avxvnniint16 -target-feature -amx-fp16 -target-feature -zu -target-feature -ndd -target-feature +xsaveopt -target-feature +rdrnd -target-feature -avx512f -target-feature -amx-bf16 -target-feature -avx512bf16 -target-feature -avx512vnni -target-feature -push2pop2 -target-feature +cx8 -target-feature -avx512bw -target-feature +sse3 -target-feature +pku -target-feature -nf -target-feature -amx-tf32 -target-feature -amx-avx512 -target-feature +fsgsbase -target-feature -clzero -target-feature -mwaitx -target-feature -lwp -target-feature +lzcnt -target-feature +sha -target-feature +movdir64b -target-feature -ppx -target-feature -wbnoinvd -target-feature -enqcmd -target-feature -amx-transpose -target-feature -avx10.2-512 -target-feature -avxneconvert -target-feature -tbm -target-feature -pconfig -target-feature -amx-complex -target-feature +ssse3 -target-feature +cx16 -target-feature +fma -target-feature +popcnt -target-feature -avxifma -target-feature +f16c -target-feature -avx512bitalg -target-feature -rdpru -target-feature +clwb -target-feature +mmx -target-feature +sse2 -target-feature +rdseed -target-feature -avx512vbmi2 -target-feature -prefetchi -target-feature -amx-movrs -target-feature +rdpid -target-feature -fma4 -target-feature -avx512vbmi -target-feature +shstk -target-feature +vaes -target-feature +waitpkg -target-feature -sgx -target-feature +fxsr -target-feature -avx512dq -target-feature -sse4a -target-feature +aes -target-feature +bmi2 -target-feature +pclmul -tune-cpu raptorlake -debugger-tuning=gdb -fdebug-compilation-dir=/tmp/makepkg/linux-cachyos/src/linux-6.13 -ffunction-sections -fdata-sections -fsplit-machine-functions -fcoverage-compilation-dir=/tmp/makepkg/linux-cachyos/src/linux-6.13 -resource-dir /home/marcus/llvm20/lib/clang/20 -dependency-file scripts/.asn1_compiler.d -MT scripts/asn1_compiler -I ./scripts/include -I ./include -internal-isystem /home/marcus/llvm20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -source-date-epoch 1737487879 -O3 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-error -w -std=gnu11 -ferror-limit 19 -fcf-protection=none -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -mprefer-vector-width=256 -mllvm -inline-threshold=1000 -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -mllvm -enable-interleaved-mem-accesses -mllvm -enable-masked-interleaved-mem-accesses -mllvm -adce-remove-loops -mllvm -enable-ext-tsp-block-placement -mllvm -enable-gvn-hoist -mllvm -enable-dfa-jump-thread -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/asn1_compiler-456ed7.o -x c scripts/asn1_compiler.c
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,extra-vector-passes,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,early-cse<>,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-unroll-and-jam),loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "scripts/asn1_compiler.c"
4.      Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "main"
 #0 0x00005e1b5aed88c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) Signals.cpp:0:0
 #1 0x00005e1b5aed8ccf SignalHandler(int) Signals.cpp:0:0
 #2 0x00007762de845f50 (/usr/lib/libc.so.6+0x45f50)
 #3 0x00005e1b58dd7acd llvm::X86TTIImpl::getCastInstrCost(unsigned int, llvm::Type*, llvm::Type*, llvm::TargetTransformInfo::CastContextHint, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) (.cold) X86TargetTransformInfo.cpp:0:0
 #4 0x00005e1b5bc88c83 llvm::VPWidenCastRecipe::computeCost(llvm::ElementCount, llvm::VPCostContext&) const (/home/marcus/llvm20/bin/clang-20+0xce88c83)
 #5 0x00005e1b5bc8322b llvm::VPRecipeBase::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce8322b)
 #6 0x00005e1b5bc761c3 llvm::VPBasicBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce761c3)
 #7 0x00005e1b5bc7637d llvm::VPRegionBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce7637d)
 #8 0x00005e1b5bc23e9c llvm::LoopVectorizationPlanner::cost(llvm::VPlan&, llvm::ElementCount) const LoopVectorize.cpp:0:0
 #9 0x00005e1b5bc24265 llvm::LoopVectorizationPlanner::computeBestVF() LoopVectorize.cpp:0:0
#10 0x00005e1b5bc52312 llvm::LoopVectorizePass::processLoop(llvm::Loop*) LoopVectorize.cpp:0:0
#11 0x00005e1b59b252c1 llvm::LoopVectorizePass::runImpl(llvm::Function&) LoopVectorize.cpp:0:0
#12 0x00005e1b599aed27 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (.cold) bolt-pseudo.o:0:0
#13 0x00005e1b58af07cd llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#14 0x00005e1b57cfc769 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/marcus/llvm20/bin/clang-20+0x8efc769)
#15 0x00005e1b57cfc11b llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) AMDGPUTargetMachine.cpp:0:0
#16 0x00005e1b57faea24 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91aea24)
#17 0x00005e1b57fae6a9 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) AMDGPUTargetMachine.cpp:0:0
#18 0x00005e1b57fb7744 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91b7744)
#19 0x00005e1b586a8fdf (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#20 0x00005e1b585c1fef clang::emitBackendOutput(clang::CompilerInstance&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/marcus/llvm20/bin/clang-20+0x97c1fef)
#21 0x00005e1b59a64ca2 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/marcus/llvm20/bin/clang-20+0xac64ca2)
#22 0x00005e1b57d7a684 clang::ParseAST(clang::Sema&, bool, bool) (/home/marcus/llvm20/bin/clang-20+0x8f7a684)
#23 0x00005e1b5873281e clang::FrontendAction::Execute() (/home/marcus/llvm20/bin/clang-20+0x993281e)
#24 0x00005e1b5869a9ab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/marcus/llvm20/bin/clang-20+0x989a9ab)
#25 0x00005e1b5869ad9c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/marcus/llvm20/bin/clang-20+0x989ad9c)
#26 0x00005e1b58698b4e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/marcus/llvm20/bin/clang-20+0x9898b4e)
#27 0x00005e1b5869a2f1 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x00005e1b58697d19 clang_main(int, char**, llvm::ToolContext const&) (/home/marcus/llvm20/bin/clang-20+0x9897d19)
#29 0x00005e1b52a9b752 (/home/marcus/llvm20/bin/clang-20+0x3c9b752)
#30 0x00007762de826187 (/usr/lib/libc.so.6+0x26187)
#31 0x00007762de826237 __libc_start_main (/usr/lib/libc.so.6+0x26237)
#32 0x00005e1b533bce71 _start (/home/marcus/llvm20/bin/clang-20+0x45bce71)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git (https://github.com/llvm/llvm-project.git e4f03b158c97098e1835cc1f00d0175398974f98)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/marcus/llvm20/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/asn1_compiler-82f6f2.c
clang: note: diagnostic msg: /tmp/asn1_compiler-82f6f2.sh
clang: note: diagnostic msg: 

********************
make[2]: *** [scripts/Makefile.host:114: scripts/asn1_compiler] Fehler 1
make[1]: *** [/tmp/makepkg/linux-cachyos/src/linux-6.13/Makefile:1255: scripts] Fehler 2
make: *** [Makefile:251: __sub-make] Fehler 2

asn1_compiler-82f6f2.c.txt
asn1_compiler-82f6f2.sh.txt

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jan 21, 2025 via email

@ms178
Copy link
Author

ms178 commented Jan 21, 2025

Looks like -O3 was set, so non standard command line flags are related
here.

I've tried something more conservative and also dbus-broker, with the same issue (trace is from dbus-broker):

[106/183] Compiling C object subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o
FAILED: subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o 
clang -Isubprojects/libcutf8-1/src/bench-multibyte.p -Isubprojects/libcutf8-1/src -I../dbus-broker-git/subprojects/libcutf8-1/src -Isubprojects/libcstdaux-1/src -I../dbus-broker-git/subprojects/libcstdaux-1/src -flto -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -O0 -g -D_GNU_SOURCE -Wno-gnu-alignof-expression -Wno-unknown-warning-option -Wno-unused-parameter -Wno-error=type-limits -Wno-error=missing-field-initializers -Wdate-time -Wdeclaration-after-statement -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wshadow -Wundef -Wwrite-strings -O3 -march=native -mtune=native -mllvm -inline-threshold=1500 -mllvm -polly -mllvm -polly-position=early -mllvm -polly-dependences-computeout=6000000 -mllvm -polly-detect-profitability-min-per-loop-insts=40 -mllvm -polly-tiling=true -mllvm -polly-prevect-width=256 -mllvm -polly-vectorizer=stripmine -mllvm -polly-invariant-load-hoisting -mllvm -polly-loopfusion-greedy -mllvm -polly-run-inliner -mllvm -polly-run-dce -mllvm -polly-enable-delicm=true -mllvm -polly -fmerge-all-constants -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -mllvm -enable-interleaved-mem-accesses -mllvm -enable-masked-interleaved-mem-accesses -fno-math-errno -fno-trapping-math -falign-functions=32 -funroll-loops -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -mprefer-vector-width=256 -flto -fwhole-program-vtables -fsplit-lto-unit -mllvm -adce-remove-loops -mllvm -enable-ext-tsp-block-placement=1 -mllvm -enable-gvn-hoist=1 -mllvm -enable-dfa-jump-thread=1 -Wno-error -fdata-sections -ffunction-sections -fno-unique-section-names -mtls-dialect=gnu2 -fgnuc-version=14.2.0 -fprofile-generate -g3 -fno-omit-frame-pointer -mllvm -vp-counters-per-site=10 -D_FORTIFY_SOURCE=0 -MD -MQ subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o -MF subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o.d -o subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o -c ../dbus-broker-git/subprojects/libcutf8-1/src/bench-multibyte.c
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -Isubprojects/libcutf8-1/src/bench-multibyte.p -Isubprojects/libcutf8-1/src -I../dbus-broker-git/subprojects/libcutf8-1/src -Isubprojects/libcstdaux-1/src -I../dbus-broker-git/subprojects/libcstdaux-1/src -flto -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -O0 -g -D_GNU_SOURCE -Wno-gnu-alignof-expression -Wno-unknown-warning-option -Wno-unused-parameter -Wno-error=type-limits -Wno-error=missing-field-initializers -Wdate-time -Wdeclaration-after-statement -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wshadow -Wundef -Wwrite-strings -O3 -march=native -mtune=native -mllvm -inline-threshold=1500 -mllvm -polly -mllvm -polly-position=early -mllvm -polly-dependences-computeout=6000000 -mllvm -polly-detect-profitability-min-per-loop-insts=40 -mllvm -polly-tiling=true -mllvm -polly-prevect-width=256 -mllvm -polly-vectorizer=stripmine -mllvm -polly-invariant-load-hoisting -mllvm -polly-loopfusion-greedy -mllvm -polly-run-inliner -mllvm -polly-run-dce -mllvm -polly-enable-delicm=true -mllvm -polly -fmerge-all-constants -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -mllvm -enable-interleaved-mem-accesses -mllvm -enable-masked-interleaved-mem-accesses -fno-math-errno -fno-trapping-math -falign-functions=32 -funroll-loops -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -mprefer-vector-width=256 -flto -fwhole-program-vtables -fsplit-lto-unit -mllvm -adce-remove-loops -mllvm -enable-ext-tsp-block-placement=1 -mllvm -enable-gvn-hoist=1 -mllvm -enable-dfa-jump-thread=1 -Wno-error -fdata-sections -ffunction-sections -fno-unique-section-names -mtls-dialect=gnu2 -fgnuc-version=14.2.0 -fprofile-generate -g3 -fno-omit-frame-pointer -mllvm -vp-counters-per-site=10 -D_FORTIFY_SOURCE=0 -MD -MQ subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o -MF subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o.d -o subprojects/libcutf8-1/src/bench-multibyte.p/bench-multibyte.c.o -c ../dbus-broker-git/subprojects/libcutf8-1/src/bench-multibyte.c
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,extra-vector-passes,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,early-cse<>,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-unroll-and-jam),loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "../dbus-broker-git/subprojects/libcutf8-1/src/bench-multibyte.c"
4.      Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "main"
 #0 0x00005b6392ed88c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) Signals.cpp:0:0
 #1 0x00005b6392ed86b5 llvm::sys::CleanupOnSignal(unsigned long) (/home/marcus/llvm20/bin/clang-20+0xc0d86b5)
 #2 0x00005b6392e9e878 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x00005b6392e9e9fe CrashRecoverySignalHandler(int) (.llvm.7573658860347809712) CrashRecoveryContext.cpp:0:0
 #4 0x00007731a2c45f50 (/usr/lib/libc.so.6+0x45f50)
 #5 0x00005b6390dd7acd llvm::X86TTIImpl::getCastInstrCost(unsigned int, llvm::Type*, llvm::Type*, llvm::TargetTransformInfo::CastContextHint, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) (.cold) X86TargetTransformInfo.cpp:0:0
 #6 0x00005b6393c88c83 llvm::VPWidenCastRecipe::computeCost(llvm::ElementCount, llvm::VPCostContext&) const (/home/marcus/llvm20/bin/clang-20+0xce88c83)
 #7 0x00005b6393c8322b llvm::VPRecipeBase::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce8322b)
 #8 0x00005b6393c761c3 llvm::VPBasicBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce761c3)
 #9 0x00005b6393c7637d llvm::VPRegionBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce7637d)
#10 0x00005b6393c23e9c llvm::LoopVectorizationPlanner::cost(llvm::VPlan&, llvm::ElementCount) const LoopVectorize.cpp:0:0
#11 0x00005b6393c24265 llvm::LoopVectorizationPlanner::computeBestVF() LoopVectorize.cpp:0:0
#12 0x00005b6393c52312 llvm::LoopVectorizePass::processLoop(llvm::Loop*) LoopVectorize.cpp:0:0
#13 0x00005b6391b252c1 llvm::LoopVectorizePass::runImpl(llvm::Function&) LoopVectorize.cpp:0:0
#14 0x00005b63919aed27 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (.cold) bolt-pseudo.o:0:0
#15 0x00005b6390af07cd llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#16 0x00005b638fcfc769 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/marcus/llvm20/bin/clang-20+0x8efc769)
#17 0x00005b638fcfc11b llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) AMDGPUTargetMachine.cpp:0:0
#18 0x00005b638ffaea24 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91aea24)
#19 0x00005b638ffae6a9 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) AMDGPUTargetMachine.cpp:0:0
#20 0x00005b638ffb7744 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91b7744)
#21 0x00005b63906a8fdf (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#22 0x00005b63905c1fef clang::emitBackendOutput(clang::CompilerInstance&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/marcus/llvm20/bin/clang-20+0x97c1fef)
#23 0x00005b6391a64ca2 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/marcus/llvm20/bin/clang-20+0xac64ca2)
#24 0x00005b638fd7a684 clang::ParseAST(clang::Sema&, bool, bool) (/home/marcus/llvm20/bin/clang-20+0x8f7a684)
#25 0x00005b639073281e clang::FrontendAction::Execute() (/home/marcus/llvm20/bin/clang-20+0x993281e)
#26 0x00005b639069a9ab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/marcus/llvm20/bin/clang-20+0x989a9ab)
#27 0x00005b639069ad9c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/marcus/llvm20/bin/clang-20+0x989ad9c)
#28 0x00005b6390698b4e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/marcus/llvm20/bin/clang-20+0x9898b4e)
#29 0x00005b639069a2f1 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x00005b639069a1a1 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#31 0x00005b639069a179 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/marcus/llvm20/bin/clang-20+0x989a179)
#32 0x00005b639069a04d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/marcus/llvm20/bin/clang-20+0x989a04d)
#33 0x00005b6390699ea4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/marcus/llvm20/bin/clang-20+0x9899ea4)
#34 0x00005b6390699c24 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/marcus/llvm20/bin/clang-20+0x9899c24)
#35 0x00005b6390697a90 clang_main(int, char**, llvm::ToolContext const&) (/home/marcus/llvm20/bin/clang-20+0x9897a90)
#36 0x00005b638aa9b752 (/home/marcus/llvm20/bin/clang-20+0x3c9b752)
#37 0x00007731a2c26187 (/usr/lib/libc.so.6+0x26187)
#38 0x00007731a2c26237 __libc_start_main (/usr/lib/libc.so.6+0x26237)
#39 0x00005b638b3bce71 _start (/home/marcus/llvm20/bin/clang-20+0x45bce71)

@ms178
Copy link
Author

ms178 commented Jan 21, 2025

Dbus-broker gets past the first stage in my PGO+BOLT-optimized PKGBUILD with these very modest flags...

export CC=clang
export CXX=clang++
export CC_LD=lld
export CXX_LD=lld
export AR=llvm-ar
export NM=llvm-nm
export STRIP=llvm-strip
export OBJCOPY=llvm-objcopy
export OBJDUMP=llvm-objdump
export READELF=llvm-readelf
export RANLIB=llvm-ranlib
export HOSTCC=clang
export HOSTCXX=clang++
export HOSTAR=llvm-ar
export CPPFLAGS="-D_FORTIFY_SOURCE=0"
export CFLAGS="-O2 -march=native -mtune=native -falign-functions=32 -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -w"
export CXXFLAGS="${CFLAGS} -Wp,-U_GLIBCXX_ASSERTIONS"
export LDFLAGS="-Wl,-O3,-Bsymbolic-functions,--as-needed -fcf-protection=none -mharden-sls=none -Wl,--push-state -Wl,-whole-archive -lmimalloc -Wl,--pop-state -lpthread -lstdc++ -lm -ldl -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs -Wl,--hash-style=gnu -Wl,--undefined-version"
export CCLDFLAGS="$LDFLAGS"
export CXXLDFLAGS="$LDFLAGS"
export ASFLAGS="-D__AVX__=1 -D__AVX2__=1 -D__FMA__=1"

... but fails in stage 2 with a trace that looks very familiar:

[135/183] Compiling C object src/libbus-static.a.p/dbus_sasl.c.o
FAILED: src/libbus-static.a.p/dbus_sasl.c.o 
clang -Isrc/libbus-static.a.p -Isrc -I../dbus-broker-git/src -Isubprojects/libcdvar-1/src -I../dbus-broker-git/subprojects/libcdvar-1/src -Isubprojects/libcstdaux-1/src -I../dbus-broker-git/subprojects/libcstdaux-1/src -Isubprojects/libcutf8-1/src -I../dbus-broker-git/subprojects/libcutf8-1/src -Isubprojects/libclist-3/src -I../dbus-broker-git/subprojects/libclist-3/src -Isubprojects/libcrbtree-3/src -I../dbus-broker-git/subprojects/libcrbtree-3/src -flto -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu18 -O3 -D_GNU_SOURCE -Wno-gnu-alignof-expression -Wno-maybe-uninitialized -Wno-unknown-warning-option -Wno-unused-parameter -Wno-error=type-limits -Wno-error=missing-field-initializers -Wdate-time -Wdeclaration-after-statement -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wsuggest-attribute=noreturn -Wundef -Wwrite-strings '-DBINDIR="/usr/bin"' -DPACKAGE_VERSION=36 -DSYSTEMUIDMAX=999 '-DSYSTEM_CONSOLE_USERS="gdm","sddm","lightdm","lxdm",' -O2 -march=native -mtune=native -falign-functions=32 -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -w -fprofile-use=/tmp/makepkg/dbus-broker-git/src/default.profdata -D_FORTIFY_SOURCE=0 -fPIC -fvisibility=hidden -fno-common -MD -MQ src/libbus-static.a.p/dbus_sasl.c.o -MF src/libbus-static.a.p/dbus_sasl.c.o.d -o src/libbus-static.a.p/dbus_sasl.c.o -c ../dbus-broker-git/src/dbus/sasl.c
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -Isrc/libbus-static.a.p -Isrc -I../dbus-broker-git/src -Isubprojects/libcdvar-1/src -I../dbus-broker-git/subprojects/libcdvar-1/src -Isubprojects/libcstdaux-1/src -I../dbus-broker-git/subprojects/libcstdaux-1/src -Isubprojects/libcutf8-1/src -I../dbus-broker-git/subprojects/libcutf8-1/src -Isubprojects/libclist-3/src -I../dbus-broker-git/subprojects/libclist-3/src -Isubprojects/libcrbtree-3/src -I../dbus-broker-git/subprojects/libcrbtree-3/src -flto -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu18 -O3 -D_GNU_SOURCE -Wno-gnu-alignof-expression -Wno-maybe-uninitialized -Wno-unknown-warning-option -Wno-unused-parameter -Wno-error=type-limits -Wno-error=missing-field-initializers -Wdate-time -Wdeclaration-after-statement -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wshadow -Wstrict-aliasing=3 -Wsuggest-attribute=noreturn -Wundef -Wwrite-strings -DBINDIR=\"/usr/bin\" -DPACKAGE_VERSION=36 -DSYSTEMUIDMAX=999 -DSYSTEM_CONSOLE_USERS=\"gdm\",\"sddm\",\"lightdm\",\"lxdm\", -O2 -march=native -mtune=native -falign-functions=32 -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -w -fprofile-use=/tmp/makepkg/dbus-broker-git/src/default.profdata -D_FORTIFY_SOURCE=0 -fPIC -fvisibility=hidden -fno-common -MD -MQ src/libbus-static.a.p/dbus_sasl.c.o -MF src/libbus-static.a.p/dbus_sasl.c.o.d -o src/libbus-static.a.p/dbus_sasl.c.o -c ../dbus-broker-git/src/dbus/sasl.c
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "../dbus-broker-git/src/dbus/sasl.c"
4.      Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "sasl_server_dispatch"
 #0 0x000059d197cd88c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) Signals.cpp:0:0
 #1 0x000059d197cd86b5 llvm::sys::CleanupOnSignal(unsigned long) (/home/marcus/llvm20/bin/clang-20+0xc0d86b5)
 #2 0x000059d197c9e878 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x000059d197c9e9fe CrashRecoverySignalHandler(int) (.llvm.7573658860347809712) CrashRecoveryContext.cpp:0:0
 #4 0x00007b53a7c45f50 (/usr/lib/libc.so.6+0x45f50)
 #5 0x000059d195bd7acd llvm::X86TTIImpl::getCastInstrCost(unsigned int, llvm::Type*, llvm::Type*, llvm::TargetTransformInfo::CastContextHint, llvm::TargetTransformInfo::TargetCostKind, llvm::Instruction const*) (.cold) X86TargetTransformInfo.cpp:0:0
 #6 0x000059d198a88c83 llvm::VPWidenCastRecipe::computeCost(llvm::ElementCount, llvm::VPCostContext&) const (/home/marcus/llvm20/bin/clang-20+0xce88c83)
 #7 0x000059d198a8322b llvm::VPRecipeBase::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce8322b)
 #8 0x000059d198a761c3 llvm::VPBasicBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce761c3)
 #9 0x000059d198a7637d llvm::VPRegionBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/home/marcus/llvm20/bin/clang-20+0xce7637d)
#10 0x000059d198a23e9c llvm::LoopVectorizationPlanner::cost(llvm::VPlan&, llvm::ElementCount) const LoopVectorize.cpp:0:0
#11 0x000059d198a24265 llvm::LoopVectorizationPlanner::computeBestVF() LoopVectorize.cpp:0:0
#12 0x000059d198a52312 llvm::LoopVectorizePass::processLoop(llvm::Loop*) LoopVectorize.cpp:0:0
#13 0x000059d1969252c1 llvm::LoopVectorizePass::runImpl(llvm::Function&) LoopVectorize.cpp:0:0
#14 0x000059d1967aed27 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (.cold) bolt-pseudo.o:0:0
#15 0x000059d1958f07cd llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#16 0x000059d194afc769 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/marcus/llvm20/bin/clang-20+0x8efc769)
#17 0x000059d194afc11b llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) AMDGPUTargetMachine.cpp:0:0
#18 0x000059d194daea24 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91aea24)
#19 0x000059d194dae6a9 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) AMDGPUTargetMachine.cpp:0:0
#20 0x000059d194db7744 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/marcus/llvm20/bin/clang-20+0x91b7744)
#21 0x000059d1954a8fdf (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#22 0x000059d1953c1fef clang::emitBackendOutput(clang::CompilerInstance&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/marcus/llvm20/bin/clang-20+0x97c1fef)
#23 0x000059d196864ca2 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/marcus/llvm20/bin/clang-20+0xac64ca2)
#24 0x000059d194b7a684 clang::ParseAST(clang::Sema&, bool, bool) (/home/marcus/llvm20/bin/clang-20+0x8f7a684)
#25 0x000059d19553281e clang::FrontendAction::Execute() (/home/marcus/llvm20/bin/clang-20+0x993281e)
#26 0x000059d19549a9ab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/marcus/llvm20/bin/clang-20+0x989a9ab)
#27 0x000059d19549ad9c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/marcus/llvm20/bin/clang-20+0x989ad9c)
#28 0x000059d195498b4e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/marcus/llvm20/bin/clang-20+0x9898b4e)
#29 0x000059d19549a2f1 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x000059d19549a1a1 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#31 0x000059d19549a179 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/marcus/llvm20/bin/clang-20+0x989a179)
#32 0x000059d19549a04d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/marcus/llvm20/bin/clang-20+0x989a04d)
#33 0x000059d195499ea4 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/marcus/llvm20/bin/clang-20+0x9899ea4)
#34 0x000059d195499c24 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/marcus/llvm20/bin/clang-20+0x9899c24)
#35 0x000059d195497a90 clang_main(int, char**, llvm::ToolContext const&) (/home/marcus/llvm20/bin/clang-20+0x9897a90)
#36 0x000059d18f89b752 (/home/marcus/llvm20/bin/clang-20+0x3c9b752)
#37 0x00007b53a7c26187 (/usr/lib/libc.so.6+0x26187)
#38 0x00007b53a7c26237 __libc_start_main (/usr/lib/libc.so.6+0x26237)
#39 0x000059d1901bce71 _start (/home/marcus/llvm20/bin/clang-20+0x45bce71)

sasl-80e9b3.c.txt
sasl-80e9b3.sh.txt

@ms178
Copy link
Author

ms178 commented Jan 21, 2025

O2 and above seems to trigger this, I don't get it with O1 and these flags:

export CC=clang
export CXX=clang++
export CC_LD=lld
export CXX_LD=lld
export AR=llvm-ar
export NM=llvm-nm
export STRIP=llvm-strip
export OBJCOPY=llvm-objcopy
export OBJDUMP=llvm-objdump
export READELF=llvm-readelf
export RANLIB=llvm-ranlib
export HOSTCC=clang
export HOSTCXX=clang++
export HOSTAR=llvm-ar
export CPPFLAGS="-D_FORTIFY_SOURCE=0"
export CFLAGS="-O1 -march=native -mtune=native -falign-functions=32 -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -w"
export CXXFLAGS="${CFLAGS} -Wp,-U_GLIBCXX_ASSERTIONS"
export LDFLAGS="-Wl,-O3,-Bsymbolic-functions,--as-needed -fcf-protection=none -mharden-sls=none -Wl,--hash-style=gnu -Wl,--undefined-version"
export CCLDFLAGS="$LDFLAGS"
export CXXLDFLAGS="$LDFLAGS"
export ASFLAGS="-D__AVX__=1 -D__AVX2__=1 -D__FMA__=1"

@nickdesaulniers nickdesaulniers added Extra flags The use of additional, non-standard CFLAGS causes this issue Compiler crash This bug makes Clang crash, emitting a backtrace labels Jan 21, 2025
@nickdesaulniers
Copy link
Member

Can you rebuild llvm with assertions enabled? There's an assert in X86TTIImpl::getCastInstrCost that may catch which "instruction opcode" is missing a selection dag node. -DLLVM_ENABLE_ASSERTIONS=ON

@nathanchance
Copy link
Member

It also looks like there are a bunch of vectorizing flags in the command, presumably those come from CachyOS as well? Is there any way to see everything that they enable because those certainly seem related for reproducing?

cc @ptr1337

@ms178
Copy link
Author

ms178 commented Jan 21, 2025

@nathanchance These additional vectorizing flags are from my personal modifications. The issue doesn't seem to be specific to the Linux Kernel though, I've since reproduced it with dbus-broker with O2 and above (O1 is fine). I am currently building LLVM with assertions enabled, as Nick suggested. I'll come back if I have more to report.

P.S: I've also filed llvm/llvm-project#123809 to track this on LLVM upstream.

@nickdesaulniers nickdesaulniers added the Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list. label Jan 21, 2025
@ms178
Copy link
Author

ms178 commented Jan 21, 2025

With an assertion build from the same revision but minus the BOLT optimization stage that I usually perform on top, I cannot reproduce this issue. Yet another level of added complexity is that I've used some BOLT patches on top which might be a factor here, too.

Next, I'll perform the BOLT optimization on the assertion build and see if that causes the issue to re-appear.

@ms178
Copy link
Author

ms178 commented Jan 21, 2025

Indeed something bad is going on after performing the BOLT optimizations.

The trace with the Kernel looks different, though:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /home/marcus/llvm20/bin/clang-20 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir scripts/basic/fixdep- -disable-free -clear-ast-before-backend -main-file-name fixdep.c -function-alignment 5 -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -ffp-contract=fast -fno-rounding-math -ffp-exception-behavior=ignore -mconstructor-aliases -funwind-tables=2 -target-cpu raptorlake -target-feature +prfchw -target-feature -cldemote -target-feature +avx -target-feature +sahf -target-feature -xop -target-feature +crc32 -target-feature -amx-fp8 -target-feature +xsaves -target-feature -avx512fp16 -target-feature -usermsr -target-feature -sm4 -target-feature -egpr -target-feature +sse4.1 -target-feature -avx512ifma -target-feature +xsave -target-feature +sse4.2 -target-feature -tsxldtrk -target-feature -sm3 -target-feature +ptwrite -target-feature +widekl -target-feature -movrs -target-feature +invpcid -target-feature +64bit -target-feature +xsavec -target-feature -avx10.1-512 -target-feature -avx512vpopcntdq -target-feature +cmov -target-feature -avx512vp2intersect -target-feature -avx512cd -target-feature +movbe -target-feature -avxvnniint8 -target-feature -ccmp -target-feature -amx-int8 -target-feature +kl -target-feature -avx10.1-256 -target-feature -sha512 -target-feature +avxvnni -target-feature -rtm -target-feature +adx -target-feature +avx2 -target-feature +hreset -target-feature +movdiri -target-feature +serialize -target-feature +vpclmulqdq -target-feature -avx512vl -target-feature -uintr -target-feature -cf -target-feature +clflushopt -target-feature -raoint -target-feature -cmpccxadd -target-feature +bmi -target-feature -amx-tile -target-feature +sse -target-feature -avx10.2-256 -target-feature +gfni -target-feature -avxvnniint16 -target-feature -amx-fp16 -target-feature -zu -target-feature -ndd -target-feature +xsaveopt -target-feature +rdrnd -target-feature -avx512f -target-feature -amx-bf16 -target-feature -avx512bf16 -target-feature -avx512vnni -target-feature -push2pop2 -target-feature +cx8 -target-feature -avx512bw -target-feature +sse3 -target-feature +pku -target-feature -nf -target-feature -amx-tf32 -target-feature -amx-avx512 -target-feature +fsgsbase -target-feature -clzero -target-feature -mwaitx -target-feature -lwp -target-feature +lzcnt -target-feature +sha -target-feature +movdir64b -target-feature -ppx -target-feature -wbnoinvd -target-feature -enqcmd -target-feature -amx-transpose -target-feature -avx10.2-512 -target-feature -avxneconvert -target-feature -tbm -target-feature -pconfig -target-feature -amx-complex -target-feature +ssse3 -target-feature +cx16 -target-feature +fma -target-feature +popcnt -target-feature -avxifma -target-feature +f16c -target-feature -avx512bitalg -target-feature -rdpru -target-feature +clwb -target-feature +mmx -target-feature +sse2 -target-feature +rdseed -target-feature -avx512vbmi2 -target-feature -prefetchi -target-feature -amx-movrs -target-feature +rdpid -target-feature -fma4 -target-feature -avx512vbmi -target-feature +shstk -target-feature +vaes -target-feature +waitpkg -target-feature -sgx -target-feature +fxsr -target-feature -avx512dq -target-feature -sse4a -target-feature +aes -target-feature +bmi2 -target-feature +pclmul -tune-cpu raptorlake -debugger-tuning=gdb -fdebug-compilation-dir=/tmp/makepkg/linux-cachyos/src/linux-6.13 -ffunction-sections -fdata-sections -fsplit-machine-functions -fcoverage-compilation-dir=/tmp/makepkg/linux-cachyos/src/linux-6.13 -resource-dir /home/marcus/llvm20/lib/clang/20 -dependency-file scripts/basic/.fixdep.d -MT scripts/basic/fixdep -I ./scripts/include -internal-isystem /home/marcus/llvm20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -source-date-epoch 1737500420 -O3 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-error -w -std=gnu11 -ferror-limit 19 -fcf-protection=none -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -mprefer-vector-width=256 -mllvm -inline-threshold=1000 -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -mllvm -enable-interleaved-mem-accesses -mllvm -enable-masked-interleaved-mem-accesses -mllvm -adce-remove-loops -mllvm -enable-ext-tsp-block-placement -mllvm -enable-gvn-hoist -mllvm -enable-dfa-jump-thread -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/fixdep-243e73.o -x c scripts/basic/fixdep.c
1.      /usr/include/unistd.h:1011:67: current parser token ';'
 #0 0x00005ff2461d9a66 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) Signals.cpp:0:0
 #1 0x00005ff2461d9e69 SignalHandler(int) Signals.cpp:0:0
 #2 0x0000778eddc45f50 (/usr/lib/libc.so.6+0x45f50)
 #3 0x00005ff242600a98 clang::Decl::getTranslationUnitDecl() (/home/marcus/llvm20/bin/clang-20+0xb800a98)
 #4 0x00005ff2426c545e clang::Decl::addAttr(clang::Attr*) (/home/marcus/llvm20/bin/clang-20+0xb8c545e)
 #5 0x00005ff242a4936f (anonymous namespace)::ParsedAttrInfoConst::handleDeclAttribute(clang::Sema&, clang::Decl*, clang::ParsedAttr const&) const (.0105da2943f03a831a0cebd4d20633ef) ParsedAttr.cpp:0:0
 #6 0x00005ff242a4adc5 ProcessDeclAttribute(clang::Sema&, clang::Scope*, clang::Decl*, clang::ParsedAttr const&, clang::Sema::ProcessDeclAttributeOptions const&) (.llvm.14143684358988481704) SemaDeclAttr.cpp:0:0
 #7 0x00005ff24261bde8 clang::Sema::ProcessDeclAttributeList(clang::Scope*, clang::Decl*, clang::ParsedAttributesView const&, clang::Sema::ProcessDeclAttributeOptions const&) (/home/marcus/llvm20/bin/clang-20+0xb81bde8)
 #8 0x00005ff24261bd04 clang::Sema::ProcessDeclAttributes(clang::Scope*, clang::Decl*, clang::Declarator const&) (/home/marcus/llvm20/bin/clang-20+0xb81bd04)
 #9 0x00005ff2426e8180 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/home/marcus/llvm20/bin/clang-20+0xb8e8180)
#10 0x00005ff242679744 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/home/marcus/llvm20/bin/clang-20+0xb879744)
#11 0x00005ff242679258 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/home/marcus/llvm20/bin/clang-20+0xb879258)
#12 0x00005ff242670419 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) ParseDecl.cpp:0:0
#13 0x00005ff242675c0f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/home/marcus/llvm20/bin/clang-20+0xb875c0f)
#14 0x00005ff242676704 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) Parser.cpp:0:0
#15 0x00005ff242676482 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/home/marcus/llvm20/bin/clang-20+0xb876482)
#16 0x00005ff2426716ca clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/marcus/llvm20/bin/clang-20+0xb8716ca)
#17 0x00005ff2426b043f clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/home/marcus/llvm20/bin/clang-20+0xb8b043f)
#18 0x00005ff2426b017a clang::ParseAST(clang::Sema&, bool, bool) (/home/marcus/llvm20/bin/clang-20+0xb8b017a)
#19 0x00005ff243107229 clang::FrontendAction::Execute() (/home/marcus/llvm20/bin/clang-20+0xc307229)
#20 0x00005ff242ee04f3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/marcus/llvm20/bin/clang-20+0xc0e04f3)
#21 0x00005ff242ee0a18 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/marcus/llvm20/bin/clang-20+0xc0e0a18)
#22 0x00005ff242ede14d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/marcus/llvm20/bin/clang-20+0xc0de14d)
#23 0x00005ff242eda472 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x00005ff242edc7e8 clang_main(int, char**, llvm::ToolContext const&) (/home/marcus/llvm20/bin/clang-20+0xc0dc7e8)
#25 0x00005ff23ab045f2 (/home/marcus/llvm20/bin/clang-20+0x3d045f2)
#26 0x0000778eddc26187 (/usr/lib/libc.so.6+0x26187)
#27 0x0000778eddc26237 __libc_start_main (/usr/lib/libc.so.6+0x26237)
#28 0x00005ff23adee751 _start (/home/marcus/llvm20/bin/clang-20+0x3fee751)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git (https://github.com/llvm/llvm-project.git e4f03b158c97098e1835cc1f00d0175398974f98)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/marcus/llvm20/bin
Build config: +assertions
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/fixdep-d6ca3c.c
clang: note: diagnostic msg: /tmp/fixdep-d6ca3c.sh
clang: note: diagnostic msg: 

fixdep-d6ca3c.c.txt
fixdep-d6ca3c.sh.txt

@ms178
Copy link
Author

ms178 commented Jan 22, 2025

After some further experiments, I am now fairly confident that BOLT or the BOLT extra patches broke my Clang/LLD binaries as I cannot reproduce the issue reported here and upstream any longer with the LTO+PGOed binaries. As this is most likely a toolchain and not a Clang/Kernel-related issue, shall I close this one in favor of further discussions in the LLVM upstream issue?

@nathanchance
Copy link
Member

Yes, I would recommend bisecting that series to see which patch causes it then working with the author to make sure it gets fixed before merging into LLVM upstream.

@ptr1337
Copy link
Member

ptr1337 commented Jan 22, 2025

It also looks like there are a bunch of vectorizing flags in the command, presumably those come from CachyOS as well? Is there any way to see everything that they enable because those certainly seem related for reproducing?

cc @ptr1337

No, this build and flags are not passed by us. ms178 manually patches the Kbuild/Makefile and adds these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler crash This bug makes Clang crash, emitting a backtrace Extra flags The use of additional, non-standard CFLAGS causes this issue Reported upstream This bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.
Projects
None yet
Development

No branches or pull requests

4 participants