Skip to content

Nightly rustc panic when compiling a simple no_std program #125545

Closed
@limuy2022

Description

@limuy2022

Code

min.zip

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (36153f1a4 2024-05-24)
binary: rustc
commit-hash: 36153f1a4e3162f0a143c7b3e468ecb3beb0008e
commit-date: 2024-05-24
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

thread 'rustc' panicked at src/driver/aot.rs:302:89:
called `Result::unwrap()` on an `Err` value: Backend(binary format is unknown

Backtrace

Stack backtrace:
   0: <anyhow::Error>::msg::<&str>
   1: rustc_codegen_cranelift::driver::aot::make_module
   2: rustc_codegen_cranelift::driver::aot::module_codegen::{closure#0}
   3: rustc_codegen_cranelift::driver::aot::module_codegen
   4: <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>
   5: rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}
   6: <core::iter::adapters::filter_map::FilterMap<alloc::vec::into_iter::IntoIter<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_data_structures::sync::parallel::enabled::par_map<(usize, &rustc_middle::mir::mono::CodegenUnit), alloc::vec::Vec<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#1}> as core::iter::traits::iterator::Iterator>::next
   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#1}
  12: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  13: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#2} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  14: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/alloc/src/boxed.rs:2063:9
  15: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/alloc/src/boxed.rs:2063:9
  16: std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/sys/pal/unix/thread.rs:108:17
  17: <unknown>
  18: <unknown>)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/core/src/result.rs:1658:5
   3: rustc_codegen_cranelift::driver::aot::make_module
   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::{closure#3}::{closure#0}
   8: <core::iter::adapters::filter_map::FilterMap<alloc::vec::into_iter::IntoIter<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_data_structures::sync::parallel::enabled::par_map<(usize, &rustc_middle::mir::mono::CodegenUnit), alloc::vec::Vec<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#1}> as core::iter::traits::iterator::Iterator>::next
   9: rustc_codegen_cranelift::driver::aot::run_aot
  10: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  11: rustc_interface::passes::start_codegen
  12: <rustc_interface::queries::Queries>::codegen_and_build_linker
  13: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
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 make sure that you have updated to the latest nightly

note: please attach the file at `/home/limuy/桌面/EmperorOS/rustc-ice-2024-05-25T12_29_13-33604.txt` to your bug report

note: compiler flags: --crate-type lib -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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-craneliftThings relevant to the [future] cranelift backendC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-bare-metalTarget: Rust without an operating systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions