From 269792457602580ace906bf53fdf3abc78976321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 23 Jul 2026 21:00:06 +0200 Subject: [PATCH 01/13] Do not pass `-no-pie` on Windows --- compiler/rustc_codegen_ssa/src/back/linker.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 50a3e7fb7a1d1..c49f12973a074 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -536,7 +536,8 @@ impl<'a> Linker for GccLinker<'a> { LinkOutputKind::StaticNoPicExe => { // `-static` works for both gcc wrapper and ld. self.link_or_cc_arg("-static"); - if !self.is_ld && self.is_gnu { + // noop on windows w/ gcc, warning w/ clang + if !self.is_ld && self.is_gnu && !self.sess.target.is_like_windows { self.cc_arg("-no-pie"); } } From 0ec97c248ea81a4078f797f9b0b2f5b8e97d3f96 Mon Sep 17 00:00:00 2001 From: fereidani Date: Sat, 8 Aug 2026 06:48:46 +0330 Subject: [PATCH 02/13] Remove unnecessary fmt::Display use for overflow assertion --- library/alloc/src/sync.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 4f86d6c596050..2a8ab5c646217 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -55,8 +55,10 @@ use crate::vec::Vec; /// See comment in `Arc::clone`. const MAX_REFCOUNT: usize = (isize::MAX) as usize; -/// The error in case either counter reaches above `MAX_REFCOUNT`, and we can `panic` safely. -const INTERNAL_OVERFLOW_ERROR: &str = "Arc counter overflow"; +#[inline(always)] +fn enforce_overflow_limit(n: usize) { + assert!(n <= MAX_REFCOUNT, "Arc counter overflow"); +} #[cfg(not(sanitize = "thread"))] macro_rules! acquire { @@ -1954,7 +1956,7 @@ impl Arc { } // We can't allow the refcount to increase much past `MAX_REFCOUNT`. - assert!(cur <= MAX_REFCOUNT, "{}", INTERNAL_OVERFLOW_ERROR); + enforce_overflow_limit(cur); // NOTE: this code currently ignores the possibility of overflow // into usize::MAX; in general both Rc and Arc need to be adjusted @@ -3311,7 +3313,7 @@ impl Weak { return None; } // See comments in `Arc::clone` for why we do this (for `mem::forget`). - assert!(n <= MAX_REFCOUNT, "{}", INTERNAL_OVERFLOW_ERROR); + enforce_overflow_limit(n); Some(n + 1) } From 9be1177c0a5c8e45e2627140785db7ac8cf25b14 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 8 Aug 2026 16:32:07 +0200 Subject: [PATCH 03/13] Miri: give the incremental session a chance to finish --- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_interface/src/util.rs | 10 +- compiler/rustc_middle/src/queries.rs | 4 +- src/tools/miri/src/bin/miri.rs | 104 ++++++++++++++---- src/tools/miri/src/diagnostics.rs | 2 +- src/tools/miri/src/eval.rs | 4 +- .../pass/ptr_read_access.notrace.stderr | 2 + .../pass/ptr_read_access.trace.stderr | 2 + .../pass/ptr_write_access.notrace.stderr | 2 + .../pass/ptr_write_access.trace.stderr | 2 + .../libc/fcntl_f-fullfsync_apple.stderr | 2 + .../libc/libc-fs-with-isolation.stderr | 2 + .../libc/libc-socket-invalid-addr.stderr | 2 + .../libc/libc-socket-with-isolation.stderr | 2 + .../miri/tests/pass/extern_types.stack.stderr | 2 + .../tests/pass/open_a_file_in_proc.stderr | 2 + .../env/current_dir_with_isolation.stderr | 2 + .../tests/pass/shims/fs-with-isolation.stderr | 2 + .../tests/pass/shims/socket-address.stderr | 2 + 19 files changed, 117 insertions(+), 35 deletions(-) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index cdba198297201..ec5669b1363f7 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -1312,7 +1312,7 @@ pub(crate) fn start_codegen<'tcx>( // Skip crate items and just output metadata in -Z no-codegen mode. tcx.sess.dcx().abort_if_errors(); - // Linker::link will skip join_codegen in case of a CodegenResults Any value. + // Linker::link will skip join_codegen in case of a `CompiledModules` Any value. Box::new(CompiledModules { modules: vec![], allocator_module: None }) } else { codegen_backend.codegen_crate(tcx) diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 654a782262e22..5f5c847f2ad57 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -363,7 +363,7 @@ pub fn get_codegen_backend( filename if filename.contains('.') => { load_backend_from_dylib(early_dcx, filename.as_ref()) } - "dummy" => || Box::new(DummyCodegenBackend { target_config_override: None }), + "dummy" => || Box::new(DummyCodegenBackend), #[cfg(feature = "llvm")] "llvm" => rustc_codegen_llvm::LlvmCodegenBackend::new, backend_name => get_codegen_sysroot(early_dcx, sysroot, backend_name), @@ -376,9 +376,7 @@ pub fn get_codegen_backend( unsafe { load() } } -pub struct DummyCodegenBackend { - pub target_config_override: Option TargetConfig>>, -} +pub struct DummyCodegenBackend; impl CodegenBackend for DummyCodegenBackend { fn name(&self) -> &'static str { @@ -386,10 +384,6 @@ impl CodegenBackend for DummyCodegenBackend { } fn target_config(&self, sess: &Session) -> TargetConfig { - if let Some(target_config_override) = &self.target_config_override { - return target_config_override(sess); - } - let abi_required_features = sess.target.abi_required_features(); let internal_target_features = internal_target_features::<0>( sess, diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index f90274460e379..6af9f6346fe91 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -2027,10 +2027,10 @@ rustc_queries! { // The hash should not be calculated before the `analysis` pass is complete, specifically // until `tcx.untracked().definitions.freeze()` has been called, otherwise if incremental // compilation is enabled calculating this hash can freeze this structure too early in - // compilation and cause subsequent crashes when attempting to write to `definitions` + // compilation and cause subsequent crashes when attempting to write to `definitions`. query crate_hash(_: CrateNum) -> Svh { eval_always - desc { "looking up the hash a crate" } + desc { "looking up the hash of a crate" } separate_provide_extern } diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 5a5acc53de766..07d64286d0c9b 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -13,6 +13,7 @@ extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_interface; extern crate rustc_log; +extern crate rustc_metadata; extern crate rustc_middle; extern crate rustc_session; @@ -21,6 +22,7 @@ rustc_driver::override_c_allocator_in_binary!(); mod log; +use std::any::Any; use std::env; use std::num::{NonZero, NonZeroI32}; use std::ops::Range; @@ -34,6 +36,7 @@ use miri::{ TreeBorrowsParams, ValidationMode, entry_fn, run_genmc_mode, }; use rustc_codegen_ssa::traits::CodegenBackend; +use rustc_codegen_ssa::{CompiledModules, CrateInfo, TargetConfig}; use rustc_data_structures::sync::{self, DynSync}; use rustc_driver::Compilation; use rustc_interface::interface::Config; @@ -51,6 +54,13 @@ struct MiriCompilerCalls { many_seeds: Option, } +struct MiriCodegenBackend { + native: Box, + dummy: DummyCodegenBackend, + /// Whether we are in a dependency or in the to-be-interpreted binary crate + dep: bool, +} + struct ManySeedsConfig { seeds: Range, keep_going: bool, @@ -97,39 +107,27 @@ fn run_many_seeds( /// Generates the codegen backend for code that Miri will interpret: we basically /// use the dummy backend, except that we put the LLVM backend in charge of /// target features. -fn make_miri_codegen_backend(sess: &Session) -> Box { +fn make_miri_codegen_backend(sess: &Session, dep: bool) -> Box { let early_dcx = EarlyDiagCtxt::new(sess.opts.error_format); // Use the target_config method of the default codegen backend (eg LLVM) to ensure the // calculated target features match said backend by respecting eg -Ctarget-cpu. - let target_config_backend = rustc_interface::util::get_codegen_backend( + let native_codegen_backend = rustc_interface::util::get_codegen_backend( &early_dcx, &sess.opts.sysroot, None, &sess.target, ); - target_config_backend.init(sess); + native_codegen_backend.init(sess); - Box::new(DummyCodegenBackend { - target_config_override: Some(Box::new(move |sess| { - let mut cfg = target_config_backend.target_config(sess); - // The basic types and ABI always work. - cfg.has_reliable_f16 = true; - cfg.has_reliable_f128 = true; - // We always provide the f16 intrinsics, but some are provided via the host, - // so forward its reliability. - cfg.has_reliable_f16_math = cfg!(target_has_reliable_f16_math); - // Many f128 operations are still missing. - cfg.has_reliable_f128_math = false; - cfg - })), - }) + Box::new(MiriCodegenBackend { native: native_codegen_backend, dummy: DummyCodegenBackend, dep }) } impl rustc_driver::Callbacks for MiriCompilerCalls { fn config(&mut self, config: &mut rustc_interface::interface::Config) { // We never reach codegen anyway. - config.make_codegen_backend = Some(Box::new(make_miri_codegen_backend)); + config.make_codegen_backend = + Some(Box::new(|sess| make_miri_codegen_backend(sess, /* dep */ false))); // Register our custom extra symbols. config.extra_symbols = miri::sym::EXTRA_SYMBOLS.into(); @@ -203,10 +201,71 @@ impl rustc_driver::Callbacks for MiriCompilerCalls { tcx.dcx().abort_if_errors(); exit(return_code.get()); } else { - exit(rustc_driver::EXIT_SUCCESS); + // We want to continue here so rustc can do its usual shutdown and finalize the + // incremental session. Our custom codegen backend ensures nothing actually happens. + return Compilation::Continue; } + } +} + +impl CodegenBackend for MiriCodegenBackend { + fn name(&self) -> &'static str { + "miri" + } + + fn target_config(&self, sess: &Session) -> TargetConfig { + let native_target_config = self.native.target_config(sess); + TargetConfig { + internal_target_features: native_target_config.internal_target_features, - // Unreachable. + // The basic types and ABI always work. + has_reliable_f16: true, + has_reliable_f128: true, + // We always provide the f16 intrinsics, but some are provided via the host, + // so forward its reliability. + has_reliable_f16_math: cfg!(target_has_reliable_f16_math), + // Many f128 operations are still missing. + has_reliable_f128_math: false, + } + } + + fn target_cpu(&self, _sess: &Session) -> String { + String::new() + } + + // Everything complicated is forwarded to the dummy backend. + + fn supported_crate_types(&self, sess: &Session) -> Vec { + self.dummy.supported_crate_types(sess) + } + + fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Box { + self.dummy.codegen_crate(tcx) + } + + fn join_codegen( + &self, + ongoing_codegen: Box, + sess: &Session, + incr_comp_session: Option<&rustc_session::IncrCompSession>, + outputs: &rustc_session::config::OutputFilenames, + crate_info: &CrateInfo, + ) -> (CompiledModules, rustc_middle::dep_graph::WorkProductMap) { + self.dummy.join_codegen(ongoing_codegen, sess, incr_comp_session, outputs, crate_info) + } + + fn link( + &self, + sess: &Session, + compiled_modules: CompiledModules, + crate_info: CrateInfo, + metadata: rustc_metadata::EncodedMetadata, + outputs: &rustc_session::config::OutputFilenames, + ) { + // In the binary this should do nothing. + if self.dep { + self.dummy.link(sess, compiled_modules, crate_info, metadata, outputs) + } } } @@ -217,7 +276,8 @@ impl rustc_driver::Callbacks for MiriDepCompilerCalls { #[allow(rustc::potential_query_instability)] // rustc_codegen_ssa (where this code is copied from) also allows this lint fn config(&mut self, config: &mut Config) { // We don't need actual codegen, we just emit an rlib that Miri can later consume. - config.make_codegen_backend = Some(Box::new(make_miri_codegen_backend)); + config.make_codegen_backend = + Some(Box::new(|sess| make_miri_codegen_backend(sess, /* dep */ true))); // Avoid warnings about unsupported crate types. However, only do that we we are *not* being // queried by cargo about the supported crate types so that cargo still receives the @@ -683,4 +743,6 @@ fn main() -> ExitCode { } } run_compiler_and_exit(&rustc_args, &mut MiriCompilerCalls::new(miri_config, many_seeds)) + // Note that we *cannot* just return here, in native-lib mode we have to coordinate + // with the supervisor process! } diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index d4fe89d4f0258..d71c89617bab7 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -237,7 +237,7 @@ pub fn prune_stacktrace<'tcx>( /// Report the result of a Miri execution. /// /// Returns `Some` if this was regular program termination with a given exit code and a `bool` -/// indicating whether a leak check should happen; `None` otherwise. +/// indicating whether a leak check should happen; `None` if execution was aborted with an error. pub fn report_result<'tcx>( ecx: &InterpCx<'tcx, MiriMachine<'tcx>>, res: InterpErrorInfo<'tcx>, diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index f33dc9d070971..3ba16971eca84 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -510,8 +510,8 @@ fn call_main<'tcx>( } /// Evaluates the entry function specified by `entry_id`. -/// Returns `Some(return_code)` if program execution completed. -/// Returns `None` if an evaluation error occurred. +/// Returns `Ok(())` if program execution completed with exit code 0. +/// Returns `Err(code)` if an evaluation error occurred or the program returned a non-0 exit code. pub fn eval_entry<'tcx>( tcx: TyCtxt<'tcx>, entry_id: DefId, diff --git a/src/tools/miri/tests/native-lib/pass/ptr_read_access.notrace.stderr b/src/tools/miri/tests/native-lib/pass/ptr_read_access.notrace.stderr index bc2fcac08f014..e1b6ce12fac90 100644 --- a/src/tools/miri/tests/native-lib/pass/ptr_read_access.notrace.stderr +++ b/src/tools/miri/tests/native-lib/pass/ptr_read_access.notrace.stderr @@ -14,3 +14,5 @@ LL | unsafe { print_pointer(&x) }; 1: main at tests/native-lib/pass/ptr_read_access.rs:LL:CC +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/native-lib/pass/ptr_read_access.trace.stderr b/src/tools/miri/tests/native-lib/pass/ptr_read_access.trace.stderr index c7f30c114f16a..3295eda01fffc 100644 --- a/src/tools/miri/tests/native-lib/pass/ptr_read_access.trace.stderr +++ b/src/tools/miri/tests/native-lib/pass/ptr_read_access.trace.stderr @@ -15,3 +15,5 @@ LL | unsafe { print_pointer(&x) }; 1: main at tests/native-lib/pass/ptr_read_access.rs:LL:CC +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/native-lib/pass/ptr_write_access.notrace.stderr b/src/tools/miri/tests/native-lib/pass/ptr_write_access.notrace.stderr index 15b2bc6df63fa..c86cf783f5d04 100644 --- a/src/tools/miri/tests/native-lib/pass/ptr_write_access.notrace.stderr +++ b/src/tools/miri/tests/native-lib/pass/ptr_write_access.notrace.stderr @@ -14,3 +14,5 @@ LL | unsafe { increment_int(&mut x) }; 1: main at tests/native-lib/pass/ptr_write_access.rs:LL:CC +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/native-lib/pass/ptr_write_access.trace.stderr b/src/tools/miri/tests/native-lib/pass/ptr_write_access.trace.stderr index d12a25f84b370..1c62afa09c799 100644 --- a/src/tools/miri/tests/native-lib/pass/ptr_write_access.trace.stderr +++ b/src/tools/miri/tests/native-lib/pass/ptr_write_access.trace.stderr @@ -15,3 +15,5 @@ LL | unsafe { increment_int(&mut x) }; 1: main at tests/native-lib/pass/ptr_write_access.rs:LL:CC +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass-dep/libc/fcntl_f-fullfsync_apple.stderr b/src/tools/miri/tests/pass-dep/libc/fcntl_f-fullfsync_apple.stderr index 09a24e1e5d74d..718ddf4e7f459 100644 --- a/src/tools/miri/tests/pass-dep/libc/fcntl_f-fullfsync_apple.stderr +++ b/src/tools/miri/tests/pass-dep/libc/fcntl_f-fullfsync_apple.stderr @@ -1,2 +1,4 @@ warning: `fcntl` was made to return an error due to isolation +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass-dep/libc/libc-fs-with-isolation.stderr b/src/tools/miri/tests/pass-dep/libc/libc-fs-with-isolation.stderr index b0cadfb970bf3..a3ed50bd9a65f 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-fs-with-isolation.stderr +++ b/src/tools/miri/tests/pass-dep/libc/libc-fs-with-isolation.stderr @@ -2,3 +2,5 @@ warning: `readlink` was made to return an error due to isolation warning: `$STAT` was made to return an error due to isolation +warning: 2 warnings emitted + diff --git a/src/tools/miri/tests/pass-dep/libc/libc-socket-invalid-addr.stderr b/src/tools/miri/tests/pass-dep/libc/libc-socket-invalid-addr.stderr index 4eea2b6d24fb3..ae73ce17e7ab8 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-socket-invalid-addr.stderr +++ b/src/tools/miri/tests/pass-dep/libc/libc-socket-invalid-addr.stderr @@ -6,3 +6,5 @@ LL | unsafe { libc::getaddrinfo(node_c_str.as_ptr(), service_c_str.as_pt | = note: Miri cannot return proper error information from this call; only a generic error code is being returned +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass-dep/libc/libc-socket-with-isolation.stderr b/src/tools/miri/tests/pass-dep/libc/libc-socket-with-isolation.stderr index 36fc0a5aac328..f7cfb6138cdcc 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-socket-with-isolation.stderr +++ b/src/tools/miri/tests/pass-dep/libc/libc-socket-with-isolation.stderr @@ -1,2 +1,4 @@ warning: `socket` was made to return an error due to isolation +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass/extern_types.stack.stderr b/src/tools/miri/tests/pass/extern_types.stack.stderr index 88825169e1cd7..c1a66d92a7241 100644 --- a/src/tools/miri/tests/pass/extern_types.stack.stderr +++ b/src/tools/miri/tests/pass/extern_types.stack.stderr @@ -7,3 +7,5 @@ LL | let x: &Foo = unsafe { &*(ptr::without_provenance::<()>(16) as *const F = help: `extern type` are not compatible with the Stacked Borrows aliasing model implemented by Miri; Miri may miss bugs in this code = help: try running with `MIRIFLAGS=-Zmiri-tree-borrows` to use the more permissive but also even more experimental Tree Borrows aliasing checks instead +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass/open_a_file_in_proc.stderr b/src/tools/miri/tests/pass/open_a_file_in_proc.stderr index c80b11ecb37bb..1667200204ac7 100644 --- a/src/tools/miri/tests/pass/open_a_file_in_proc.stderr +++ b/src/tools/miri/tests/pass/open_a_file_in_proc.stderr @@ -30,3 +30,5 @@ LL | let fd = cvt_r(|| unsafe { open64(path.as_ptr(), flags, opts.mode a 11: main at tests/pass/open_a_file_in_proc.rs:LL:CC +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass/shims/env/current_dir_with_isolation.stderr b/src/tools/miri/tests/pass/shims/env/current_dir_with_isolation.stderr index 589ca65a1e47e..6133368b01859 100644 --- a/src/tools/miri/tests/pass/shims/env/current_dir_with_isolation.stderr +++ b/src/tools/miri/tests/pass/shims/env/current_dir_with_isolation.stderr @@ -2,3 +2,5 @@ warning: `$GETCWD` was made to return an error due to isolation warning: `$SETCWD` was made to return an error due to isolation +warning: 2 warnings emitted + diff --git a/src/tools/miri/tests/pass/shims/fs-with-isolation.stderr b/src/tools/miri/tests/pass/shims/fs-with-isolation.stderr index 452c5b9b772aa..abcb6221af214 100644 --- a/src/tools/miri/tests/pass/shims/fs-with-isolation.stderr +++ b/src/tools/miri/tests/pass/shims/fs-with-isolation.stderr @@ -14,3 +14,5 @@ warning: `rmdir` was made to return an error due to isolation warning: `opendir` was made to return an error due to isolation +warning: 8 warnings emitted + diff --git a/src/tools/miri/tests/pass/shims/socket-address.stderr b/src/tools/miri/tests/pass/shims/socket-address.stderr index 7091c3b6c6d5a..12b7aa1514c87 100644 --- a/src/tools/miri/tests/pass/shims/socket-address.stderr +++ b/src/tools/miri/tests/pass/shims/socket-address.stderr @@ -23,3 +23,5 @@ LL | cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &m 7: main at tests/pass/shims/socket-address.rs:LL:CC +warning: 1 warning emitted + From e8c3f617035576f93217f9afd42570f73b1083b8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 8 Aug 2026 21:31:03 +0200 Subject: [PATCH 04/13] fix unused features in Miri tests --- src/tools/miri/tests/pass-dep/shims/gettid.rs | 1 + src/tools/miri/tests/pass/async-closure-drop.rs | 2 +- src/tools/miri/tests/pass/async-closure.rs | 2 -- src/tools/miri/tests/pass/async-drop.rs | 2 +- src/tools/miri/tests/pass/both_borrows/basic_aliasing_model.rs | 2 +- .../pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr | 2 ++ .../tests/pass/stacked_borrows/coroutine-self-referential.rs | 2 +- src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs | 1 - 8 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/miri/tests/pass-dep/shims/gettid.rs b/src/tools/miri/tests/pass-dep/shims/gettid.rs index 2522a15219148..90e456d27f523 100644 --- a/src/tools/miri/tests/pass-dep/shims/gettid.rs +++ b/src/tools/miri/tests/pass-dep/shims/gettid.rs @@ -3,6 +3,7 @@ //@ [without_isolation] compile-flags: -Zmiri-disable-isolation #![feature(linkage)] +#![allow(unused_features)] // only used on some targets fn gettid() -> u64 { cfg_select! { diff --git a/src/tools/miri/tests/pass/async-closure-drop.rs b/src/tools/miri/tests/pass/async-closure-drop.rs index d1fd92814d950..4cf25c65af9ab 100644 --- a/src/tools/miri/tests/pass/async-closure-drop.rs +++ b/src/tools/miri/tests/pass/async-closure-drop.rs @@ -1,4 +1,4 @@ -#![feature(async_fn_traits, async_trait_bounds)] +#![feature(async_trait_bounds)] use std::future::Future; use std::pin::pin; diff --git a/src/tools/miri/tests/pass/async-closure.rs b/src/tools/miri/tests/pass/async-closure.rs index 5067f1d2d8e78..c67af28b37802 100644 --- a/src/tools/miri/tests/pass/async-closure.rs +++ b/src/tools/miri/tests/pass/async-closure.rs @@ -1,5 +1,3 @@ -#![feature(async_fn_traits)] - use std::future::Future; use std::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; use std::pin::pin; diff --git a/src/tools/miri/tests/pass/async-drop.rs b/src/tools/miri/tests/pass/async-drop.rs index 3461af5bededf..0291c74a75650 100644 --- a/src/tools/miri/tests/pass/async-drop.rs +++ b/src/tools/miri/tests/pass/async-drop.rs @@ -7,7 +7,7 @@ // please consider modifying rustc's async drop test at // `tests/ui/async-await/async-drop/async-drop-initial.rs`. -#![feature(async_drop, impl_trait_in_assoc_type)] +#![feature(async_drop)] #![allow(incomplete_features, dead_code)] // FIXME(zetanumbers): consider AsyncDestruct::async_drop cleanup tests diff --git a/src/tools/miri/tests/pass/both_borrows/basic_aliasing_model.rs b/src/tools/miri/tests/pass/both_borrows/basic_aliasing_model.rs index 5689ad0e62e2b..da984fe133689 100644 --- a/src/tools/miri/tests/pass/both_borrows/basic_aliasing_model.rs +++ b/src/tools/miri/tests/pass/both_borrows/basic_aliasing_model.rs @@ -1,7 +1,7 @@ //@revisions: stack tree tree_implicit_writes //@[tree_implicit_writes]compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(allocator_api)] + use std::alloc::{Layout, alloc, dealloc}; use std::cell::Cell; use std::ptr; diff --git a/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr b/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr index 171bf0c82d511..7ec8b04cfce01 100644 --- a/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr +++ b/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr @@ -3,3 +3,5 @@ warning: target feature `sse2` must be enabled to ensure that the ABI of the cur = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116344 +warning: 1 warning emitted + diff --git a/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs b/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs index 72e360fe19a1f..4fef797d7c282 100644 --- a/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs +++ b/src/tools/miri/tests/pass/stacked_borrows/coroutine-self-referential.rs @@ -1,6 +1,6 @@ // See https://github.com/rust-lang/unsafe-code-guidelines/issues/148: // this fails when Stacked Borrows is strictly applied even to `!Unpin` types. -#![feature(coroutines, coroutine_trait, stmt_expr_attributes)] +#![feature(coroutines, coroutine_trait)] use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; diff --git a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs index 4bcaf823e99ca..2672294220ab6 100644 --- a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs +++ b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs @@ -1,7 +1,6 @@ //@revisions: tree tree_implicit_writes //@[tree_implicit_writes]compile-flags: -Zmiri-tree-borrows-implicit-writes //@compile-flags: -Zmiri-tree-borrows -#![feature(allocator_api)] use std::{mem, ptr}; From f61d3175e11c17481fed96e6f5f0d6cd12ab1b63 Mon Sep 17 00:00:00 2001 From: Tim Vilgot Mikael Fredenberg Date: Sun, 9 Aug 2026 07:36:38 +0200 Subject: [PATCH 05/13] rustc-book: update sys-v abi link --- src/doc/rustc/src/codegen-options/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 3c7577b9135e6..909bc6f356126 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -12,7 +12,7 @@ may be able to use more compact addressing modes. The specific ranges depend on target architectures and addressing modes available to them. \ For x86 more detailed description of its code models can be found in -[System V Application Binary Interface](https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf) +[System V Application Binary Interface](https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build) specification. Supported values for this option are: From c1bfb4b5587e7cf4ece8b30ec49ca424d08e205d Mon Sep 17 00:00:00 2001 From: fereidani Date: Sat, 8 Aug 2026 16:58:56 +0330 Subject: [PATCH 06/13] Improve overflow check code generation further --- library/alloc/src/sync.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 2a8ab5c646217..82b05aed8c31e 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -55,9 +55,12 @@ use crate::vec::Vec; /// See comment in `Arc::clone`. const MAX_REFCOUNT: usize = (isize::MAX) as usize; -#[inline(always)] -fn enforce_overflow_limit(n: usize) { - assert!(n <= MAX_REFCOUNT, "Arc counter overflow"); +#[cold] +#[cfg_attr(not(panic = "immediate-abort"), inline(never))] +#[cfg_attr(panic = "immediate-abort", inline)] +#[track_caller] +fn panic_arc_overflow() -> ! { + panic!("Arc counter overflow"); } #[cfg(not(sanitize = "thread"))] @@ -1956,8 +1959,9 @@ impl Arc { } // We can't allow the refcount to increase much past `MAX_REFCOUNT`. - enforce_overflow_limit(cur); - + if cur > MAX_REFCOUNT { + panic_arc_overflow(); + } // NOTE: this code currently ignores the possibility of overflow // into usize::MAX; in general both Rc and Arc need to be adjusted // to deal with overflow. @@ -3313,7 +3317,9 @@ impl Weak { return None; } // See comments in `Arc::clone` for why we do this (for `mem::forget`). - enforce_overflow_limit(n); + if n > MAX_REFCOUNT { + panic_arc_overflow(); + } Some(n + 1) } From dd905cd1118463d1ee4546f016199dad517f6ccb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 10 Aug 2026 09:58:30 -0700 Subject: [PATCH 07/13] std: Adjust cfgs again for TLS on WASI This commit adjusts the changes made in 159733. A wasi-libc bug was discovered in 160828 which is present in certain situations which means that the changes in 159733 expose this bug. The purpose of this PR is to get wasip1/wasip2 targets fixed again while preserving a working implementation for wasip3. This upstream bug is already fixed in wasi-libc meaning that this PR won't be necessary once wasi-sdk-34 is published and used in rust-lang/rust. Until that time, however, this effectively reverts 159733 for wasip1/wasip2. The wasip3 target is Tier 3 still and requires wasi-sdk-34 anyway which is why that's left unchanged. Closes 160828 --- library/std/src/sys/thread_local/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/std/src/sys/thread_local/mod.rs b/library/std/src/sys/thread_local/mod.rs index cb954e475be1b..3ccfdd27ee833 100644 --- a/library/std/src/sys/thread_local/mod.rs +++ b/library/std/src/sys/thread_local/mod.rs @@ -25,7 +25,7 @@ cfg_select! { any( - all(target_family = "wasm", not(target_feature = "atomics"), not(target_os = "wasi")), + all(target_family = "wasm", not(target_feature = "atomics"), not(target_env = "p3")), target_os = "uefi", target_os = "zkvm", target_os = "trusty", @@ -56,7 +56,7 @@ cfg_select! { /// single callback that runs all of the destructors in the list. #[cfg(all( target_thread_local, - not(all(target_family = "wasm", not(target_feature = "atomics"), not(target_os = "wasi"))) + not(all(target_family = "wasm", not(target_feature = "atomics"), not(target_env = "p3"))) ))] pub(crate) mod destructors { cfg_select! { @@ -96,7 +96,7 @@ pub(crate) mod guard { pub(crate) use windows::enable; } any( - all(target_family = "wasm", not(target_os = "wasi")), + all(target_family = "wasm", not(target_env = "p3")), target_os = "uefi", target_os = "zkvm", target_os = "trusty", @@ -151,7 +151,7 @@ pub(crate) mod key { ), all(not(target_thread_local), target_vendor = "apple"), target_os = "teeos", - target_os = "wasi", + all(target_os = "wasi", target_env = "p3"), ) => { mod racy; mod unix; From 0166f5056a311d91cd38a8e3199a7ae8b84a05c4 Mon Sep 17 00:00:00 2001 From: Pranav Dronavalli Date: Mon, 10 Aug 2026 15:51:38 -0500 Subject: [PATCH 08/13] Add rust_analyzer to check-cfg names --- compiler/rustc_session/src/config/cfg.rs | 1 + tests/rustdoc-ui/doc-cfg-2.stderr | 2 +- tests/ui/check-cfg/cargo-build-script.stderr | 2 +- tests/ui/check-cfg/cargo-feature.none.stderr | 2 +- tests/ui/check-cfg/cargo-feature.some.stderr | 2 +- tests/ui/check-cfg/cfg-select.stderr | 2 +- .../cfg-value-for-cfg-name-duplicate.stderr | 2 +- .../cfg-value-for-cfg-name-multiple.stderr | 2 +- .../exhaustive-names-values.feature.stderr | 2 +- .../exhaustive-names-values.full.stderr | 2 +- tests/ui/check-cfg/hrtb-crash.stderr | 2 +- tests/ui/check-cfg/mix.stderr | 2 +- tests/ui/check-cfg/nested-cfg.stderr | 2 +- .../check-cfg/raw-keywords.edition2015.stderr | 2 +- .../check-cfg/raw-keywords.edition2021.stderr | 2 +- .../report-in-external-macros.cargo.stderr | 2 +- .../report-in-external-macros.rustc.stderr | 2 +- tests/ui/check-cfg/well-known-names.stderr | 1 + tests/ui/check-cfg/well-known-values.rs | 2 + tests/ui/check-cfg/well-known-values.stderr | 51 +++++++++++-------- tests/ui/macros/cfg.stderr | 2 +- tests/ui/macros/cfg_select.stderr | 2 +- 22 files changed, 53 insertions(+), 38 deletions(-) diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index e5c874503a00f..a6decd5898689 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -391,6 +391,7 @@ impl CheckCfg { ins!(sym::doc, no_values); ins!(sym::doctest, no_values); ins!(sym::miri, no_values); + ins!(sym::rust_analyzer, no_values); ins!(sym::rustfmt, no_values); ins!(sym::overflow_checks, no_values); diff --git a/tests/rustdoc-ui/doc-cfg-2.stderr b/tests/rustdoc-ui/doc-cfg-2.stderr index da202ea4809f1..6fc30c718a441 100644 --- a/tests/rustdoc-ui/doc-cfg-2.stderr +++ b/tests/rustdoc-ui/doc-cfg-2.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `foo` LL | #[doc(cfg(foo), cfg(bar))] | ^^^ | - = help: expected names are: `FALSE` and `test` and 33 more + = help: expected names are: `FALSE` and `test` and 34 more = help: to expect this configuration use `--check-cfg=cfg(foo)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cargo-build-script.stderr b/tests/ui/check-cfg/cargo-build-script.stderr index 9694a762a06c4..d36d0909a0ad6 100644 --- a/tests/ui/check-cfg/cargo-build-script.stderr +++ b/tests/ui/check-cfg/cargo-build-script.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo` LL | #[cfg(has_foo)] | ^^^^^^^ | - = help: expected names are: `has_bar` and 33 more + = help: expected names are: `has_bar` and 34 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index 05d2a41238258..130cbc0e1ec45 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `docsrs`, `feature`, and `test` and 33 more + = help: expected names are: `docsrs`, `feature`, and `test` and 34 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index de84eb2932e7e..e6d07b82928db 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 33 more + = help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 34 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cfg-select.stderr b/tests/ui/check-cfg/cfg-select.stderr index e4bc800f7cc07..8769f938d3836 100644 --- a/tests/ui/check-cfg/cfg-select.stderr +++ b/tests/ui/check-cfg/cfg-select.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `invalid_cfg1` LL | invalid_cfg1 => {} | ^^^^^^^^^^^^ | - = help: expected names are: `FALSE` and `test` and 33 more + = help: expected names are: `FALSE` and `test` and 34 more = help: to expect this configuration use `--check-cfg=cfg(invalid_cfg1)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 50ae3d88f61df..576fa0cdbfae0 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value` LL | #[cfg(value)] | ^^^^^ | - = help: expected names are: `bar`, `bee`, `cow`, and `foo` and 33 more + = help: expected names are: `bar`, `bee`, `cow`, and `foo` and 34 more = help: to expect this configuration use `--check-cfg=cfg(value)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index b432d46920a22..66fc5b7e2125b 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value` LL | #[cfg(my_value)] | ^^^^^^^^ | - = help: expected names are: `bar` and `foo` and 33 more + = help: expected names are: `bar` and `foo` and 34 more = help: to expect this configuration use `--check-cfg=cfg(my_value)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 8c0b623d445ed..8e3825f098ff3 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 33 more + = help: expected names are: `feature` and 34 more = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 8c0b623d445ed..8e3825f098ff3 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 33 more + = help: expected names are: `feature` and 34 more = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/hrtb-crash.stderr b/tests/ui/check-cfg/hrtb-crash.stderr index d07dee86d680c..a07e774f5329d 100644 --- a/tests/ui/check-cfg/hrtb-crash.stderr +++ b/tests/ui/check-cfg/hrtb-crash.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `b` LL | for<#[cfg(b)] c> u8:; | ^ help: found config with similar value: `target_feature = "b"` | - = help: expected names are: `FALSE`, `docsrs`, and `test` and 33 more + = help: expected names are: `FALSE`, `docsrs`, and `test` and 34 more = help: to expect this configuration use `--check-cfg=cfg(b)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index bd0ecc2d0ac6b..4d113d37c6c68 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu` LL | #[cfg_attr(uu, unix)] | ^^ | - = help: expected names are: `feature` and 33 more + = help: expected names are: `feature` and 34 more = help: to expect this configuration use `--check-cfg=cfg(uu)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/nested-cfg.stderr b/tests/ui/check-cfg/nested-cfg.stderr index 19dd68753b74e..96a53b1c22ee5 100644 --- a/tests/ui/check-cfg/nested-cfg.stderr +++ b/tests/ui/check-cfg/nested-cfg.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown` LL | #[cfg(unknown)] | ^^^^^^^ | - = help: expected names are: `FALSE` and `test` and 33 more + = help: expected names are: `FALSE` and `test` and 34 more = help: to expect this configuration use `--check-cfg=cfg(unknown)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/raw-keywords.edition2015.stderr b/tests/ui/check-cfg/raw-keywords.edition2015.stderr index 46e02bfbb3ecd..53b91670b5821 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2015.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2015.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 33 more + = help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 34 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/raw-keywords.edition2021.stderr b/tests/ui/check-cfg/raw-keywords.edition2021.stderr index 3e108debfcf8b..c5900a12ed008 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2021.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2021.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 33 more + = help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 34 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr index 646c814ef65f6..1d5be70dbcd77 100644 --- a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 33 more + = help: expected names are: `feature` and 34 more = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr index d38f3560063ac..1ac657131ad45 100644 --- a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 33 more + = help: expected names are: `feature` and 34 more = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)` diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 3f68bca37dd5d..31685126aac8f 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -15,6 +15,7 @@ LL | #[cfg(list_all_well_known_cfgs)] `panic` `proc_macro` `relocation_model` +`rust_analyzer` `rustfmt` `sanitize` `sanitizer_cfi_generalize_pointers` diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index c10139570570b..54157fe6f4e46 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -47,6 +47,8 @@ //~^ WARN unexpected `cfg` condition value relocation_model = "_UNEXPECTED_VALUE", //~^ WARN unexpected `cfg` condition value + rust_analyzer = "_UNEXPECTED_VALUE", + //~^ WARN unexpected `cfg` condition value rustfmt = "_UNEXPECTED_VALUE", //~^ WARN unexpected `cfg` condition value sanitize = "_UNEXPECTED_VALUE", diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 693833decc971..3d6422fe5f380 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -106,6 +106,17 @@ LL | relocation_model = "_UNEXPECTED_VALUE", warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:50:5 | +LL | rust_analyzer = "_UNEXPECTED_VALUE", + | ^^^^^^^^^^^^^---------------------- + | | + | help: remove the value + | + = note: no expected value for `rust_analyzer` + = note: see for more information about checking conditional configuration + +warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` + --> $DIR/well-known-values.rs:52:5 + | LL | rustfmt = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- | | @@ -115,7 +126,7 @@ LL | rustfmt = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:52:5 + --> $DIR/well-known-values.rs:54:5 | LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,7 +135,7 @@ LL | sanitize = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:54:5 + --> $DIR/well-known-values.rs:56:5 | LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +144,7 @@ LL | target_abi = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:56:5 + --> $DIR/well-known-values.rs:58:5 | LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,7 +153,7 @@ LL | target_arch = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:58:5 + --> $DIR/well-known-values.rs:60:5 | LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -151,7 +162,7 @@ LL | target_endian = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:60:5 + --> $DIR/well-known-values.rs:62:5 | LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -160,7 +171,7 @@ LL | target_env = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:62:5 + --> $DIR/well-known-values.rs:64:5 | LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +180,7 @@ LL | target_family = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:66:5 + --> $DIR/well-known-values.rs:68:5 | LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +189,7 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:68:5 + --> $DIR/well-known-values.rs:70:5 | LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -187,7 +198,7 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:70:5 + --> $DIR/well-known-values.rs:72:5 | LL | target_has_atomic_primitive_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -196,7 +207,7 @@ LL | target_has_atomic_primitive_alignment = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:72:5 + --> $DIR/well-known-values.rs:74:5 | LL | target_has_threads = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^---------------------- @@ -207,7 +218,7 @@ LL | target_has_threads = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:74:5 + --> $DIR/well-known-values.rs:76:5 | LL | target_object_format = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -216,7 +227,7 @@ LL | target_object_format = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:76:5 + --> $DIR/well-known-values.rs:78:5 | LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +236,7 @@ LL | target_os = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:78:5 + --> $DIR/well-known-values.rs:80:5 | LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -234,7 +245,7 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:80:5 + --> $DIR/well-known-values.rs:82:5 | LL | target_thread_local = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^---------------------- @@ -245,7 +256,7 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:82:5 + --> $DIR/well-known-values.rs:84:5 | LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -254,7 +265,7 @@ LL | target_vendor = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:84:5 + --> $DIR/well-known-values.rs:86:5 | LL | ub_checks = "_UNEXPECTED_VALUE", | ^^^^^^^^^---------------------- @@ -265,7 +276,7 @@ LL | ub_checks = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:86:5 + --> $DIR/well-known-values.rs:88:5 | LL | unix = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -276,7 +287,7 @@ LL | unix = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:88:5 + --> $DIR/well-known-values.rs:90:5 | LL | windows = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -287,7 +298,7 @@ LL | windows = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` - --> $DIR/well-known-values.rs:94:7 + --> $DIR/well-known-values.rs:96:7 | LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | ^^^^^^^^^^^^------- @@ -297,5 +308,5 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qnx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration -warning: 30 warnings emitted +warning: 31 warnings emitted diff --git a/tests/ui/macros/cfg.stderr b/tests/ui/macros/cfg.stderr index b4c7cd3306d26..05fdae02a0161 100644 --- a/tests/ui/macros/cfg.stderr +++ b/tests/ui/macros/cfg.stderr @@ -46,7 +46,7 @@ warning: unexpected `cfg` condition name: `foo` LL | cfg!(foo); | ^^^ | - = help: expected names are: `FALSE` and `test` and 33 more + = help: expected names are: `FALSE` and `test` and 34 more = help: to expect this configuration use `--check-cfg=cfg(foo)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr index 1a72e7a9c0ace..8e09aa4da93f3 100644 --- a/tests/ui/macros/cfg_select.stderr +++ b/tests/ui/macros/cfg_select.stderr @@ -169,7 +169,7 @@ warning: unexpected `cfg` condition name: `a` LL | a + 1 => {} | ^ help: found config with similar value: `target_feature = "a"` | - = help: expected names are: `FALSE` and `test` and 33 more + = help: expected names are: `FALSE` and `test` and 34 more = help: to expect this configuration use `--check-cfg=cfg(a)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default From 1d06f70696b7742c94d8a7a5a79df34a52f86dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 11 Aug 2026 09:25:05 +0200 Subject: [PATCH 09/13] Allow running an arbitrary number of try jobs per PR --- src/ci/citool/src/jobs.rs | 12 +++++--- src/ci/citool/src/main.rs | 63 +++++++++++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/ci/citool/src/jobs.rs b/src/ci/citool/src/jobs.rs index cc93761e9604e..8b4f66c85761a 100644 --- a/src/ci/citool/src/jobs.rs +++ b/src/ci/citool/src/jobs.rs @@ -271,7 +271,11 @@ pub enum RunType { /// Workflows that run after a push to a PR branch PullRequest, /// Try run started with @bors try - TryJob { job_patterns: Option> }, + TryJob { + job_patterns: Option>, + /// Should the limit on the number of try jobs be ignored? + nolimit: bool, + }, /// Merge attempt workflow AutoJob, /// Fake job only used for sharing Github Actions cache. @@ -289,7 +293,7 @@ fn calculate_jobs( ) -> anyhow::Result> { let (jobs, prefix, base_env) = match run_type { RunType::PullRequest => (db.pr_jobs.clone(), "PR", &db.envs.pr_env), - RunType::TryJob { job_patterns } => { + RunType::TryJob { job_patterns, nolimit } => { let jobs = if let Some(patterns) = job_patterns { let mut jobs: Vec = vec![]; let mut unknown_patterns = vec![]; @@ -311,7 +315,7 @@ fn calculate_jobs( unknown_patterns.join(", ") )); } - if jobs.len() > MAX_TRY_JOBS_COUNT { + if jobs.len() > MAX_TRY_JOBS_COUNT && !nolimit { return Err(anyhow::anyhow!( "It is only possible to schedule up to {MAX_TRY_JOBS_COUNT} custom jobs, received {} custom jobs expanded from {} pattern(s)", jobs.len(), @@ -342,7 +346,7 @@ fn calculate_jobs( // built toolchain using `rustup-toolchain-install-master`), // we inject the `DIST_TRY_BUILD` environment variable to the jobs // to tell `opt-dist` to make the build faster by skipping certain steps. - if let RunType::TryJob { job_patterns } = run_type { + if let RunType::TryJob { job_patterns, nolimit: _ } = run_type { if job_patterns.is_none() { env.insert( "DIST_TRY_BUILD".to_string(), diff --git a/src/ci/citool/src/main.rs b/src/ci/citool/src/main.rs index 8afda476ea68f..b8d8c18213948 100644 --- a/src/ci/citool/src/main.rs +++ b/src/ci/citool/src/main.rs @@ -30,6 +30,12 @@ const CI_DIRECTORY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/.."); pub const DOCKER_DIRECTORY: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../docker"); const JOBS_YML_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../github-actions/jobs.yml"); +#[derive(Default)] +struct TryJobMetadata { + job_patterns: Vec, + nolimit: bool, +} + struct GitHubContext { event_name: String, branch_ref: String, @@ -41,12 +47,16 @@ impl GitHubContext { match (self.event_name.as_str(), self.branch_ref.as_str()) { ("pull_request", _) => Some(RunType::PullRequest), ("push", "refs/heads/automation/bors/try-perf" | "refs/heads/try-perf") => { - Some(RunType::TryJob { job_patterns: None }) + Some(RunType::TryJob { job_patterns: None, nolimit: false }) } ("push", "refs/heads/automation/bors/try") => { - let patterns = self.get_try_job_patterns(); - let patterns = if !patterns.is_empty() { Some(patterns) } else { None }; - Some(RunType::TryJob { job_patterns: patterns }) + let metadata = self.get_try_job_metadata(); + let patterns = if !metadata.job_patterns.is_empty() { + Some(metadata.job_patterns) + } else { + None + }; + Some(RunType::TryJob { job_patterns: patterns, nolimit: metadata.nolimit }) } ("push", "refs/heads/automation/bors/auto") => Some(RunType::AutoJob), ("push", "refs/heads/main") => Some(RunType::MainJob), @@ -54,25 +64,46 @@ impl GitHubContext { } } - /// Tries to parse patterns of CI jobs that should be executed - /// from the commit message of the passed GitHub context + /// Tries to parse metadata about try jobs from the commit message. + /// + /// Currently, two things can be specified. + /// + /// # Try job patterns + /// The first is a set of patterns of CI jobs that should be executed. /// /// They can be specified in the form of /// try-job: /// or /// try-job: `` /// (to avoid GitHub rendering the glob patterns as Markdown) - fn get_try_job_patterns(&self) -> Vec { - if let Some(ref msg) = self.commit_message { - msg.lines() - .filter_map(|line| line.trim().strip_prefix("try-job: ")) - // Strip backticks if present - .map(|l| l.trim_matches('`')) - .map(|l| l.trim().to_string()) - .collect() - } else { - vec![] + /// + /// # No limit + /// The second is a marker that specifies that the limit on the maximum number of allowed try + /// jobs to execute should NOT be applied. + /// + /// try-nolimit + fn get_try_job_metadata(&self) -> TryJobMetadata { + let Some(commit_msg) = &self.commit_message else { + return TryJobMetadata::default(); + }; + + let mut nolimit = false; + let mut job_patterns = vec![]; + + for line in commit_msg.lines() { + let line = line.trim(); + if line.starts_with("try-nolimit") { + nolimit = true; + continue; + } + let Some(pattern) = line.strip_prefix("try-job: ") else { + continue; + }; + // Strip backticks if present + let pattern = pattern.trim_matches('`'); + job_patterns.push(pattern.trim().to_string()); } + TryJobMetadata { job_patterns, nolimit } } } From 91de2e36f1515134a2a8082f9666021785d3e20d Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 11 Aug 2026 14:45:44 +0200 Subject: [PATCH 10/13] tests/run-make-cargo/thumb-none-cortex-m: bump `cortex-m` dependency the previous version, v0.5.0 (from 2018), does not include a Cargo lockfile which makes the test brittle as bugs and unintentional breaking changes in any new release of a dependency can make the test fail the newly chosen version, v0.7.7, includes a Cargo lockfile --- tests/run-make-cargo/thumb-none-cortex-m/rmake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-make-cargo/thumb-none-cortex-m/rmake.rs b/tests/run-make-cargo/thumb-none-cortex-m/rmake.rs index 6158b9c36da24..92b832599970b 100644 --- a/tests/run-make-cargo/thumb-none-cortex-m/rmake.rs +++ b/tests/run-make-cargo/thumb-none-cortex-m/rmake.rs @@ -18,7 +18,7 @@ use run_make_support::{cargo, cmd, env, env_var, target}; const CRATE: &str = "cortex-m"; const CRATE_URL: &str = "https://github.com/rust-embedded/cortex-m"; -const CRATE_SHA1: &str = "a448e9156e2cb1e556e5441fd65426952ef4b927"; // v0.5.0 +const CRATE_SHA1: &str = "bb4a78208323260a161e68b2498438867f971bc5"; // v0.7.7 fn main() { // FIXME: requires an internet connection https://github.com/rust-lang/rust/issues/128733 From 6408d389fc3b43e4710a318b991c93014bd6cc8d Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 10 Aug 2026 08:20:14 -0400 Subject: [PATCH 11/13] Add -Zwasm-proc-macro flag This is currently not really implemented, but partial support for it is added in various places across the tree. This is a patch extracted from the wider set of work to make review easier, which wires up: * Unstable flag in rustc * Bootstrap flag to enable using wasm-proc-macros (this needs an extra std compilation, wiring into compiletest) * Partial compiletest support for the flag (mostly just CLI side of things) --- bootstrap.example.toml | 12 +++++++++ compiler/rustc_interface/src/diagnostics.rs | 4 +++ compiler/rustc_interface/src/passes.rs | 6 +++++ compiler/rustc_interface/src/tests.rs | 1 + compiler/rustc_session/src/options.rs | 2 ++ src/bootstrap/src/core/build_steps/test.rs | 12 +++++++++ src/bootstrap/src/core/config/config.rs | 4 +++ src/bootstrap/src/core/config/toml/rust.rs | 2 ++ src/bootstrap/src/utils/cc_detect.rs | 11 ++++++-- .../src/compiler-flags/wasm-proc-macros.md | 8 ++++++ src/tools/compiletest/src/cli.rs | 6 +++++ src/tools/compiletest/src/common.rs | 2 ++ src/tools/compiletest/src/directives/cfg.rs | 6 +++++ .../src/directives/directive_names.rs | 2 ++ src/tools/compiletest/src/runtest.rs | 27 ++++++++++++++++++- src/tools/compiletest/src/rustdoc_gui_test.rs | 1 + 16 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 src/doc/unstable-book/src/compiler-flags/wasm-proc-macros.md diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 3752f1bcc2ce6..418c5a4a9cb81 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -944,6 +944,18 @@ # because bootstrap will attempt to download the JSON docs data for this commit from its CI. #rust.stdlib-semver-baseline = "" +# Enables building a wasm proc macro compatible toolchain. +# +# This requires building an additional standard library for a different target and adding it +# to the sysroot before running tests, and so needs special handling in bootstrap. Currently +# off by default. +# +# This currently opts compiletest into running/building proc-macro tests via wasm. +# +# The implementation for this has not finished landing, so you probably don't +# want to enable this right now. +#rust.wasm-proc-macros = false + # ============================================================================= # Distribution options # diff --git a/compiler/rustc_interface/src/diagnostics.rs b/compiler/rustc_interface/src/diagnostics.rs index 44d6073b93037..9e6d4317c98e5 100644 --- a/compiler/rustc_interface/src/diagnostics.rs +++ b/compiler/rustc_interface/src/diagnostics.rs @@ -53,6 +53,10 @@ pub(crate) struct MixedBinCrate; #[diag("cannot mix `proc-macro` crate type with others")] pub(crate) struct MixedProcMacroCrate; +#[derive(Diagnostic)] +#[diag("cannot compile `proc-macro` crate to wasm targets without -Zwasm-proc-macros")] +pub(crate) struct UnstableWasmProcMacro; + #[derive(Diagnostic)] #[diag("error writing dependencies to `{$path}`: {$error}")] pub(crate) struct ErrorWritingDependencies<'a> { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index cdba198297201..e54739043580f 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -275,6 +275,12 @@ fn configure_and_expand( sess.dcx().emit_err(diagnostics::MixedProcMacroCrate); } } + + if is_proc_macro_crate && sess.target.is_like_wasm && !sess.opts.unstable_opts.wasm_proc_macros + { + sess.dcx().emit_err(diagnostics::UnstableWasmProcMacro); + } + if crate_types.contains(&CrateType::Sdylib) && !tcx.features().export_stable() { feature_err(sess, sym::export_stable, DUMMY_SP, "`sdylib` crate type is unstable").emit(); } diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index f3a6dfea5959e..548ee3f4b8e7b 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -910,6 +910,7 @@ fn test_unstable_options_tracking_hash() { tracked!(verify_llvm_ir, true); tracked!(virtual_function_elimination, true); tracked!(wasi_exec_model, Some(WasiExecModel::Reactor)); + tracked!(wasm_proc_macros, true); // tidy-alphabetical-end macro_rules! tracked_no_crate_hash { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index b3023c731eeff..20d1ff55eab6e 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2979,6 +2979,8 @@ written to standard error output)"), // FIXME remove this after a couple releases wasm_c_abi: () = ((), parse_wasm_c_abi, [TRACKED], "use spec-compliant C ABI for `wasm32-unknown-unknown` (deprecated, always enabled)"), + wasm_proc_macros: bool = (false, parse_bool, [TRACKED], + "enable support for compiling and loading wasm proc macros"), write_long_types_to_disk: bool = (true, parse_bool, [UNTRACKED], "whether long type names should be written to files instead of being printed in errors"), // tidy-alphabetical-end diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 6658087bae78c..dca3220acda55 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2277,6 +2277,14 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the builder.ensure(compile::Rustc::new(test_compiler, target)); } + // Build the standard library for wasm32-wasip2 (current target for wasm proc macros). + if builder.config.wasm_proc_macros { + builder.ensure(compile::Std::new( + test_compiler, + TargetSelection::from_user("wasm32-wasip2"), + )); + } + if suite == "debuginfo" { builder.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(test_compiler).to_path_buf(), @@ -2326,6 +2334,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the let is_rustdoc = suite == "rustdoc-ui" || suite == "rustdoc-js"; + if builder.config.wasm_proc_macros { + cmd.arg("--wasm-proc-macros"); + } + // There are (potentially) 2 `cargo`s to consider: // // - A "bootstrap" cargo, which is the same cargo used to build bootstrap itself, and is diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 4bc9de932f98f..fa10de3c92fac 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -343,6 +343,8 @@ pub struct Config { pub skip_std_check_if_no_download_rustc: bool, pub exec_ctx: ExecutionContext, + + pub wasm_proc_macros: bool, } impl Config { @@ -615,6 +617,7 @@ impl Config { break_on_ice: rust_break_on_ice, rustflags: rust_rustflags, stdlib_semver_baseline: rust_stdlib_semver_baseline, + wasm_proc_macros, } = toml_rust.unwrap_or_default(); let Llvm { @@ -1611,6 +1614,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to .unwrap_or(rust_debug == Some(true)), vendor, verbose_tests, + wasm_proc_macros: wasm_proc_macros.unwrap_or(false), windows_rc: build_windows_rc.map(PathBuf::from), yarn: build_yarn.map(PathBuf::from), // tidy-alphabetical-end diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 33516fcbc9e4c..d0954e3ad70a5 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -75,6 +75,7 @@ define_config! { break_on_ice: Option = "break-on-ice", parallel_frontend_threads: Option = "parallel-frontend-threads", stdlib_semver_baseline: Option = "stdlib-semver-baseline", + wasm_proc_macros: Option = "wasm-proc-macros", } } @@ -393,6 +394,7 @@ pub fn check_incompatible_options_for_ci_rustc( bootstrap_override_lld: _, rustflags: _, stdlib_semver_baseline: _, + wasm_proc_macros: _, } = ci_rust_config; // There are two kinds of checks for CI rustc incompatible options: diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 3c05302950844..86fe5cf946071 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -68,7 +68,7 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { /// by combining the primary build target, host targets, and any additional targets. For /// each target, it calls [`fill_target_compiler`] to configure the necessary compiler tools. pub fn fill_compilers(build: &mut Build) { - let targets: HashSet<_> = match build.config.cmd { + let mut targets: HashSet<_> = match build.config.cmd { // We don't need to check cross targets for these commands. crate::Subcommand::Clean { .. } | crate::Subcommand::Check { .. } @@ -90,7 +90,14 @@ pub fn fill_compilers(build: &mut Build) { } }; - for target in targets.into_iter() { + // When we intend to build wasm proc macros, we'll need to detect a toolchain for linking those + // as well. In the future it would be good to make this a no-op given that we shouldn't need to + // build any C/C++ code for wasm... + if build.config.wasm_proc_macros { + targets.insert(TargetSelection::from_user("wasm32-wasip2")); + } + + for target in targets { fill_target_compiler(build, target); } } diff --git a/src/doc/unstable-book/src/compiler-flags/wasm-proc-macros.md b/src/doc/unstable-book/src/compiler-flags/wasm-proc-macros.md new file mode 100644 index 0000000000000..1f47f4373968e --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/wasm-proc-macros.md @@ -0,0 +1,8 @@ +# `wasm-proc-macros` + +This option controls whether to enable support for compiling and loading +`--crate-type=proc-macro` to/from WASM rather than the normal host dylib target. + +Currently we expect that proc macros are compiled to the `wasm32-wasip2` +target. The exact target will likely change in the future. When this flag is +passed, both regular dylib proc macros and wasm proc macros are supported. diff --git a/src/tools/compiletest/src/cli.rs b/src/tools/compiletest/src/cli.rs index 1786c68a1889c..3af7b4dfeaeac 100644 --- a/src/tools/compiletest/src/cli.rs +++ b/src/tools/compiletest/src/cli.rs @@ -281,6 +281,10 @@ struct Args { /// Ignore `//@ ignore-backends` directives. #[arg(long)] bypass_ignore_backends: bool, + /// Build proc-macros for wasm. Assumes environment is configured to support this; e.g., std is + /// already built appropriately. + #[arg(long)] + wasm_proc_macros: bool, // These values can be entered multiple times, for example: // --skip foo --skip bar @@ -503,6 +507,8 @@ pub(crate) fn parse_config(args: Vec) -> Config { gcc_supported_target_tuples, + wasm_proc_macros: args.wasm_proc_macros, + jobs: args.jobs, parallel_frontend_threads, diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index de5c50d234661..c5a631ad94589 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -766,6 +766,8 @@ pub(crate) struct Config { pub(crate) parallel_frontend_threads: u32, /// Number of times to execute each test. pub(crate) iteration_count: u32, + + pub(crate) wasm_proc_macros: bool, } impl Config { diff --git a/src/tools/compiletest/src/directives/cfg.rs b/src/tools/compiletest/src/directives/cfg.rs index b9036462f3447..19e08de1d062a 100644 --- a/src/tools/compiletest/src/directives/cfg.rs +++ b/src/tools/compiletest/src/directives/cfg.rs @@ -235,6 +235,12 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions { ); } + builder.cond( + "wasm-proc-macros", + config.wasm_proc_macros, + "when wasm-proc-macros is enabled in bootstrap.toml", + ); + // Coverage tests run the same test file in multiple modes. // If a particular test should not be run in one of the modes, ignore it // with "ignore-coverage-map" or "ignore-coverage-run". diff --git a/src/tools/compiletest/src/directives/directive_names.rs b/src/tools/compiletest/src/directives/directive_names.rs index b73e782252148..2a6783cbfbf1e 100644 --- a/src/tools/compiletest/src/directives/directive_names.rs +++ b/src/tools/compiletest/src/directives/directive_names.rs @@ -136,6 +136,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "ignore-vxworks", "ignore-wasi", "ignore-wasm", + "ignore-wasm-proc-macros", "ignore-wasm32", "ignore-wasm32-unknown-unknown", "ignore-wasm64", @@ -266,6 +267,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "only-uefi", "only-unix", "only-visionos", + "only-wasm-proc-macros", "only-wasm32", "only-wasm32-unknown-emscripten", "only-wasm32-unknown-unknown", diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 73e3b87b37aa8..8f45e037d0fc9 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1351,7 +1351,27 @@ impl<'test> TestCx<'test> { let mut aux_props = self.props.from_aux_file(&aux_path, self.variant.revision(), self.config); if aux_type == Some(AuxType::ProcMacro) { - aux_props.force_host = true; + if self.config.wasm_proc_macros { + aux_props.compile_flags.push("--target=wasm32-wasip2".to_owned()); + // Override any earlier linkers for now, otherwise we fail to build since compiletest + // thinks we're building for a different target and passes its linker (if one is + // configured). + // + // wasm32-wasip2 should in principle always be able to link with wasm-component-ld + + // wasm-ld. This does mean that rust.lld needs to be enabled to build wasm-ld wrapper + // around rust-lld. + aux_props.compile_flags.push("-Clinker=wasm-component-ld".to_owned()); + aux_props.compile_flags.push(format!( + "-Clink-arg=--wasm-ld-path={}", + self.config + .sysroot_base + .join("lib/rustlib") + .join(&self.config.host) + .join("bin/gcc-ld/wasm-ld") + )); + } else { + aux_props.force_host = true; + } } let mut aux_dir = aux_dir.to_path_buf(); if aux_type == Some(AuxType::Bin) { @@ -1576,6 +1596,11 @@ impl<'test> TestCx<'test> { }; compiler.arg(input_file); + // Enable wasm proc macros. + if self.config.wasm_proc_macros { + compiler.arg("-Zwasm-proc-macros"); + } + // Hide libstd sources from ui tests to make sure we generate the stderr // output that users will see. // Without this, we may be producing good diagnostics in-tree but users diff --git a/src/tools/compiletest/src/rustdoc_gui_test.rs b/src/tools/compiletest/src/rustdoc_gui_test.rs index 7fc37a1a4371d..88880f09837ee 100644 --- a/src/tools/compiletest/src/rustdoc_gui_test.rs +++ b/src/tools/compiletest/src/rustdoc_gui_test.rs @@ -143,5 +143,6 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config { jobs: Default::default(), parallel_frontend_threads: Config::DEFAULT_PARALLEL_FRONTEND_THREADS, iteration_count: Config::DEFAULT_ITERATION_COUNT, + wasm_proc_macros: false, } } From 4789fa3446e2d4339416ed7167ce41e33c372525 Mon Sep 17 00:00:00 2001 From: Pranav Dronavalli Date: Tue, 11 Aug 2026 10:12:03 -0500 Subject: [PATCH 12/13] Update check-cfg documentation --- src/doc/rustc/src/check-cfg.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc/src/check-cfg.md b/src/doc/rustc/src/check-cfg.md index ef791b57895ab..21c8bdfb1877f 100644 --- a/src/doc/rustc/src/check-cfg.md +++ b/src/doc/rustc/src/check-cfg.md @@ -99,7 +99,7 @@ the need to specify them manually. Well known names and values are implicitly added as long as at least one `--check-cfg` argument is present. -As of `2026-05-15T`, the list of known names is as follows: +As of `2026-08-11T`, the list of known names is as follows: @@ -113,6 +113,7 @@ As of `2026-05-15T`, the list of known names is as follows: - `panic` - `proc_macro` - `relocation_model` + - `rust_analyzer` - `rustfmt` - `sanitize` - `sanitizer_cfi_generalize_pointers` From 38ef4c894af725c060d896fe6f35274e7ad4c900 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Tue, 11 Aug 2026 17:42:18 +0200 Subject: [PATCH 13/13] No longer mention the removed generic --- compiler/rustc_abi/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 1e0fd78b4dd75..589c5a5cb1229 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -2383,7 +2383,7 @@ pub enum AbiFromStrErr { NoExplicitUnwind, } -// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. +// NOTE: This struct is generic over the FieldIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone, Debug)] #[cfg_attr(feature = "nightly", derive(StableHash))] pub struct VariantLayout {