Skip to content

Use EII for #[panic_handler]#159016

Draft
bjorn3 wants to merge 7 commits into
rust-lang:mainfrom
bjorn3:eii_panic_handler
Draft

Use EII for #[panic_handler]#159016
bjorn3 wants to merge 7 commits into
rust-lang:mainfrom
bjorn3:eii_panic_handler

Conversation

@bjorn3

@bjorn3 bjorn3 commented Jul 9, 2026

Copy link
Copy Markdown
Member

While we can't yet use EIIs for things like the global allocator due to missing platform support, we can safely use it for #[panic_handler] as that doesn't require any object file format features. Just matching symbol names.

This gets rid of one of the two remaining weak lang items.

TODO

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 9, 2026
@bjorn3

bjorn3 commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

bjorn3 added 5 commits July 24, 2026 11:31
The only way it was possible to skip needing to declare #[panic_handler]
is using #![no_core], which is unstable anyway. Always requiring
\#[panic_handler] makes things more consistent and avoids having to
special case several MIR optimizations for the absence of #[panic_handler].
@bjorn3
bjorn3 force-pushed the eii_panic_handler branch from ecd1f4c to 2f001d2 Compare July 24, 2026 09:48

/// Attribute macro applied to a function to register it as a panic handler.
///
/// See also [`core::panic::PanicInfo`](crate::panic::PanicInfo).

@bjorn3 bjorn3 Jul 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are probably better pages to link to.

View changes since the review

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-gcc-core-tests failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] rustc_demangle test:false 2.787
[RUSTC-TIMING] object test:false 9.470
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-Wl,--version-script=<sysroot>-std/x86_64-unknown-linux-gnu/dist/build/std/f7da64f10c2aedb5/out/rustc5LxA9x/list" "-Wl,--no-undefined-version" "-m64" "<sysroot>-std/x86_64-unknown-linux-gnu/dist/build/std/f7da64f10c2aedb5/out/rustc5LxA9x/symbols.o" "<1 object files omitted>" "<sysroot>-std/x86_64-unknown-linux-gnu/dist/build/std/f7da64f10c2aedb5/out/rustc5LxA9x/rmeta.o" "<1 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_abort/056ba980b6d42ed4/out/libpanic_abort-056ba980b6d42ed4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/object/f6c29a2e86fe8978/out/libobject-f6c29a2e86fe8978.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/memchr/d3f79e30eaff302b/out/libmemchr-d3f79e30eaff302b.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/addr2line/522083117fe6cf26/out/libaddr2line-522083117fe6cf26.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/gimli/a87847ad504deb36/out/libgimli-a87847ad504deb36.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/cfg-if/4eda1be19abc422c/out/libcfg_if-4eda1be19abc422c.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-demangle/b444b69d3514e1cc/out/librustc_demangle-b444b69d3514e1cc.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/std_detect/e36cfc7a8531723f/out/libstd_detect-e36cfc7a8531723f.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/hashbrown/fbce72e94d5a4778/out/libhashbrown-fbce72e94d5a4778.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-std-workspace-alloc/9aac443049ed8b50/out/librustc_std_workspace_alloc-9aac443049ed8b50.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/miniz_oxide/70dd8113784b4192/out/libminiz_oxide-70dd8113784b4192.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/adler2/c49581c4f28dd5d5/out/libadler2-c49581c4f28dd5d5.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/unwind/bec37a19a74bcf55/out/libunwind-bec37a19a74bcf55.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/libc/040e9699da8da62a/out/liblibc-040e9699da8da62a.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-std-workspace-core/d1e758262c9a2d92/out/librustc_std_workspace_core-d1e758262c9a2d92.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/alloc/647734819e827a9e/out/liballoc-647734819e827a9e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/core/0086f05a15241247/out/libcore-0086f05a15241247.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/compiler_builtins/8fcc40f19e2b2503/out/libcompiler_builtins-8fcc40f19e2b2503.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "<sysroot>-std/x86_64-unknown-linux-gnu/dist/build/std/f7da64f10c2aedb5/out/rustc5LxA9x/raw-dylibs" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>-std/x86_64-unknown-linux-gnu/dist/build/compiler_builtins/6589fb165378686f/out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "<sysroot>-std/x86_64-unknown-linux-gnu/dist/build/std/f7da64f10c2aedb5/out/libstd-f7da64f10c2aedb5.so" "-shared" "-Wl,-soname=libstd-f7da64f10c2aedb5.so" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: version script assignment of 'global' to symbol '_RNvNtCsbiUOxexDKIi_4core9panicking10panic_impl' failed: symbol not defined
          collect2: error: ld returned 1 exit status
          

[RUSTC-TIMING] std test:false 44.329
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `std` (lib) due to 1 previous error

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name std --edition=2024 library/std/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type dylib --crate-type rlib --emit=dep-info,metadata,link -Z embed-metadata=no -C prefer-dynamic -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 --warn=unexpected_cfgs --check-cfg 'cfg(feature, values(any()))' --check-cfg 'cfg(target_has_reliable_f16)' --check-cfg 'cfg(target_has_reliable_f16_math)' --check-cfg 'cfg(target_has_reliable_f128)' --check-cfg 'cfg(target_has_reliable_f128_math)' -Cembed-bitcode=yes -Zunstable-options -Cforce-frame-pointers=non-leaf -C overflow-checks=on --cfg 'feature="addr2line"' --cfg 'feature="backtrace"' --cfg 'feature="compiler-builtins-c"' --cfg 'feature="miniz_oxide"' --cfg 'feature="object"' --cfg 'feature="panic-unwind"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("addr2line", "backtrace", "backtrace-trace-only", "compiler-builtins-c", "compiler-builtins-mem", "debug_refcell", "llvm-libunwind", "llvm_enzyme", "miniz_oxide", "object", "optimize_for_size", "panic-unwind", "system-llvm-libunwind", "windows_raw_dylib"))' -C metadata=f3e0d2ae3859d890 -C extra-filename=-f7da64f10c2aedb5 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/std/f7da64f10c2aedb5/out --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/addr2line/522083117fe6cf26/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/adler2/c49581c4f28dd5d5/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/alloc/647734819e827a9e/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/cfg-if/4eda1be19abc422c/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/compiler_builtins/8fcc40f19e2b2503/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/core/0086f05a15241247/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/gimli/a87847ad504deb36/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/hashbrown/fbce72e94d5a4778/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/libc/040e9699da8da62a/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/memchr/d3f79e30eaff302b/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/miniz_oxide/70dd8113784b4192/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/object/f6c29a2e86fe8978/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_abort/056ba980b6d42ed4/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_unwind/2815104dcc7cde70/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-demangle/b444b69d3514e1cc/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-std-workspace-alloc/9aac443049ed8b50/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-std-workspace-core/d1e758262c9a2d92/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/std_detect/e36cfc7a8531723f/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/unwind/bec37a19a74bcf55/out -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/dist/build/std/f7da64f10c2aedb5/out --extern 'priv:addr2line=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/addr2line/522083117fe6cf26/out/libaddr2line-522083117fe6cf26.rlib' --extern 'priv:addr2line=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/addr2line/522083117fe6cf26/out/libaddr2line-522083117fe6cf26.rmeta' --extern alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/alloc/647734819e827a9e/out/liballoc-647734819e827a9e.rlib --extern alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/alloc/647734819e827a9e/out/liballoc-647734819e827a9e.rmeta --extern 'priv:cfg_if=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/cfg-if/4eda1be19abc422c/out/libcfg_if-4eda1be19abc422c.rlib' --extern 'priv:cfg_if=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/cfg-if/4eda1be19abc422c/out/libcfg_if-4eda1be19abc422c.rmeta' --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/core/0086f05a15241247/out/libcore-0086f05a15241247.rlib --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/core/0086f05a15241247/out/libcore-0086f05a15241247.rmeta --extern 'priv:hashbrown=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/hashbrown/fbce72e94d5a4778/out/libhashbrown-fbce72e94d5a4778.rlib' --extern 'priv:hashbrown=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/hashbrown/fbce72e94d5a4778/out/libhashbrown-fbce72e94d5a4778.rmeta' --extern libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/libc/040e9699da8da62a/out/liblibc-040e9699da8da62a.rlib --extern libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/libc/040e9699da8da62a/out/liblibc-040e9699da8da62a.rmeta --extern 'priv:miniz_oxide=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/miniz_oxide/70dd8113784b4192/out/libminiz_oxide-70dd8113784b4192.rlib' --extern 'priv:miniz_oxide=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/miniz_oxide/70dd8113784b4192/out/libminiz_oxide-70dd8113784b4192.rmeta' --extern 'priv:object=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/object/f6c29a2e86fe8978/out/libobject-f6c29a2e86fe8978.rlib' --extern 'priv:object=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/object/f6c29a2e86fe8978/out/libobject-f6c29a2e86fe8978.rmeta' --extern 'priv:panic_abort=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_abort/056ba980b6d42ed4/out/libpanic_abort-056ba980b6d42ed4.rlib' --extern 'priv:panic_abort=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_abort/056ba980b6d42ed4/out/libpanic_abort-056ba980b6d42ed4.rmeta' --extern 'priv:panic_unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_unwind/2815104dcc7cde70/out/libpanic_unwind-2815104dcc7cde70.rlib' --extern 'priv:panic_unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/panic_unwind/2815104dcc7cde70/out/libpanic_unwind-2815104dcc7cde70.rmeta' --extern 'priv:rustc_demangle=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-demangle/b444b69d3514e1cc/out/librustc_demangle-b444b69d3514e1cc.rlib' --extern 'priv:rustc_demangle=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/rustc-demangle/b444b69d3514e1cc/out/librustc_demangle-b444b69d3514e1cc.rmeta' --extern std_detect=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/std_detect/e36cfc7a8531723f/out/libstd_detect-e36cfc7a8531723f.rlib --extern std_detect=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/std_detect/e36cfc7a8531723f/out/libstd_detect-e36cfc7a8531723f.rmeta --extern 'priv:unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/unwind/bec37a19a74bcf55/out/libunwind-bec37a19a74bcf55.rlib' --extern 'priv:unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/unwind/bec37a19a74bcf55/out/libunwind-bec37a19a74bcf55.rmeta' -Z unstable-options -Zannotate-moves '--check-cfg=cfg(feature,values(any()))' -Zunstable-options -Zmacro-backtrace -Csplit-debuginfo=off -Cprefer-dynamic -Zinline-mir -Zinline-mir-preserve-debug -Zmir_strip_debuginfo=locals-in-tiny-functions -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Alinker-messages '-Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/")' -Cpanic=abort -Zpanic-abort-tests -Z binary-dep-depinfo -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/dist/build/compiler_builtins/6589fb165378686f/out --cfg backtrace_in_libstd --check-cfg 'cfg(netbsd10)' --check-cfg 'cfg(no_global_oom_handling)' --check-cfg 'cfg(restricted_std)' --check-cfg 'cfg(backtrace_in_libstd)' --check-cfg 'cfg(vxworks_lt_25_09)'` (exit status: 254)
Bootstrap failed while executing `--stage 1 test library/coretests`
Currently active steps:
test::Crate { build_compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, mode: Std, crates: ["coretests"] } at src/bootstrap/src/core/build_steps/test.rs:3393
compile::Std { target: x86_64-unknown-linux-gnu, build_compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: false }, crates: [], force_recompile: true, extra_rust_args: [], is_for_mir_opt_tests: false } at src/bootstrap/src/core/build_steps/test.rs:3411
Build completed unsuccessfully in 0:10:34

Important

For more information how to resolve CI failures of this job, visit this link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants