Skip to content

Rename symbols rather than add symbol aliases for EIIs when possible#159843

Draft
bjorn3 wants to merge 4 commits into
rust-lang:mainfrom
bjorn3:eii_using_symbol_rename
Draft

Rename symbols rather than add symbol aliases for EIIs when possible#159843
bjorn3 wants to merge 4 commits into
rust-lang:mainfrom
bjorn3:eii_using_symbol_rename

Conversation

@bjorn3

@bjorn3 bjorn3 commented Jul 24, 2026

Copy link
Copy Markdown
Member

The symbol name of the EII impl will now get changed to match the EII decl whenever there is no default impl. This already works across all backends and targets unlike the weak symbol aliases that we currently use. When there is a default impl, we will still use weak symbol aliases.

Based on #159326 and #159374

bjorn3 added 4 commits July 24, 2026 11:53
This allows implementing EIIs that don't have a default impl without the
involvement of symbol aliases by simply changing the mangled symbol name
of the implementation, which would make them trivially compatible with
all backends and targets. This change will be left to a followup PR.
This reduces the amount of special casing #[no_mangle] needs in the rest
of the compiler.
The symbol name of the EII impl will now get changed to match the EII
decl whenever there is no default impl. This already works across all
backends and targets unlike the weak symbol aliases that we currently
use. When there is a default impl, we will still use weak symbol
aliases.
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. labels Jul 24, 2026
@bjorn3 bjorn3 mentioned this pull request Jul 24, 2026
3 tasks
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   9:     0xff1ef2fc8330 - std[faaa1722a6c2e07a]::panicking::default_hook::{closure#0}
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/panicking.rs:292:27
  10:     0xff1ef2fe7db4 - std[faaa1722a6c2e07a]::panicking::default_hook
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/panicking.rs:319:9
  11:     0xff1eef6d83f4 - std[faaa1722a6c2e07a]::panicking::update_hook::<alloc[7220a3968fb26a7c]::boxed::Box<rustc_driver_impl[7b725a2f7bf77b9a]::install_ice_hook::{closure#1}>>::{closure#0}
  12:     0xff1ef2fe8130 - <alloc[7220a3968fb26a7c]::boxed::Box<dyn for<'a, 'b> core[a3bed6fa7f8910de]::ops::function::Fn<(&'a std[faaa1722a6c2e07a]::panic::PanicHookInfo<'b>,), Output = ()> + core[a3bed6fa7f8910de]::marker::Sync + core[a3bed6fa7f8910de]::marker::Send> as core[a3bed6fa7f8910de]::ops::function::Fn<(&std[faaa1722a6c2e07a]::panic::PanicHookInfo,)>>::call
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/alloc/src/boxed.rs:2333:9
  13:     0xff1ef2fe8130 - std[faaa1722a6c2e07a]::panicking::panic_with_hook
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/panicking.rs:823:13
  14:     0xff1ef2fc83f4 - std[faaa1722a6c2e07a]::panicking::panic_handler::{closure#0}
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/panicking.rs:681:13
  15:     0xff1ef2fc0520 - std[faaa1722a6c2e07a]::sys::backtrace::__rust_end_short_backtrace::<std[faaa1722a6c2e07a]::panicking::panic_handler::{closure#0}, !>
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/sys/backtrace.rs:182:18
  16:     0xff1ef2fc9c48 - __rustc[a25a212e9fab2cd3]::rust_begin_unwind
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/panicking.rs:679:5
  17:     0xff1eef639bfc - core[a3bed6fa7f8910de]::panicking::panic_fmt
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/core/src/panicking.rs:80:14
  18:     0xff1eef639bd4 - core[a3bed6fa7f8910de]::panicking::panic
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/core/src/panicking.rs:150:5
  19:     0xff1eef639908 - core[a3bed6fa7f8910de]::option::unwrap_failed
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/core/src/option.rs:2251:5
  20:     0xff1ef1447d84 - rustc_lint[5d8010d553e09163]::foreign_modules::name_of_extern_decl
  21:     0xff1ef14498d0 - rustc_lint[5d8010d553e09163]::foreign_modules::clashing_extern_declarations
  22:     0xff1ef121a7a4 - rustc_query_impl[75f7ded4abce79f5]::query_impl::clashing_extern_declarations::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0xff1ef10bbde8 - <std[faaa1722a6c2e07a]::thread::local::LocalKey<core[a3bed6fa7f8910de]::cell::Cell<*const ()>>>::with::<rustc_middle[ff4e3d3446a5eafc]::ty::context::tls::enter_context<rustc_query_impl[75f7ded4abce79f5]::execution::execute_job_non_incr<rustc_middle[ff4e3d3446a5eafc]::query::caches::SingleCache<rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>>::{closure#0}, rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>::{closure#0}, rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>
  24:     0xff1ef0fced88 - rustc_query_impl[75f7ded4abce79f5]::execution::try_execute_query::<rustc_middle[ff4e3d3446a5eafc]::query::caches::SingleCache<rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>, false>
  25:     0xff1ef12d5bac - rustc_query_impl[75f7ded4abce79f5]::query_impl::clashing_extern_declarations::execute_query_non_incr::__rust_end_short_backtrace
  26:     0xff1eef931dd4 - rustc_interface[5e735bd0272d27ec]::passes::analysis::{closure#0}::{closure#0}::{closure#3}
  27:     0xff1ef2f77f20 - rustc_data_structures[81c4a32698bb0a71]::sync::parallel::par_fns
  28:     0xff1eef932848 - rustc_interface[5e735bd0272d27ec]::passes::analysis::{closure#0}::{closure#0}
  29:     0xff1ef2f77f20 - rustc_data_structures[81c4a32698bb0a71]::sync::parallel::par_fns
  30:     0xff1eef92c554 - <rustc_session[83eec55e1416d174]::session::Session>::time::<(), rustc_interface[5e735bd0272d27ec]::passes::analysis::{closure#0}>
  31:     0xff1eef8a8370 - rustc_interface[5e735bd0272d27ec]::passes::analysis
  32:     0xff1ef128be9c - rustc_query_impl[75f7ded4abce79f5]::query_impl::analysis::invoke_provider_fn::__rust_begin_short_backtrace
  33:     0xff1ef10bbde8 - <std[faaa1722a6c2e07a]::thread::local::LocalKey<core[a3bed6fa7f8910de]::cell::Cell<*const ()>>>::with::<rustc_middle[ff4e3d3446a5eafc]::ty::context::tls::enter_context<rustc_query_impl[75f7ded4abce79f5]::execution::execute_job_non_incr<rustc_middle[ff4e3d3446a5eafc]::query::caches::SingleCache<rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>>::{closure#0}, rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>::{closure#0}, rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>
  34:     0xff1ef0fced88 - rustc_query_impl[75f7ded4abce79f5]::execution::try_execute_query::<rustc_middle[ff4e3d3446a5eafc]::query::caches::SingleCache<rustc_middle[ff4e3d3446a5eafc]::query::erase::ErasedData<[u8; 0usize]>>, false>
  35:     0xff1ef12d6314 - rustc_query_impl[75f7ded4abce79f5]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  36:     0xff1eef6b6ae8 - <std[faaa1722a6c2e07a]::thread::local::LocalKey<core[a3bed6fa7f8910de]::cell::Cell<*const ()>>>::with::<rustc_middle[ff4e3d3446a5eafc]::ty::context::tls::enter_context<<rustc_middle[ff4e3d3446a5eafc]::ty::context::GlobalCtxt>::enter<rustc_interface[5e735bd0272d27ec]::passes::create_and_enter_global_ctxt<core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>, rustc_driver_impl[7b725a2f7bf77b9a]::run_compiler::{closure#0}::{closure#1}>::{closure#2}, core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>>::{closure#1}, core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>>::{closure#0}, core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>>
  37:     0xff1eef665844 - <rustc_middle[ff4e3d3446a5eafc]::ty::context::TyCtxt>::create_global_ctxt::<core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>, rustc_interface[5e735bd0272d27ec]::passes::create_and_enter_global_ctxt<core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>, rustc_driver_impl[7b725a2f7bf77b9a]::run_compiler::{closure#0}::{closure#1}>::{closure#2}>
  38:     0xff1eef705a00 - rustc_interface[5e735bd0272d27ec]::passes::create_and_enter_global_ctxt::<core[a3bed6fa7f8910de]::option::Option<rustc_interface[5e735bd0272d27ec]::queries::Linker>, rustc_driver_impl[7b725a2f7bf77b9a]::run_compiler::{closure#0}::{closure#1}>
  39:     0xff1eef6a2b24 - std[faaa1722a6c2e07a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5e735bd0272d27ec]::util::run_in_thread_with_globals<rustc_interface[5e735bd0272d27ec]::util::run_in_thread_pool_with_globals<rustc_interface[5e735bd0272d27ec]::interface::run_compiler<(), rustc_driver_impl[7b725a2f7bf77b9a]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0xff1eef6ced28 - <std[faaa1722a6c2e07a]::thread::lifecycle::spawn_unchecked<rustc_interface[5e735bd0272d27ec]::util::run_in_thread_with_globals<rustc_interface[5e735bd0272d27ec]::util::run_in_thread_pool_with_globals<rustc_interface[5e735bd0272d27ec]::interface::run_compiler<(), rustc_driver_impl[7b725a2f7bf77b9a]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a3bed6fa7f8910de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0xff1ef2ff3058 - <alloc[7220a3968fb26a7c]::boxed::Box<dyn core[a3bed6fa7f8910de]::ops::function::FnOnce<(), Output = ()> + core[a3bed6fa7f8910de]::marker::Send> as core[a3bed6fa7f8910de]::ops::function::FnOnce<()>>::call_once
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/alloc/src/boxed.rs:2319:9
  42:     0xff1ef2ff3058 - <std[faaa1722a6c2e07a]::sys::thread::unix::Thread>::new::thread_start
                               at /rustc/08d5b675a9b2abdca5e2fe4eabe0e07bbda15d49/library/std/src/sys/thread/unix.rs:123:17
  43:     0xff1eeea8b9f4 - <unknown>
  44:     0xff1eeeaf700c - <unknown>
---

note: compiler flags: --crate-type bin

query stack during panic:
#0 [clashing_extern_declarations] checking `extern fn` declarations are compatible
#1 [analysis] running analysis passes on crate `rust_out`
end of query stack
warning: 1 warning emitted

Couldn't compile the test.

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants