-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
Have a #![no_std]
lib crate and then another #![no_std]
binary crate, attempt to link them together.
// foo/no_std_lib/lib.rs
#![no_std]
#![feature(lang_items)]
#[lang = "start"]
fn lang_start() {}
#[panic_handler]
fn panic(_: &::core::panic::PanicInfo) -> ! {loop {}}
// foo/app/main.rs
#![no_std]
extern crate no_std_lib;
fn main() {}
// foo/app/Cargo.toml
[dependencies]
"no_std_lib" = { path = "../no_std_lib" }
// foo/Cargo.toml
...
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
Changing app from a binary to a library (so linking two libraries) doesn't cause the error.
Full repo for repro: https://github.com/mikegedelman/rust-no-std-ice
Meta
rustc --version --verbose
:
rustc 1.52.0-nightly (caca2121f 2021-03-05)
binary: rustc
commit-hash: caca2121ffe4cb47d8ea2d9469c493995f57e0b5
commit-date: 2021-03-05
host: x86_64-apple-darwin
release: 1.52.0-nightly
LLVM version: 12.0.0
Error output
-> % cargo build
Compiling no_std_lib v0.0.1 (/Users/mgedelman/projects/break_rust/no_std_lib)
Compiling app v0.0.1 (/Users/mgedelman/projects/break_rust/app)
error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:1153:17: get_optimized_mir: missing MIR for `DefId(4:14 ~ no_std_lib[cfa6]::lang_start)`
thread 'rustc' panicked at 'Box<Any>', /rustc/caca2121ffe4cb47d8ea2d9469c493995f57e0b5/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: 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: rustc 1.52.0-nightly (caca2121f 2021-03-05) running on x86_64-apple-darwin
note: compiler flags: -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [optimized_mir] optimizing MIR for `no_std_lib::lang_start`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error
error: could not compile `app`
Backtrace
thread 'rustc' panicked at 'Box<Any>', /rustc/caca2121ffe4cb47d8ea2d9469c493995f57e0b5/library/std/src/panic.rs:59:5
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::bug
3: rustc_errors::Handler::bug
4: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
5: rustc_middle::ty::context::tls::with_opt::{{closure}}
6: rustc_middle::ty::context::tls::with_opt
7: rustc_middle::util::bug::opt_span_bug_fmt
8: rustc_middle::util::bug::bug_fmt
9: rustc_metadata::rmeta::decoder::<impl rustc_metadata::creader::CrateMetadataRef>::get_optimized_mir::{{closure}}
10: rustc_metadata::rmeta::decoder::<impl rustc_metadata::creader::CrateMetadataRef>::get_optimized_mir
11: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::optimized_mir
12: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
14: rustc_data_structures::stack::ensure_sufficient_stack
15: rustc_query_system::query::plumbing::force_query_with_job
16: rustc_query_system::query::plumbing::get_query_impl
17: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::optimized_mir
18: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir
19: rustc_mir::monomorphize::collector::collect_neighbours
20: rustc_mir::monomorphize::collector::collect_items_rec
21: rustc_session::utils::<impl rustc_session::session::Session>::time
22: rustc_mir::monomorphize::collector::collect_crate_mono_items
23: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
24: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::collect_and_partition_mono_items>::compute
25: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
27: rustc_data_structures::stack::ensure_sufficient_stack
28: rustc_query_system::query::plumbing::force_query_with_job
29: rustc_query_system::query::plumbing::get_query_impl
30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
31: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
32: rustc_interface::passes::QueryContext::enter
33: rustc_interface::queries::Queries::ongoing_codegen
34: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
35: rustc_span::with_source_map
36: rustc_interface::interface::create_compiler_and_run
37: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: 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: rustc 1.52.0-nightly (caca2121f 2021-03-05) running on x86_64-apple-darwin
note: compiler flags: -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [optimized_mir] optimizing MIR for `no_std_lib::lang_start`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.