rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
94.89k stars 12.23k forks source link

ICE using `cranelift` targeting `gnux32` #118739

Open Nemo157 opened 7 months ago

Nemo157 commented 7 months ago

Code

> cargo new foo && cd foo
     Created binary (application) `foo` package

> cargo build --target x86_64-unknown-linux-gnux32 --config=profile.dev.codegen-backend='"cranelift"' -Zcodegen-backend
   Compiling foo v0.1.0 (/tmp/scratch.rust-unwrapped.2023-12-08T13-12.lofrxc/foo)
thread 'rustc' panicked at src/lib.rs:144:9:
assertion `left == right` failed
  left: types::I32
 right: types::I64
stack backtrace:
   0: rust_begin_unwind
             at /rustc/503e129328080e924c0ddfca6abf4c2812580102/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/503e129328080e924c0ddfca6abf4c2812580102/library/core/src/panicking.rs:72:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<cranelift_codegen::ir::types::Type, cranelift_codegen::ir::types::Type>
   4: rustc_codegen_cranelift::driver::aot::module_codegen::{closure#0}
   5: rustc_codegen_cranelift::driver::aot::module_codegen
   6: <rustc_middle::dep_graph::DepsType as rustc_query_system::dep_graph::Deps>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::DepsType>>::with_task<rustc_middle::ty::context::TyCtxt, (rustc_codegen_cranelift::config::BackendConfig, alloc::sync::Arc<rustc_codegen_cranelift::global_asm::GlobalAsmConfig>, rustc_span::symbol::Symbol, rustc_codegen_cranelift::concurrency_limiter::ConcurrencyLimiterToken), rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>::{closure#0}::{closure#0}, rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>
   7: rustc_codegen_cranelift::driver::aot::run_aot
   8: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
   9: rustc_interface::passes::start_codegen
  10: <rustc_interface::queries::Queries>::codegen_and_build_linker
  11: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `/tmp/scratch.rust-unwrapped.2023-12-08T13-12.lofrxc/foo/rustc-ice-2023-12-08T12_13_05-2544016.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -Z codegen-backend=cranelift -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `foo` (bin "foo")

Meta

rustc 1.76.0-nightly (503e12932 2023-12-07)
binary: rustc
commit-hash: 503e129328080e924c0ddfca6abf4c2812580102
commit-date: 2023-12-07
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
bjorn3 commented 7 months ago

I'm not sure if Cranelift itself supports the x32 abi.

Nemo157 commented 7 months ago

Yeah, I wouldn't be disappointed if the solution was to just explicitly give an error; I just happened to be using cranelift by default and wanted to test a build with gnux32.

bjorn3 commented 1 month ago

It no longer ICEs but I am pretty sure it is codegened incorrectly by cranelift now.

Edit: opened https://github.com/bytecodealliance/wasmtime/issues/8694