Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: Unexpected def kind GlobalAsm #137471

Closed
matthiaskrgr opened this issue Feb 23, 2025 · 0 comments · Fixed by #137502
Closed

ICE: Unexpected def kind GlobalAsm #137471

matthiaskrgr opened this issue Feb 23, 2025 · 0 comments · Fixed by #137502
Assignees
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

//@compile-flags: --emit=mir
core::arch::global_asm!(
    r#"
    .global foo
    .global _foo
foo:
_foo:
    ret
"#
);

fn main() {}

#[cfg(not)]
fn main() {}

original:

//@ run-pass
//@ needs-asm-support

#![feature(naked_functions)]
#![allow(dead_code)]

#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
core::arch::global_asm!(
    r#"
    .global foo
    .global _foo
foo:
_foo:
    ret
"#
);

extern "C" {
    fn foo();
}

#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
fn main() {
    unsafe {
        foo();
    }
}

#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
fn main() {}

This worked before #137180

Version information

rustc 1.87.0-nightly (bca5f37cb 2025-02-23)
binary: rustc
commit-hash: bca5f37cbded0db8d37414bb08c4b101a5f26d36
commit-date: 2025-02-23
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

}
(DefKind::Static { safety: _, mutability: hir::Mutability::Mut, nested: false }, _) => {
write!(w, "static mut ")?
}
(_, _) if is_function => write!(w, "fn ")?,
(DefKind::AnonConst | DefKind::InlineConst, _) => {} // things like anon const, not an item
_ => bug!("Unexpected def kind {:?}", kind),
}
ty::print::with_forced_impl_filename_line! {
// see notes on #41697 elsewhere
write!(w, "{}", tcx.def_path_str(def_id))?
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --emit=mir

Program output

error: internal compiler error: compiler/rustc_middle/src/mir/pretty.rs:656:14: Unexpected def kind GlobalAsm


thread 'rustc' panicked at compiler/rustc_middle/src/mir/pretty.rs:656:14:
Box<dyn Any>
stack backtrace:
   0:     0x72dabd57d024 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb2766718346e8914
   1:     0x72dabdc162ec - core::fmt::write::h9a1616cb06c0cb0c
   2:     0x72dabec69851 - std::io::Write::write_fmt::ha495c1f1db9a43ed
   3:     0x72dabd57ce82 - std::sys::backtrace::BacktraceLock::print::hfcfc21e91f78122e
   4:     0x72dabd57f68e - std::panicking::default_hook::{{closure}}::hdbc3741f9d3f7a84
   5:     0x72dabd57f264 - std::panicking::default_hook::hc24bc002e7741aa1
   6:     0x72dabc6de2d7 - std[aff040118bb958da]::panicking::update_hook::<alloc[67af6a9cecfd7ba8]::boxed::Box<rustc_driver_impl[301a9b8b79b48566]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x72dabd57ff03 - std::panicking::rust_panic_with_hook::hcb6606e9e0388155
   8:     0x72dabc719bd1 - std[aff040118bb958da]::panicking::begin_panic::<rustc_errors[ccf3a74766137fa5]::ExplicitBug>::{closure#0}
   9:     0x72dabc70dfe6 - std[aff040118bb958da]::sys::backtrace::__rust_end_short_backtrace::<std[aff040118bb958da]::panicking::begin_panic<rustc_errors[ccf3a74766137fa5]::ExplicitBug>::{closure#0}, !>
  10:     0x72dabc70dfcb - std[aff040118bb958da]::panicking::begin_panic::<rustc_errors[ccf3a74766137fa5]::ExplicitBug>
  11:     0x72dabc7235d1 - <rustc_errors[ccf3a74766137fa5]::diagnostic::BugAbort as rustc_errors[ccf3a74766137fa5]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x72dabccf4846 - rustc_middle[bff44984932adf4f]::util::bug::opt_span_bug_fmt::<rustc_span[2a04d5a35653b919]::span_encoding::Span>::{closure#0}
  13:     0x72dabccddd2a - rustc_middle[bff44984932adf4f]::ty::context::tls::with_opt::<rustc_middle[bff44984932adf4f]::util::bug::opt_span_bug_fmt<rustc_span[2a04d5a35653b919]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x72dabccddb9b - rustc_middle[bff44984932adf4f]::ty::context::tls::with_context_opt::<rustc_middle[bff44984932adf4f]::ty::context::tls::with_opt<rustc_middle[bff44984932adf4f]::util::bug::opt_span_bug_fmt<rustc_span[2a04d5a35653b919]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x72dabb0f9e20 - rustc_middle[bff44984932adf4f]::util::bug::bug_fmt
  16:     0x72dabccb5fc5 - rustc_middle[bff44984932adf4f]::mir::pretty::write_mir_intro
  17:     0x72dabccb1ace - rustc_middle[bff44984932adf4f]::mir::pretty::write_mir_pretty::{closure#0}
  18:     0x72dabccb0668 - rustc_middle[bff44984932adf4f]::mir::pretty::write_mir_pretty
  19:     0x72dabce9783c - rustc_mir_transform[235952b1afe2fde9]::dump_mir::emit_mir
  20:     0x72dabeabae05 - <rustc_interface[a6a17d2a4de965ee]::queries::Linker>::codegen_and_build_linker
  21:     0x72dabed4e1ef - rustc_interface[a6a17d2a4de965ee]::passes::create_and_enter_global_ctxt::<core[25dd51937c36d244]::option::Option<rustc_interface[a6a17d2a4de965ee]::queries::Linker>, rustc_driver_impl[301a9b8b79b48566]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  22:     0x72dabed41a60 - rustc_interface[a6a17d2a4de965ee]::interface::run_compiler::<(), rustc_driver_impl[301a9b8b79b48566]::run_compiler::{closure#0}>::{closure#1}
  23:     0x72dabeb7eedc - std[aff040118bb958da]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a6a17d2a4de965ee]::util::run_in_thread_with_globals<rustc_interface[a6a17d2a4de965ee]::util::run_in_thread_pool_with_globals<rustc_interface[a6a17d2a4de965ee]::interface::run_compiler<(), rustc_driver_impl[301a9b8b79b48566]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x72dabeb7f300 - <<std[aff040118bb958da]::thread::Builder>::spawn_unchecked_<rustc_interface[a6a17d2a4de965ee]::util::run_in_thread_with_globals<rustc_interface[a6a17d2a4de965ee]::util::run_in_thread_pool_with_globals<rustc_interface[a6a17d2a4de965ee]::interface::run_compiler<(), rustc_driver_impl[301a9b8b79b48566]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[25dd51937c36d244]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x72dabeb7fceb - std::sys::pal::unix::thread::Thread::new::thread_start::h4bc285b173c402c8
  26:     0x72dab8ea370a - <unknown>
  27:     0x72dab8f27aac - <unknown>
  28:                0x0 - <unknown>

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: rustc 1.87.0-nightly (bca5f37cb 2025-02-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
end of query stack
error: aborting due to 1 previous error


@rustbot label +F-naked_functions

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 23, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-naked_functions `#![feature(naked_functions)]` labels Feb 23, 2025
@Noratrieb Noratrieb added A-pretty Area: Pretty printing (including `-Z unpretty`) requires-nightly This issue requires a nightly compiler in some way. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 23, 2025
@compiler-errors compiler-errors self-assigned this Feb 23, 2025
fmease added a commit to fmease/rust that referenced this issue Feb 26, 2025
…r-body, r=oli-obk

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 26, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 4, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: aarch64-apple
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 4, 2025
…r-body, r=oli-obk

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: aarch64-apple
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 4, 2025
…r-body, r=oli-obk

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: aarch64-apple
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 5, 2025
…r-body, r=oli-obk

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: aarch64-apple
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
compiler-errors added a commit to compiler-errors/rust that referenced this issue Mar 6, 2025
…r-body, r=oli-obk

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
Noratrieb added a commit to Noratrieb/rust that referenced this issue Mar 6, 2025
…r-body, r=oli-obk

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 6, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
try-job: x86_64-apple-2
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 6, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
try-job: x86_64-apple-2
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 7, 2025
…body, r=<try>

Don't include global asm in `mir_keys`, fix error body synthesis

r? oli-obk

Fixes rust-lang#137470
Fixes rust-lang#137471
Fixes rust-lang#137472
Fixes rust-lang#137473

try-job: test-various
try-job: x86_64-apple-2
@bors bors closed this as completed in dea1661 Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. F-naked_functions `#![feature(naked_functions)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants