Skip to content

Update toolchain to latest nightly (Nov 13) - #460

Closed
dvdplm wants to merge 22 commits into
Rust-GPU:mainfrom
dvdplm:update-toolchain-Nov-02-2025
Closed

Update toolchain to latest nightly (Nov 13)#460
dvdplm wants to merge 22 commits into
Rust-GPU:mainfrom
dvdplm:update-toolchain-Nov-02-2025

Conversation

@dvdplm

@dvdplmdvdplm commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Based on @nnethercote's work in #420, but with a more recent toolchain.

The toolchain update from nightly-2025-06-30 to nightly-2025-11-13 uncovered a slew of minor incompatibilities and a major(?) ABI issue: rustc_target::callconv::PassMode handling in function ABIs changed upstream. The bulk of that work happened in #144529 with the introduction of the new internal #[rustc_pass_indirectly_in_non_rustic_abis] attribute.

This change causes an ICE when we run the compiletests from rust-gpu with, e.g. cargo run -p compiletests --no-default-features --features "use-installed-tools" typed_buffer.rs -- --target-env vulkan1.1,vulkan1.2,vulkan1.3,vulkan1.4,spv1.3. The assertion we hit when compiling core is here:

 assert_matches!(
arg.mode,
PassMode::Indirect { on_stack: false, .. },
"the {spec_abi} ABI does not implement `#[rustc_pass_indirectly_in_non_rustic_abis]`"
);

The assertion fires in our query hook (abi.rs:104) when calling the default provider's fn_abi_of_instance, which now runs the new sanity check from PR #144529. rust-gpu converts extern "C" to extern "unadjusted" (line 47 in abi.rs), then attempts to force all arguments to PassMode::Direct via readjust_fn_abi() (line 68). However, PR #144529 introduced a new invariant that requires certain types marked with #[rustc_pass_indirectly_in_non_rustic_abis] to be passed indirectly, even in unadjusted ABIs.

Example ICE output (Click to view)
$ cargo run -p compiletests --no-default-features --features "use-installed-tools" typed_buffer.rs -- --target-env vulkan1.1,vulkan1.2,vulkan1.3,vulkan1.4,spv1.3
Compiling rustc_codegen_spirv v0.9.0 (/Users/aggron/dev/play/rust-gpu/crates/rustc_codegen_spirv)
Compiling compiletests v0.0.0 (/Users/aggron/dev/play/rust-gpu/tests/compiletests)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.23s
Running `target/debug/compiletests typed_buffer.rs -- --target-env vulkan1.1,vulkan1.2,vulkan1.3,vulkan1.4,spv1.3`
Testing env: vulkan1.2
Compiling compiler_builtins v0.1.160 (/Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)
Compiling core v0.0.0 (/Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core)
Compiling libm v0.2.15
Compiling num-traits v0.2.19
thread 'rustc' (7026365) panicked at compiler/rustc_ty_utils/src/abi.rs:393:13:
assertion `left matches right` failed: the "unadjusted" ABI does not implement `#[rustc_pass_indirectly_in_non_rustic_abis]`
left: Direct(ArgAttributes { regular: , arg_ext: None, pointee_size: Size(0 bytes), pointee_align: None })
right: PassMode::Indirect { on_stack: false, .. }
stack backtrace:
0: 0x10f07e308 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd0092cb2108dff20
1: 0x10c5114f0 - core::fmt::write::ha186e2b4ead44120
2: 0x10f03812c - std::io::Write::write_fmt::h6e4671fa9b3a062f
3: 0x10f050174 - std::panicking::default_hook::{{closure}}::h69c01c0374ca677d
4: 0x10f04fe44 - std::panicking::default_hook::h1046bb683cbbadf4
5: 0x10d09bdbc - std[e0104592952a5dd2]::panicking::update_hook::<alloc[f04d64cd1d58c663]::boxed::Box<rustc_driver_impl[903a3f876b94d2fb]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x10d09bdbc - std[e0104592952a5dd2]::panicking::update_hook::<alloc[f04d64cd1d58c663]::boxed::Box<rustc_driver_impl[903a3f876b94d2fb]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x10f050654 - std::panicking::panic_with_hook::h8531190ba21235aa
8: 0x10f0502d0 - std::panicking::panic_handler::{{closure}}::h62694d8b9a34358e
9: 0x10f049d1c - std::sys::backtrace::__rust_end_short_backtrace::h0ec2058982a912e1
10: 0x10f02e8a8 - __rustc[847c02c2895e2821]::rust_begin_unwind
11: 0x111db4af0 - core::panicking::panic_fmt::h898455b97f9faa0d
12: 0x111db49f0 - core::panicking::assert_failed_inner::h6c76435104fddc07
13: 0x111f51f18 - core[e1286b790dd73a96]::panicking::assert_matches_failed::<rustc_target[aa4293a4e7302e06]::callconv::PassMode>
14: 0x10ef9cbf8 - rustc_ty_utils[3828d5716b659cf2]::abi::fn_abi_sanity_check::fn_arg_sanity_check
15: 0x10ef909a0 - rustc_ty_utils[3828d5716b659cf2]::abi::fn_abi_new_uncached
16: 0x10ef8d08c - rustc_ty_utils[3828d5716b659cf2]::abi::fn_abi_of_instance
17: 0x117bb3300 - rustc_codegen_spirv::abi::provide::{{closure}}::h289900d70d8e0378
at /Users/aggron/dev/play/rust-gpu/crates/rustc_codegen_spirv/src/abi.rs:104:22
18: 0x117cd2858 - core::ops::function::FnOnce::call_once::h51035616f6ed3020
at /Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
19: 0x10e4f7838 - rustc_query_impl[6b7bffa0d04cfd41]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6b7bffa0d04cfd41]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 16usize]>>
20: 0x10e7f8f88 - <rustc_query_impl[6b7bffa0d04cfd41]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2} as core[e1286b790dd73a96]::ops::function::FnOnce<(rustc_middle[a67d08fc31966930]::ty::context::TyCtxt, rustc_middle[a67d08fc31966930]::ty::PseudoCanonicalInput<(rustc_middle[a67d08fc31966930]::ty::instance::Instance, &rustc_middle[a67d08fc31966930]::ty::list::RawList<(), rustc_middle[a67d08fc31966930]::ty::Ty>)>)>>::call_once
21: 0x10e57972c - rustc_query_system[f89dc8d89280194f]::query::plumbing::try_execute_query::<rustc_query_impl[6b7bffa0d04cfd41]::DynamicConfig<rustc_query_system[f89dc8d89280194f]::query::caches::DefaultCache<rustc_middle[a67d08fc31966930]::ty::PseudoCanonicalInput<(rustc_middle[a67d08fc31966930]::ty::instance::Instance, &rustc_middle[a67d08fc31966930]::ty::list::RawList<(), rustc_middle[a67d08fc31966930]::ty::Ty>)>, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[6b7bffa0d04cfd41]::plumbing::QueryCtxt, false>
22: 0x10e693958 - rustc_query_impl[6b7bffa0d04cfd41]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace
23: 0x10d0241f0 - <rustc_const_eval[815e6d43893a3622]::interpret::eval_context::InterpCx<rustc_const_eval[815e6d43893a3622]::const_eval::machine::CompileTimeMachine> as rustc_middle[a67d08fc31966930]::ty::layout::FnAbiOf>::fn_abi_of_instance
24: 0x10cf7a4f0 - <rustc_const_eval[815e6d43893a3622]::interpret::eval_context::InterpCx<rustc_const_eval[815e6d43893a3622]::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
25: 0x10cf7828c - <rustc_const_eval[815e6d43893a3622]::interpret::eval_context::InterpCx<rustc_const_eval[815e6d43893a3622]::const_eval::machine::CompileTimeMachine>>::eval_terminator
26: 0x10cfabc7c - rustc_const_eval[815e6d43893a3622]::const_eval::eval_queries::eval_to_allocation_raw_provider
27: 0x10e4f8804 - rustc_query_impl[6b7bffa0d04cfd41]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6b7bffa0d04cfd41]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 24usize]>>
28: 0x10e8022fc - <rustc_query_impl[6b7bffa0d04cfd41]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core[e1286b790dd73a96]::ops::function::FnOnce<(rustc_middle[a67d08fc31966930]::ty::context::TyCtxt, rustc_middle[a67d08fc31966930]::ty::PseudoCanonicalInput<rustc_middle[a67d08fc31966930]::mir::interpret::GlobalId>)>>::call_once
29: 0x10e57114c - rustc_query_system[f89dc8d89280194f]::query::plumbing::try_execute_query::<rustc_query_impl[6b7bffa0d04cfd41]::DynamicConfig<rustc_query_system[f89dc8d89280194f]::query::caches::DefaultCache<rustc_middle[a67d08fc31966930]::ty::PseudoCanonicalInput<rustc_middle[a67d08fc31966930]::mir::interpret::GlobalId>, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[6b7bffa0d04cfd41]::plumbing::QueryCtxt, false>
30: 0x10e69d3a8 - rustc_query_impl[6b7bffa0d04cfd41]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
31: 0x10cfad328 - rustc_const_eval[815e6d43893a3622]::const_eval::eval_queries::eval_to_const_value_raw_provider
32: 0x10e4f90c8 - rustc_query_impl[6b7bffa0d04cfd41]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6b7bffa0d04cfd41]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 24usize]>>
33: 0x10e807d50 - <rustc_query_impl[6b7bffa0d04cfd41]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2} as core[e1286b790dd73a96]::ops::function::FnOnce<(rustc_middle[a67d08fc31966930]::ty::context::TyCtxt, rustc_middle[a67d08fc31966930]::ty::PseudoCanonicalInput<rustc_middle[a67d08fc31966930]::mir::interpret::GlobalId>)>>::call_once
34: 0x10e573504 - rustc_query_system[f89dc8d89280194f]::query::plumbing::try_execute_query::<rustc_query_impl[6b7bffa0d04cfd41]::DynamicConfig<rustc_query_system[f89dc8d89280194f]::query::caches::DefaultCache<rustc_middle[a67d08fc31966930]::ty::PseudoCanonicalInput<rustc_middle[a67d08fc31966930]::mir::interpret::GlobalId>, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[6b7bffa0d04cfd41]::plumbing::QueryCtxt, false>
35: 0x10e6a0abc - rustc_query_impl[6b7bffa0d04cfd41]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
36: 0x10d34fa0c - <rustc_middle[a67d08fc31966930]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[34dc5b6ecdbdcc6d]::check_crate::{closure#2}>::{closure#0}
37: 0x10d380518 - rustc_hir_analysis[34dc5b6ecdbdcc6d]::check_crate
38: 0x10d98902c - rustc_interface[cc654ed05c1e7758]::passes::analysis
39: 0x10e4fad9c - rustc_query_impl[6b7bffa0d04cfd41]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6b7bffa0d04cfd41]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 0usize]>>
40: 0x10e540854 - rustc_query_system[f89dc8d89280194f]::query::plumbing::try_execute_query::<rustc_query_impl[6b7bffa0d04cfd41]::DynamicConfig<rustc_query_system[f89dc8d89280194f]::query::caches::SingleCache<rustc_middle[a67d08fc31966930]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6b7bffa0d04cfd41]::plumbing::QueryCtxt, false>
41: 0x10e6b247c - rustc_query_impl[6b7bffa0d04cfd41]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
42: 0x10d04fea4 - rustc_interface[cc654ed05c1e7758]::passes::create_and_enter_global_ctxt::<core[e1286b790dd73a96]::option::Option<rustc_interface[cc654ed05c1e7758]::queries::Linker>, rustc_driver_impl[903a3f876b94d2fb]::run_compiler::{closure#0}::{closure#2}>
43: 0x10d09a4f4 - rustc_interface[cc654ed05c1e7758]::interface::run_compiler::<(), rustc_driver_impl[903a3f876b94d2fb]::run_compiler::{closure#0}>::{closure#1}
44: 0x10d08dc58 - std[e0104592952a5dd2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[cc654ed05c1e7758]::util::run_in_thread_with_globals<rustc_interface[cc654ed05c1e7758]::util::run_in_thread_pool_with_globals<rustc_interface[cc654ed05c1e7758]::interface::run_compiler<(), rustc_driver_impl[903a3f876b94d2fb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
45: 0x10d0a0b1c - <<std[e0104592952a5dd2]::thread::Builder>::spawn_unchecked_<rustc_interface[cc654ed05c1e7758]::util::run_in_thread_with_globals<rustc_interface[cc654ed05c1e7758]::util::run_in_thread_pool_with_globals<rustc_interface[cc654ed05c1e7758]::interface::run_compiler<(), rustc_driver_impl[903a3f876b94d2fb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e1286b790dd73a96]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
46: 0x10f0469bc - std::sys::thread::unix::Thread::new::thread_start::hb62037f489b284b5
47: 0x189ca5c08 - __pthread_cond_wait
error: 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: please make sure that you have updated to the latest nightly
note: please attach the file at `/Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/rustc-ice-2025-11-14T08_25_38-10527.txt` to your bug report
note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 -Z force-unstable-if-unmarked -Z codegen-backend=/Users/aggron/dev/play/rust-gpu/target/debug/deps/librustc_codegen_spirv.dylib -Z binary-dep-depinfo -C symbol-mangling-version=v0 -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(rust_gpu) -C overflow-checks=off -C debug-assertions=off -Z inline-mir=off -Z mir-enable-passes=-GVN -Z share-generics=off -C debuginfo=2 -C embed-bitcode=no
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `ffi::va_list::_::c`
#1 [eval_to_allocation_raw] const-evaluating + checking `ffi::va_list::_`
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-gpu/rust-gpu/issues/new
note: please make sure that you have updated to the latest nightly
note: please attach the file at `/Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/rustc-ice-2025-11-14T08_25_38-10527.txt` to your bug report
note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 -Z force-unstable-if-unmarked -Z codegen-backend=/Users/aggron/dev/play/rust-gpu/target/debug/deps/librustc_codegen_spirv.dylib -Z binary-dep-depinfo -C symbol-mangling-version=v0 -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(rust_gpu) -C overflow-checks=off -C debug-assertions=off -Z inline-mir=off -Z mir-enable-passes=-GVN -Z share-generics=off -C debuginfo=2 -C embed-bitcode=no
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `ffi::va_list::_::c`
#1 [eval_to_allocation_raw] const-evaluating + checking `ffi::va_list::_`
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
note: `rust-gpu` version `0.9.0`
error: could not compile `core` (lib)
Caused by:
process didn't exit successfully: `/Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/rustc --crate-name core --edition=2024 /Users/aggron/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=167 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --warn=unexpected_cfgs --check-cfg 'cfg(no_fp_fmt_parse)' --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)' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("debug_refcell", "optimize_for_size", "panic_immediate_abort"))' -C metadata=98dc830f61738f16 -C extra-filename=-18147afe4ebe7729 --out-dir /Users/aggron/dev/play/rust-gpu/target/compiletest-deps/spirv-unknown-vulkan1.2/debug/deps --target /Users/aggron/dev/play/rust-gpu/crates/rustc_codegen_spirv-target-specs/target-specs/spirv-unknown-vulkan1.2.json -Z force-unstable-if-unmarked -L dependency=/Users/aggron/dev/play/rust-gpu/target/compiletest-deps/spirv-unknown-vulkan1.2/debug/deps -L dependency=/Users/aggron/dev/play/rust-gpu/target/compiletest-deps/debug/deps --cap-lints allow -Zcodegen-backend=/Users/aggron/dev/play/rust-gpu/target/debug/deps/librustc_codegen_spirv.dylib -Zbinary-dep-depinfo -Csymbol-mangling-version=v0 '-Zcrate-attr=feature(register_tool)' '-Zcrate-attr=register_tool(rust_gpu)' -Coverflow-checks=off -Cdebug-assertions=off -Zinline-mir=off -Zmir-enable-passes=-GVN -Zshare-generics=off -Cdebuginfo=2 -Cembed-bitcode=no` (exit status: 101)
thread 'main' (7026278) panicked at tests/compiletests/src/main.rs:217:10:
called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "process terminated with non-zero code: 101" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I have a suspicion that this change is involved, but I have to admit that making rust-gpu work with a locally built rustc has been quite challenging!

The other changes in this PR are simple adjustments and tweaks to accommodate for upstream changes. I suspect that some of my hack-fixes here do not actually work, but it's hard to tell with the ICE in the way.

nnethercoteand others added 18 commits October 20, 2025 16:21
- We now get warnings about unnecessary parentheses around `dyn` types.
- Spelling of `sf.name.prefer_remapped_unconditionaly` was fixed (now
ends in `lly`).
- `Pointer::into_parts` has been replaced with
`Pointer::prov_and_relative_offset`.
- `BuilderMethods::dynamic_alloca` was removed.
- `TargetDataLayout::pointer_{size,align}` were changed from fields to
methods.
- `AddressSpace::DATA` was renamed `AddressSpace::ZERO`.
- `run_fat_lto`, `optimize_fat`, and `autodiff` were merged into
`run_and_optimize_fat_lto`, and the parameters were changed.
- `run_thin_lto` parameters were changed.
- `codegen` parameters were changed.
- `LtoModuleCodegen` was removed.
- Minor error message changes:
- Some line number changes in rustc.
- Some error message wording tweaks.
The LTO changes occurred in rust-lang/rust PR 143388 and PR 144062.
- `tcx.get_attrs_unchecked(...)` was replaced with
`tcx.get_all_attrs(...)`.
- `run_link` has been removed.
- `BuilderMethods::tail_call` was added. It's currently `todo!()`.
- Adjust expected test outputs for very minor error message formatting
changes.
- And update to glam 0.30.8.
@dvdplmdvdplm changed the title Update toolchain to nightly-2025-11-02Update toolchain to latest nightly (Nov 11)Nov 11, 2025
@dvdplmdvdplm changed the title Update toolchain to latest nightly (Nov 11)Update toolchain to latest nightly (Nov 13)Nov 14, 2025
@dvdplm
dvdplm marked this pull request as ready for review November 14, 2025 09:11
@schell

Copy link
Copy Markdown
Contributor

@dvdplm is this PR ready to go or are you looking to collab on a fix for the ICE you encountered?

@dvdplm

Copy link
Copy Markdown
ContributorAuthor

@dvdplm is this PR ready to go or are you looking to collab on a fix for the ICE you encountered?

It is definitely not ready to go, and the ICE is still there. :/

I think the issue stems from the recent work to support C variadics in FFI, but that's speculation on my part (and a moving target).

This PR should really be a draft, possibly as the starting point for further investigation.

@schell

Copy link
Copy Markdown
Contributor

Hrm, I can't set the PR as draft, can you @dvdplm?

@dvdplm
dvdplm marked this pull request as draft December 1, 2025 06:03
cgcx: &CodegenContext<Self>,
// FIXME(bjorn3): Limit LTO exports to these symbols
_exported_symbols_for_lto: &[String],
_each_linked_rlib_for_lto: &[PathBuf], // njn: ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is the set of rlibs that will be linked in during thin LTO. It is empty for thin local LTO. FWIW as of a couple of nightlies ago, if you return false from CodegenBackend::thin_lto_supported, thin local LTO will be unconditionally disabled (and -Clto=thin will be downgraded to no LTO) allowing you to replace run_thin_lto and optimize_thin with unreachable!().

o.env = self.env.to_string().into();
o.vendor = self.vendor.clone().into();
// FIXME: this is problematic I believe. Used to be a `Cow` but is now an enum.
o.env = rustc_target::spec::Env::Unspecified;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can use Env::Other(self.env.to_string().into()).

@bjorn3

Copy link
Copy Markdown

The assertion fires in our query hook (abi.rs:104) when calling the default provider's fn_abi_of_instance, which now runs the new sanity check from PR #144529. rust-gpu converts extern "C" to extern "unadjusted" (line 47 in abi.rs), then attempts to force all arguments to PassMode::Direct via readjust_fn_abi() (line 68). However, PR #144529 introduced a new invariant that requires certain types marked with #[rustc_pass_indirectly_in_non_rustic_abis] to be passed indirectly, even in unadjusted ABIs.

FWIW I want to remove extern "unadjusted" in the future once stdarch no longer depends on it. extern "unadjusted" violates internal invariants and directly exposes implementation details of the codegen backend to the user. Is it not possible to use PassMode::Indirect { on_stack: false } for extern "C" and then during abi lowering pass it as direct argument after all? It may be a bit non-trivial for returns, but if I understand correctly, shader entrypoints always return a unit type, which you can keep as PassMode::Ignore.

I have a suspicion that this change is involved

Indeed. Due to array decay in C, va_list arguments have to be passed as pointer on platforms where va_list is an array, but passed as regular struct on platforms where va_list is a struct. To get this working without needing source changes, we use #[pass_indirectly_in_non_rustic_abis] in the array case to make it be passed as pointer.

@fee1-dead

Copy link
Copy Markdown
Collaborator

Is it not possible to use PassMode::Indirect { on_stack: false } for extern "C" and then during abi lowering pass it as direct argument after all?

@bjorn3 did you mean codegen_argumenthere? I don't know what you meant by ABI lowering, because it seems that FnAbi was obtained and used directly without modification from tcx.fn_abi_of_instance. Even though rust-gpu patches rustc_codegen_ssa my understanding was that we would like to avoid introducing any additional patches if possible. So the original code was correct IMO in saying that the passed in values are done in the backend-agnostic parts which leaves not as much room for the codegen backend to configure..

@bjorn3

Copy link
Copy Markdown

With the exception of the one for the main shim, all BuilderMethods::call invocations pass an FnAbi. So if you force all arguments to be PassMode::Indirect, cg_ssa will pass pointers for all arguments, which you can turn back into direct arguments in your BuilderMethods::call call based on the type information derived from FnAbi. And in AbiBuilderMethods::get_param you can turn the direct argument into a pointer on the callee side. This way cg_ssa only sees pointers, while cg_spirv can turn this back into direct arguments at the spir-v level to match the expected abi.

@Firestar99

Copy link
Copy Markdown
Member

Superseded by #541 and #542

Thanks for your patches @dvdplm, I was able to cherry-pick them into those PRs and get them up and running! ❤️

@dvdplmdvdplm closed this Apr 8, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@dvdplm@schell@bjorn3@fee1-dead@Firestar99@nnethercote