llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.12k stars 11.61k forks source link

[LoongArch] Assertion failure while compiling with rustc #109901

Closed heiher closed 2 hours ago

heiher commented 2 hours ago

Reproduce:

git clone --recursive https://github.com/rust-lang/rust
cd rust
./src/ci/docker/run.sh dist-loongarch64-linux

Expected result:

Build successful.

Unexpected result:

rustc: /checkout/src/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::IntegerType, From = const llvm::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Backtrace

#0  0x00007ffff10969fc in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff1042476 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff10287f3 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007ffff102871b in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007ffff1039e96 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00007fffed9a4776 in llvm::LoongArchTargetLowering::shouldInsertFencesForAtomic(llvm::Instruction const*) const ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM.so.19.1-rust-1.83.0-nightly
#6  0x00007fffef76ab79 in (anonymous namespace)::AtomicExpandImpl::run(llvm::Function&, llvm::TargetMachine const*) [clone .warm] ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM.so.19.1-rust-1.83.0-nightly
#7  0x00007fffeecd5258 in (anonymous namespace)::AtomicExpandLegacy::runOnFunction(llvm::Function&) [clone .llvm.15884416701431989509] ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM.so.19.1-rust-1.83.0-nightly
#8  0x00007fffeecd1a0e in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM.so.19.1-rust-1.83.0-nightly
#9  0x00007fffeecd0636 in llvm::FPPassManager::runOnModule(llvm::Module&) () from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM.so.19.1-rust-1.83.0-nightly
#10 0x00007fffef455850 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM.so.19.1-rust-1.83.0-nightly
#11 0x00007ffff258d506 in LLVMRustWriteOutputFile () from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-a244707a960eef48.so
#12 0x00007ffff250ba0b in rustc_codegen_llvm::back::write::write_output_file ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-a244707a960eef48.so
#13 0x00007ffff2511133 in _RNvNtNtCs5C9g8sXSnH4_18rustc_codegen_llvm4back5write7codegen.llvm.9587499920141260261 ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-a244707a960eef48.so
#14 0x00007ffff243d247 in rustc_codegen_ssa::back::write::finish_intra_module_work::<rustc_codegen_llvm::LlvmCodegenBackend> ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-a244707a960eef48.so
#15 0x00007ffff243ea3f in std::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::spawn_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#0}, ()>::{closure#0}, ()> ()
   from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-a244707a960eef48.so
#16 0x00007ffff2500660 in <<std::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::spawn_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#0}, ()>::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} () from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-a244707a960eef48.so
#17 0x00007ffff133f335 in std::sys::pal::unix::thread::Thread::new::thread_start () from /checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/libstd-49bd04fd90cc2f7c.so
heiher commented 2 hours ago

Resolved by: https://github.com/llvm/llvm-project/commit/63267ca9016aa334b329aa408716456b4e3799c8

This patch should be backported to release 19.x.

heiher commented 6 minutes ago

release 19.x: https://github.com/llvm/llvm-project/pull/109915