Skip to content

Ensure we codegen the main fn #144094

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Jul 17, 2025

This needs a test. The best test I've come up with for this scenario is to check that this works with an imported main:

RUSTFLAGS=-Zcross-crate-inline-threshold=yes cargo +stage1 b --release -Zbuild-std --target=x86_64-unknown-linux-gnu

Because that's the most codegen delay that's possible.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 17, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 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] wit_component test:false 26.054
   Compiling wasm-component-ld-wrapper v0.1.0 (/checkout/src/tools/wasm-component-ld)

thread 'rustc' panicked at compiler/rustc_monomorphize/src/collector.rs:461:13:
assertion failed: tcx.should_codegen_locally(instance)
stack backtrace:
   0:     0xffcae6020134 - std::backtrace_rs::backtrace::libunwind::trace::hbeb8ff6f1dc1cc87
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
   1:     0xffcae6020134 - std::backtrace_rs::backtrace::trace_unsynchronized::hcbd64546bb0bc534
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
---
   9:     0xffcae6023a18 - std::panicking::default_hook::{{closure}}::haac60c33ad8953eb
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:300:27
  10:     0xffcae6023874 - std::panicking::default_hook::hfbe61bc0eb59097c
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:327:9
  11:     0xffcae2602c2c - <alloc[cf75e2ab30ac120f]::boxed::Box<rustc_driver_impl[185ce98be39526fb]::install_ice_hook::{closure#1}> as core[86de0986de23a55d]::ops::function::Fn<(&dyn for<'a, 'b> core[86de0986de23a55d]::ops::function::Fn<(&'a std[57c45f57ec3c24e5]::panic::PanicHookInfo<'b>,), Output = ()> + core[86de0986de23a55d]::marker::Sync + core[86de0986de23a55d]::marker::Send, &std[57c45f57ec3c24e5]::panic::PanicHookInfo)>>::call
  12:     0xffcae602448c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1caa90323394741e
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/alloc/src/boxed.rs:1980:9
  13:     0xffcae602448c - std::panicking::rust_panic_with_hook::h448ca412e27acd2b
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:841:13
  14:     0xffcae6024164 - std::panicking::begin_panic_handler::{{closure}}::he6c71f258db522c4
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:699:13
  15:     0xffcae6020630 - std::sys::backtrace::__rust_end_short_backtrace::hf8d7a4365255b145
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/sys/backtrace.rs:168:18
  16:     0xffcae6023e70 - __rustc[b7e3ce0d707010f2]::rust_begin_unwind
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:697:5
  17:     0xffcae2532a14 - core::panicking::panic_fmt::h3247d961c5317d14
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/core/src/panicking.rs:75:14
  18:     0xffcae2532a70 - core::panicking::panic::h4ccbadaf2ec212ea
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/core/src/panicking.rs:145:5
  19:     0xffcae331b748 - rustc_monomorphize[e4c91c3dc4c777ea]::collector::collect_items_rec
  20:     0xffcae3312e80 - rustc_monomorphize[e4c91c3dc4c777ea]::collector::collect_items_root
  21:     0xffcae3348814 - <rustc_session[63f005ccee228a55]::session::Session>::time::<(), rustc_monomorphize[e4c91c3dc4c777ea]::collector::collect_crate_mono_items::{closure#1}>
  22:     0xffcae331fcdc - rustc_monomorphize[e4c91c3dc4c777ea]::collector::collect_crate_mono_items
  23:     0xffcae33275e0 - rustc_monomorphize[e4c91c3dc4c777ea]::partitioning::collect_and_partition_mono_items
  24:     0xffcae49227d4 - rustc_query_impl[16f24c59ccefc9f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[16f24c59ccefc9f]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[664decf610687807]::query::erase::Erased<[u8; 40usize]>>
  25:     0xffcae4862f9c - <rustc_query_impl[16f24c59ccefc9f]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(rustc_middle[664decf610687807]::ty::context::TyCtxt, ())>>::call_once
  26:     0xffcae48b0e2c - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[664decf610687807]::ty::context::tls::enter_context<rustc_query_system[d3c07d0e50d3676a]::query::plumbing::try_load_from_disk_and_cache_in_memory<rustc_query_impl[16f24c59ccefc9f]::DynamicConfig<rustc_query_system[d3c07d0e50d3676a]::query::caches::SingleCache<rustc_middle[664decf610687807]::query::erase::Erased<[u8; 40usize]>>, false, false, false>, rustc_query_impl[16f24c59ccefc9f]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[664decf610687807]::query::erase::Erased<[u8; 40usize]>>::{closure#0}, rustc_middle[664decf610687807]::query::erase::Erased<[u8; 40usize]>>
  27:     0xffcae477629c - rustc_query_system[d3c07d0e50d3676a]::query::plumbing::try_execute_query::<rustc_query_impl[16f24c59ccefc9f]::DynamicConfig<rustc_query_system[d3c07d0e50d3676a]::query::caches::SingleCache<rustc_middle[664decf610687807]::query::erase::Erased<[u8; 40usize]>>, false, false, false>, rustc_query_impl[16f24c59ccefc9f]::plumbing::QueryCtxt, false>
  28:     0xffcae49caa48 - rustc_query_impl[16f24c59ccefc9f]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  29:     0xffcae2a593cc - rustc_codegen_ssa[e8c5c9b2d300fbe6]::base::codegen_crate::<rustc_codegen_llvm[d168fe60faae7a23]::LlvmCodegenBackend>
  30:     0xffcae29a4d18 - <rustc_codegen_llvm[d168fe60faae7a23]::LlvmCodegenBackend as rustc_codegen_ssa[e8c5c9b2d300fbe6]::traits::backend::CodegenBackend>::codegen_crate
  31:     0xffcae28288c8 - <rustc_session[63f005ccee228a55]::session::Session>::time::<alloc[cf75e2ab30ac120f]::boxed::Box<dyn core[86de0986de23a55d]::any::Any>, rustc_interface[96f7d59b305183f1]::passes::start_codegen::{closure#0}>
  32:     0xffcae28ef054 - rustc_interface[96f7d59b305183f1]::passes::start_codegen
  33:     0xffcae283f118 - <rustc_interface[96f7d59b305183f1]::queries::Linker>::codegen_and_build_linker
  34:     0xffcae260b580 - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[664decf610687807]::ty::context::tls::enter_context<<rustc_middle[664decf610687807]::ty::context::GlobalCtxt>::enter<rustc_interface[96f7d59b305183f1]::passes::create_and_enter_global_ctxt<core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}, core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>>::{closure#1}, core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>>::{closure#0}, core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>>
  35:     0xffcae25a9990 - <rustc_middle[664decf610687807]::ty::context::TyCtxt>::create_global_ctxt::<core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>, rustc_interface[96f7d59b305183f1]::passes::create_and_enter_global_ctxt<core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}>
  36:     0xffcae25e2a04 - <rustc_interface[96f7d59b305183f1]::passes::create_and_enter_global_ctxt<core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(&rustc_session[63f005ccee228a55]::session::Session, rustc_middle[664decf610687807]::ty::context::CurrentGcx, alloc[cf75e2ab30ac120f]::sync::Arc<rustc_data_structures[b20d5a92cde4f84d]::jobserver::Proxy>, &std[57c45f57ec3c24e5]::sync::once_lock::OnceLock<rustc_middle[664decf610687807]::ty::context::GlobalCtxt>, &rustc_data_structures[b20d5a92cde4f84d]::sync::worker_local::WorkerLocal<rustc_middle[664decf610687807]::arena::Arena>, &rustc_data_structures[b20d5a92cde4f84d]::sync::worker_local::WorkerLocal<rustc_hir[e506d71a89761aaf]::Arena>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  37:     0xffcae26029f4 - <alloc[cf75e2ab30ac120f]::boxed::Box<dyn for<'a> core[86de0986de23a55d]::ops::function::FnOnce<(&'a rustc_session[63f005ccee228a55]::session::Session, rustc_middle[664decf610687807]::ty::context::CurrentGcx, alloc[cf75e2ab30ac120f]::sync::Arc<rustc_data_structures[b20d5a92cde4f84d]::jobserver::Proxy>, &'a std[57c45f57ec3c24e5]::sync::once_lock::OnceLock<rustc_middle[664decf610687807]::ty::context::GlobalCtxt<'a>>, &'a rustc_data_structures[b20d5a92cde4f84d]::sync::worker_local::WorkerLocal<rustc_middle[664decf610687807]::arena::Arena<'a>>, &'a rustc_data_structures[b20d5a92cde4f84d]::sync::worker_local::WorkerLocal<rustc_hir[e506d71a89761aaf]::Arena<'a>>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2}), Output = core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>>> as core[86de0986de23a55d]::ops::function::FnOnce<(&rustc_session[63f005ccee228a55]::session::Session, rustc_middle[664decf610687807]::ty::context::CurrentGcx, alloc[cf75e2ab30ac120f]::sync::Arc<rustc_data_structures[b20d5a92cde4f84d]::jobserver::Proxy>, &std[57c45f57ec3c24e5]::sync::once_lock::OnceLock<rustc_middle[664decf610687807]::ty::context::GlobalCtxt>, &rustc_data_structures[b20d5a92cde4f84d]::sync::worker_local::WorkerLocal<rustc_middle[664decf610687807]::arena::Arena>, &rustc_data_structures[b20d5a92cde4f84d]::sync::worker_local::WorkerLocal<rustc_hir[e506d71a89761aaf]::Arena>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2})>>::call_once
  38:     0xffcae25e17c4 - rustc_interface[96f7d59b305183f1]::passes::create_and_enter_global_ctxt::<core[86de0986de23a55d]::option::Option<rustc_interface[96f7d59b305183f1]::queries::Linker>, rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}::{closure#2}>
  39:     0xffcae2579070 - rustc_span[7537e615742d9f85]::create_session_globals_then::<(), rustc_interface[96f7d59b305183f1]::util::run_in_thread_with_globals<rustc_interface[96f7d59b305183f1]::util::run_in_thread_pool_with_globals<rustc_interface[96f7d59b305183f1]::interface::run_compiler<(), rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
  40:     0xffcae25e9bf8 - std[57c45f57ec3c24e5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[96f7d59b305183f1]::util::run_in_thread_with_globals<rustc_interface[96f7d59b305183f1]::util::run_in_thread_pool_with_globals<rustc_interface[96f7d59b305183f1]::interface::run_compiler<(), rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0xffcae2584368 - <<std[57c45f57ec3c24e5]::thread::Builder>::spawn_unchecked_<rustc_interface[96f7d59b305183f1]::util::run_in_thread_with_globals<rustc_interface[96f7d59b305183f1]::util::run_in_thread_pool_with_globals<rustc_interface[96f7d59b305183f1]::interface::run_compiler<(), rustc_driver_impl[185ce98be39526fb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[86de0986de23a55d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0xffcae602840c - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4301b1eb7e190497
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/alloc/src/boxed.rs:1966:9
  43:     0xffcae602840c - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h63c57e2bd87c106a
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/alloc/src/boxed.rs:1966:9
  44:     0xffcae602840c - std::sys::pal::unix::thread::Thread::new::thread_start::h029a7b8769f51646
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/sys/pal/unix/thread.rs:97:17
  45:     0xffcae1844b30 - <unknown>
  46:     0xffcae18ad88c - <unknown>
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2025-07-17T23_29_35-26248.txt`: Read-only file system (os error 30)

note: rustc 1.90.0-nightly (f7dea7753 2025-07-17) running on aarch64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C strip=symbols -C symbol-mangling-version=v0 -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -Z unstable-options -Z binary-dep-depinfo -Z on-broken-pipe=kill -Z tls-model=initial-exec -Z allow-features=binary-dep-depinfo,proc_macro_span,proc_macro_span_shrink,proc_macro_diagnostic,min_specialization

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
[RUSTC-TIMING] wasm_component_ld test:false 0.080
error: could not compile `wasm-component-ld-wrapper` (bin "wasm-component-ld")

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name wasm_component_ld --edition=2021 src/tools/wasm-component-ld/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=61696ef4436a610f -C extra-filename=-fa6b6db12879c1a3 --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -C strip=symbols -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools/release/deps --extern wasm_component_ld=/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools/aarch64-unknown-linux-gnu/release/deps/libwasm_component_ld-efe28b099532ea21.rlib -Csymbol-mangling-version=v0 -Zrandomize-layout -Zunstable-options '--check-cfg=cfg(bootstrap)' '--check-cfg=cfg(rust_analyzer)' -Zmacro-backtrace -Csplit-debuginfo=off -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Alinker-messages -Zunstable-options -Z binary-dep-depinfo` (exit status: 101)
Build completed unsuccessfully in 0:24:21
  local time: Thu Jul 17 23:29:35 UTC 2025
  network time: Thu, 17 Jul 2025 23:29:35 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

#[inline(always)] and -Zhint-mostly-unused play not well with imported main
3 participants