Open limuy2022 opened 1 month ago
Looks like cg_clif cc @bjorn3
You are compiling for riscv64gc-unknown-none-elf. It looks like the target_lexicon crate doesn't know that the binary format for that target is ELF and instead returns that the binary format is unknown. This then results in cranelift-object returning an error that it doesn't know how to create object files for this binary format and in turn cg_clif panics as it didn't expect an error. @sunfishcode should target-lexicon return ELF as object file for all -none
targets? That is already the default when the OS is not recognized and I don't think we have any targets with an object file format other than ELF except for the wasm, windows, apple, ibm and vxworks targets all of which aren't matched by the -none
case anyway.
https://github.com/bytecodealliance/target-lexicon/pull/108 should fix this. Waiting on a new release of target-lexicon and cg_clif updating to it though.
I've now released target-lexicon 0.12.15 with https://github.com/bytecodealliance/target-lexicon/pull/108 which changes the default binary format to ELF, following the code in LLVM.
Code
min.zip
Meta
rustc --version --verbose
:Error output
Backtrace
``` Stack backtrace: 0:::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: ::with_deps::<>::with_task, 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: , 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::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: ::codegen_crate
9: rustc_interface::passes::start_codegen
10: ::codegen_and_build_linker
11: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
12: std::sys_common::backtrace::__rust_begin_short_backtrace::, 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: <::spawn_unchecked_, 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: as core::ops::function::FnOnce>::call_once
at /rustc/36153f1a4e3162f0a143c7b3e468ecb3beb0008e/library/alloc/src/boxed.rs:2063:9
15: as core::ops::function::FnOnce>::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:
18: )
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: ::with_deps::<>::with_task, 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: , 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::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: ::codegen_crate
11: rustc_interface::passes::start_codegen
12: ::codegen_and_build_linker
13: rustc_interface::interface::run_compiler::, 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
```