From 7813358f9870f8990b9f1c186f15c088f21c3ab9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:13:49 +0200 Subject: [PATCH 01/13] Use cfg_select! for unwinder_private_data_size --- library/panic_unwind/src/gcc.rs | 2 +- library/unwind/src/libunwind.rs | 81 +++++-------------- library/unwind/src/unwinding.rs | 2 +- .../miri/tests/pass/panic/unwind_dwarf.rs | 2 +- 4 files changed, 25 insertions(+), 62 deletions(-) diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index 5f95870069dc5..adcbe5170623c 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -63,7 +63,7 @@ pub(crate) unsafe fn panic(data: Box) -> u32 { _uwe: uw::_Unwind_Exception { exception_class: RUST_EXCEPTION_CLASS, exception_cleanup: Some(exception_cleanup), - private: [core::ptr::null(); uw::unwinder_private_data_size], + private: [core::ptr::null(); _], }, canary: &CANARY, cause: data, diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 6967c7f7f2665..720cbc8de942f 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -24,65 +24,28 @@ pub type _Unwind_Ptr = *const u8; pub type _Unwind_Trace_Fn = extern "C" fn(ctx: *mut _Unwind_Context, arg: *mut c_void) -> _Unwind_Reason_Code; -#[cfg(target_arch = "x86")] -pub const unwinder_private_data_size: usize = 5; - -#[cfg(all(target_arch = "x86_64", not(any(target_os = "windows", target_os = "cygwin"))))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(all(target_arch = "x86_64", any(target_os = "windows", target_os = "cygwin")))] -pub const unwinder_private_data_size: usize = 6; - -#[cfg(all(target_arch = "arm", not(target_vendor = "apple")))] -pub const unwinder_private_data_size: usize = 20; - -#[cfg(all(target_arch = "arm", target_vendor = "apple"))] -pub const unwinder_private_data_size: usize = 5; - -#[cfg(all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows"))] -pub const unwinder_private_data_size: usize = 6; - -#[cfg(all(target_arch = "aarch64", target_pointer_width = "32"))] -pub const unwinder_private_data_size: usize = 5; - -#[cfg(target_arch = "m68k")] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(target_arch = "csky")] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(target_arch = "s390x")] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(all(target_family = "wasm", target_os = "emscripten"))] -pub const unwinder_private_data_size: usize = 20; - -#[cfg(all(target_arch = "wasm32", any(target_os = "linux", target_os = "wasi")))] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(target_arch = "hexagon")] -pub const unwinder_private_data_size: usize = 5; - -#[cfg(any(target_arch = "loongarch32", target_arch = "loongarch64"))] -pub const unwinder_private_data_size: usize = 2; +const unwinder_private_data_size: usize = cfg_select! { + target_arch = "x86" => 5, + all(target_arch = "x86_64", not(any(target_os = "windows", target_os = "cygwin"))) => 2, + all(target_arch = "x86_64", any(target_os = "windows", target_os = "cygwin")) => 6, + all(target_arch = "arm", not(target_vendor = "apple")) => 20, + all(target_arch = "arm", target_vendor = "apple") => 5, + all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")) => 2, + all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows") => 6, + all(target_arch = "aarch64", target_pointer_width = "32") => 5, + target_arch = "m68k" => 2, + any(target_arch = "mips", target_arch = "mips32r6") => 2, + target_arch = "csky" => 2, + any(target_arch = "mips64", target_arch = "mips64r6") => 2, + any(target_arch = "powerpc", target_arch = "powerpc64") => 2, + target_arch = "s390x" => 2, + any(target_arch = "sparc", target_arch = "sparc64") => 2, + any(target_arch = "riscv64", target_arch = "riscv32") => 2, + all(target_family = "wasm", target_os = "emscripten") => 20, + all(target_arch = "wasm32", any(target_os = "linux", target_os = "wasi")) => 2, + target_arch = "hexagon" => 5, + any(target_arch = "loongarch32", target_arch = "loongarch64") => 2, +}; #[repr(C)] pub struct _Unwind_Exception { diff --git a/library/unwind/src/unwinding.rs b/library/unwind/src/unwinding.rs index 36120bc868ee9..ac1140ff040c0 100644 --- a/library/unwind/src/unwinding.rs +++ b/library/unwind/src/unwinding.rs @@ -36,7 +36,7 @@ pub type _Unwind_Exception_Class = u64; pub type _Unwind_Word = *const u8; pub type _Unwind_Ptr = *const u8; -pub const unwinder_private_data_size: usize = size_of::() +const unwinder_private_data_size: usize = size_of::() - size_of::<_Unwind_Exception_Class>() - size_of::<_Unwind_Exception_Cleanup_Fn>(); diff --git a/src/tools/miri/tests/pass/panic/unwind_dwarf.rs b/src/tools/miri/tests/pass/panic/unwind_dwarf.rs index 3631c3f43aea9..aaecacd95ec9a 100644 --- a/src/tools/miri/tests/pass/panic/unwind_dwarf.rs +++ b/src/tools/miri/tests/pass/panic/unwind_dwarf.rs @@ -27,7 +27,7 @@ fn panic(data: Box) -> u32 { _uwe: uw::_Unwind_Exception { exception_class: miri_exception_class(), exception_cleanup: Some(exception_cleanup), - private: [core::ptr::null(); uw::unwinder_private_data_size], + private: [core::ptr::null(); _], }, cause: data, }); From 4866a9c229a0068be889d501885033931c5fa4a1 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 9 Jul 2026 14:24:44 +0200 Subject: [PATCH 02/13] Unify the type definitions for libunwind and the unwinding crate --- library/unwind/src/lib.rs | 5 +- library/unwind/src/libunwind.rs | 23 +++++--- library/unwind/src/unwinding.rs | 100 -------------------------------- 3 files changed, 16 insertions(+), 112 deletions(-) delete mode 100644 library/unwind/src/unwinding.rs diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index 02201f43c08ce..dce3ea8c7e007 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -33,14 +33,11 @@ cfg_select! { target_os = "solid_asp3", all(target_vendor = "fortanix", target_env = "sgx"), all(target_os = "wasi", panic = "unwind"), + target_os = "xous", ) => { mod libunwind; pub use libunwind::*; } - target_os = "xous" => { - mod unwinding; - pub use unwinding::*; - } target_family = "wasm" => { mod wasm; pub use wasm::*; diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 720cbc8de942f..4726ef5fe493b 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -2,6 +2,10 @@ use core::ffi::{c_int, c_void}; +// Use the unwinding crate as unwinder on Xous +#[cfg(target_os = "xous")] +use unwinding as _; + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] pub enum _Unwind_Reason_Code { @@ -54,6 +58,12 @@ pub struct _Unwind_Exception { pub private: [_Unwind_Word; unwinder_private_data_size], } +// Check the size of _Unwind_Exception against the source of thruth when using the unwinding crate. +#[cfg(target_os = "xous")] +const _: () = { + assert!(size_of::() == size_of::<_Unwind_Exception>()); +}; + pub enum _Unwind_Context {} pub type _Unwind_Exception_Cleanup_Fn = @@ -68,10 +78,7 @@ pub type _Unwind_Exception_Cleanup_Fn = // rustc_codegen_ssa::src::back::symbol_export, rustc_middle::middle::exported_symbols // and RFC 2841 #[cfg_attr( - all( - feature = "llvm-libunwind", - any(target_os = "fuchsia", target_os = "linux", target_os = "xous") - ), + all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] // Explicitly link the `unwind` library on WASI targets. @@ -107,7 +114,7 @@ cfg_select! { pub const _UA_END_OF_STACK: c_int = 16; #[cfg_attr( - all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), + all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] unsafe extern "C" { @@ -166,7 +173,7 @@ cfg_select! { pub const UNWIND_IP_REG: c_int = 15; #[cfg_attr( - all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), + all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] unsafe extern "C" { @@ -246,14 +253,14 @@ cfg_select! { } _ => { #[cfg_attr( - all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), + all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] unsafe extern "C-unwind" { pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code; } #[cfg_attr( - all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), + all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] unsafe extern "C" { diff --git a/library/unwind/src/unwinding.rs b/library/unwind/src/unwinding.rs deleted file mode 100644 index ac1140ff040c0..0000000000000 --- a/library/unwind/src/unwinding.rs +++ /dev/null @@ -1,100 +0,0 @@ -#![allow(nonstandard_style)] - -use core::ffi::{c_int, c_void}; - -pub type _Unwind_Action = c_int; - -pub const _UA_SEARCH_PHASE: c_int = 1; -pub const _UA_CLEANUP_PHASE: c_int = 2; -pub const _UA_HANDLER_FRAME: c_int = 4; -pub const _UA_FORCE_UNWIND: c_int = 8; -pub const _UA_END_OF_STACK: c_int = 16; - -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub enum _Unwind_Reason_Code { - _URC_NO_REASON = 0, - _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_FATAL_PHASE2_ERROR = 2, - _URC_FATAL_PHASE1_ERROR = 3, - _URC_NORMAL_STOP = 4, - _URC_END_OF_STACK = 5, - _URC_HANDLER_FOUND = 6, - _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8, - _URC_FAILURE = 9, // used only by ARM EHABI -} -pub use _Unwind_Reason_Code::*; -pub use unwinding::abi::{UnwindContext, UnwindException}; -pub enum _Unwind_Context {} - -pub use unwinding::custom_eh_frame_finder::{ - EhFrameFinder, FrameInfo, FrameInfoKind, set_custom_eh_frame_finder, -}; - -pub type _Unwind_Exception_Class = u64; -pub type _Unwind_Word = *const u8; -pub type _Unwind_Ptr = *const u8; - -const unwinder_private_data_size: usize = size_of::() - - size_of::<_Unwind_Exception_Class>() - - size_of::<_Unwind_Exception_Cleanup_Fn>(); - -pub type _Unwind_Exception_Cleanup_Fn = - Option; - -#[repr(C)] -pub struct _Unwind_Exception { - pub exception_class: _Unwind_Exception_Class, - pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, - pub private: [_Unwind_Word; unwinder_private_data_size], -} - -pub unsafe fn _Unwind_GetDataRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - unwinding::abi::_Unwind_GetDataRelBase(ctx) as _Unwind_Ptr -} - -pub unsafe fn _Unwind_GetTextRelBase(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - unwinding::abi::_Unwind_GetTextRelBase(ctx) as _Unwind_Ptr -} - -pub unsafe fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - unwinding::abi::_Unwind_GetRegionStart(ctx) as _Unwind_Ptr -} - -pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - unwinding::abi::_Unwind_SetGR(ctx, reg_index, value as usize) -} - -pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word) { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - unwinding::abi::_Unwind_SetIP(ctx, value as usize) -} - -pub unsafe fn _Unwind_GetIPInfo( - ctx: *mut _Unwind_Context, - ip_before_insn: *mut c_int, -) -> _Unwind_Word { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - let ip_before_insn = unsafe { &mut *(ip_before_insn as *mut c_int) }; - unsafe { &*(unwinding::abi::_Unwind_GetIPInfo(ctx, ip_before_insn) as _Unwind_Word) } -} - -pub unsafe fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void { - let ctx = unsafe { &mut *(ctx as *mut UnwindContext<'_>) }; - unwinding::abi::_Unwind_GetLanguageSpecificData(ctx) -} - -pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code { - let exception = unsafe { &mut *(exception as *mut UnwindException) }; - unsafe { core::mem::transmute(unwinding::abi::_Unwind_RaiseException(exception)) } -} - -pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) { - let exception = unsafe { &mut *(exception as *mut UnwindException) }; - unsafe { unwinding::abi::_Unwind_DeleteException(exception) } -} From d703dae49cdc70aa354e8ec991e5d4fb817c504c Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 10 Jul 2026 14:46:26 +0200 Subject: [PATCH 03/13] Add constructor for _Unwind_Exception and hide private field --- library/panic_unwind/src/gcc.rs | 6 +----- library/unwind/src/libunwind.rs | 11 ++++++++++- library/unwind/src/wasm.rs | 11 ++++++++++- src/tools/miri/tests/pass/panic/unwind_dwarf.rs | 6 +----- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index adcbe5170623c..4f580cb552806 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -60,11 +60,7 @@ struct Exception { pub(crate) unsafe fn panic(data: Box) -> u32 { let exception = Box::new(Exception { - _uwe: uw::_Unwind_Exception { - exception_class: RUST_EXCEPTION_CLASS, - exception_cleanup: Some(exception_cleanup), - private: [core::ptr::null(); _], - }, + _uwe: uw::_Unwind_Exception::new(RUST_EXCEPTION_CLASS, Some(exception_cleanup)), canary: &CANARY, cause: data, }); diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 4726ef5fe493b..d3200d7f2c466 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -55,7 +55,16 @@ const unwinder_private_data_size: usize = cfg_select! { pub struct _Unwind_Exception { pub exception_class: _Unwind_Exception_Class, pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, - pub private: [_Unwind_Word; unwinder_private_data_size], + private: [_Unwind_Word; unwinder_private_data_size], +} + +impl _Unwind_Exception { + pub fn new( + exception_class: _Unwind_Exception_Class, + exception_cleanup: _Unwind_Exception_Cleanup_Fn, + ) -> Self { + Self { exception_class, exception_cleanup, private: [core::ptr::null(); _] } + } } // Check the size of _Unwind_Exception against the source of thruth when using the unwinding crate. diff --git a/library/unwind/src/wasm.rs b/library/unwind/src/wasm.rs index 37d93bdbb67dd..ea958aad6b6d1 100644 --- a/library/unwind/src/wasm.rs +++ b/library/unwind/src/wasm.rs @@ -51,7 +51,16 @@ pub const unwinder_private_data_size: usize = 2; pub struct _Unwind_Exception { pub exception_class: _Unwind_Exception_Class, pub exception_cleanup: _Unwind_Exception_Cleanup_Fn, - pub private: [_Unwind_Word; unwinder_private_data_size], + private: [_Unwind_Word; unwinder_private_data_size], +} + +impl _Unwind_Exception { + pub fn new( + exception_class: _Unwind_Exception_Class, + exception_cleanup: _Unwind_Exception_Cleanup_Fn, + ) -> Self { + Self { exception_class, exception_cleanup, private: [core::ptr::null(); _] } + } } pub type _Unwind_Exception_Cleanup_Fn = diff --git a/src/tools/miri/tests/pass/panic/unwind_dwarf.rs b/src/tools/miri/tests/pass/panic/unwind_dwarf.rs index aaecacd95ec9a..255f4eea4f012 100644 --- a/src/tools/miri/tests/pass/panic/unwind_dwarf.rs +++ b/src/tools/miri/tests/pass/panic/unwind_dwarf.rs @@ -24,11 +24,7 @@ fn panic(data: Box) -> u32 { } let exception = Box::new(Exception { - _uwe: uw::_Unwind_Exception { - exception_class: miri_exception_class(), - exception_cleanup: Some(exception_cleanup), - private: [core::ptr::null(); _], - }, + _uwe: uw::_Unwind_Exception::new(miri_exception_class(), Some(exception_cleanup)), cause: data, }); let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; From 407410c399b940549add137d8a85e5ecc07bd805 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:39:00 +0200 Subject: [PATCH 04/13] Remove unused include in unwind/Cargo.toml --- library/unwind/Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml index 1293c469d11c1..628b9d5e8c3ec 100644 --- a/library/unwind/Cargo.toml +++ b/library/unwind/Cargo.toml @@ -4,9 +4,6 @@ version = "0.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust.git" edition = "2024" -include = [ - '/libunwind/*', -] [lib] test = false From 4daa033c41d5080270fd6f97a58a5eb46a7cabe8 Mon Sep 17 00:00:00 2001 From: Xuyang Zhang Date: Sat, 11 Jul 2026 15:26:20 +0800 Subject: [PATCH 05/13] compiletest: use VecDeque::pop_front_if --- src/tools/compiletest/src/executor/deadline.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/executor/deadline.rs b/src/tools/compiletest/src/executor/deadline.rs index 3536eff2fd80d..47e75c03f963e 100644 --- a/src/tools/compiletest/src/executor/deadline.rs +++ b/src/tools/compiletest/src/executor/deadline.rs @@ -79,7 +79,7 @@ impl<'a> DeadlineQueue<'a> { // Clear out entries that are past their deadline, but only invoke the // callback for tests that are still considered running. - while let Some(entry) = pop_front_if(&mut self.queue, |entry| entry.deadline <= now) { + while let Some(entry) = self.queue.pop_front_if(|entry| entry.deadline <= now) { if is_running(entry.id) { on_deadline_passed(entry.id, entry.test); } @@ -87,16 +87,10 @@ impl<'a> DeadlineQueue<'a> { // Also clear out any leading entries that are no longer running, even // if their deadline hasn't been reached. - while let Some(_) = pop_front_if(&mut self.queue, |entry| !is_running(entry.id)) {} + while self.queue.pop_front_if(|entry| !is_running(entry.id)).is_some() {} if let Some(front) = self.queue.front() { assert!(now < front.deadline); } } } - -/// FIXME(vec_deque_pop_if): Use `VecDeque::pop_front_if` when it is stable in bootstrap. -fn pop_front_if(queue: &mut VecDeque, predicate: impl FnOnce(&T) -> bool) -> Option { - let first = queue.front()?; - if predicate(first) { queue.pop_front() } else { None } -} From 5d637fd0ecf40e8ceb6e9dc8b44fd472da3ddd87 Mon Sep 17 00:00:00 2001 From: rabindra789 Date: Sat, 11 Jul 2026 18:57:22 +0530 Subject: [PATCH 06/13] std: increase Windows console stdin scratch buffer The small-buffer path in Stdin::read allocates a one-element UTF-16 scratch buffer. When a pending surrogate exists, read_u16s_fixup_surrogates requires temporary storage for both the buffered surrogate and one newly read UTF-16 code unit. Increase the scratch buffer to two UTF-16 code units so the surrogate path can complete without panicking. --- library/std/src/sys/stdio/windows.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/stdio/windows.rs b/library/std/src/sys/stdio/windows.rs index 475a0592528b4..89976847d3817 100644 --- a/library/std/src/sys/stdio/windows.rs +++ b/library/std/src/sys/stdio/windows.rs @@ -278,7 +278,7 @@ impl io::Read for Stdin { Ok(bytes_copied) } else if buf.len() - bytes_copied < 4 { // Not enough space to get a UTF-8 byte. We will use the incomplete UTF8. - let mut utf16_buf = [MaybeUninit::new(0); 1]; + let mut utf16_buf = [MaybeUninit::new(0); 2]; // Read one u16 character. let read = read_u16s_fixup_surrogates(handle, &mut utf16_buf, 1, &mut self.surrogate)?; // Read bytes, using the (now-empty) self.incomplete_utf8 as extra space. From 6194bec55dc6f3bbd48bf71dd1beb8e22b4510be Mon Sep 17 00:00:00 2001 From: Sergii Bogomolov Date: Sat, 11 Jul 2026 02:27:11 +0200 Subject: [PATCH 07/13] Fix segfault in env access in statically linked FreeBSD binaries std resolves environ through dlsym on FreeBSD so that shared libraries can link, but a statically linked executable has no dynamic symbol table: the lookup returns null and the env iteration dereferences it. Take a weak reference instead: it binds at link time in any executable, and in a shared library the runtime linker resolves it against the environ the executable exports. Treat a null environ as an empty environment instead of dereferencing it. --- library/std/src/sys/env/unix.rs | 41 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/library/std/src/sys/env/unix.rs b/library/std/src/sys/env/unix.rs index 7a19f97b3ad50..f9ecec0c7304f 100644 --- a/library/std/src/sys/env/unix.rs +++ b/library/std/src/sys/env/unix.rs @@ -38,21 +38,19 @@ pub unsafe fn environ() -> *mut *const *const c_char { unsafe { libc::_NSGetEnviron() as *mut *const *const c_char } } -// On FreeBSD, environ comes from CRT rather than libc +// On FreeBSD, environ lives in crt1.o, not libc.so, so a shared library +// cannot take a strong link-time reference to it (#153451), and dlsym cannot +// find it in a statically linked executable, which has no dynamic symbol +// table to search (#158939). A weak reference covers both: it binds at link +// time in any executable, and in a shared library the runtime linker +// resolves it against the environ the executable exports. #[cfg(target_os = "freebsd")] pub unsafe fn environ() -> *mut *const *const c_char { - use crate::sync::LazyLock; - - struct Environ(*mut *const *const c_char); - unsafe impl Send for Environ {} - unsafe impl Sync for Environ {} - - static ENVIRON: LazyLock = LazyLock::new(|| { - Environ(unsafe { - libc::dlsym(libc::RTLD_DEFAULT, c"environ".as_ptr()) as *mut *const *const c_char - }) - }); - ENVIRON.0 + unsafe extern "C" { + #[linkage = "extern_weak"] + static environ: *mut *const *const c_char; + } + unsafe { environ } } // Use the `environ` static which is part of POSIX. @@ -75,14 +73,19 @@ pub fn env_read_lock() -> impl Drop { pub fn env() -> Env { unsafe { let _guard = env_read_lock(); - let mut environ = *environ(); let mut result = Vec::new(); - if !environ.is_null() { - while !(*environ).is_null() { - if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { - result.push(key_value); + // A null return means the platform could not locate the symbol; + // treat it like an empty environment. + let environ_ptr = environ(); + if !environ_ptr.is_null() { + let mut environ = *environ_ptr; + if !environ.is_null() { + while !(*environ).is_null() { + if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { + result.push(key_value); + } + environ = environ.add(1); } - environ = environ.add(1); } } return Env::new(result); From 9f9b2d9d14138d8c52a3ba9ebf8e4ed28fdaa9bb Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 11 Jul 2026 20:04:35 +1000 Subject: [PATCH 08/13] More snapshot tests for skipping coverage tests --- .../snapshots/x_test_skip_coverage_map.snap | 215 ++++++++++++++++++ .../snapshots/x_test_skip_coverage_run.snap | 215 ++++++++++++++++++ .../snapshots/x_test_skip_tests_coverage.snap | 215 ++++++++++++++++++ .../src/core/builder/cli_paths/tests.rs | 3 + 4 files changed, 648 insertions(+) create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap new file mode 100644 index 0000000000000..15ca131465d2e --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -0,0 +1,215 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test --skip=coverage-map +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-run}) + - Suite(test::tests/coverage) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) +[Test] test::RustdocHtml + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-html) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) + - Set({test::tidyselftest}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::StdarchVerify + targets: [x86_64-unknown-linux-gnu] + - Set({test::library/stdarch/crates/stdarch-verify}) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap new file mode 100644 index 0000000000000..b7dece97cdb12 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -0,0 +1,215 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test --skip=coverage-run +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-map}) + - Suite(test::tests/coverage) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) +[Test] test::RustdocHtml + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-html) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) + - Set({test::tidyselftest}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::StdarchVerify + targets: [x86_64-unknown-linux-gnu] + - Set({test::library/stdarch/crates/stdarch-verify}) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap new file mode 100644 index 0000000000000..050b1c5f699da --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -0,0 +1,215 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test --skip=tests/coverage +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-map}) + - Set({test::coverage-run}) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) +[Test] test::RustdocHtml + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-html) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) + - Set({test::tidyselftest}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::StdarchVerify + targets: [x86_64-unknown-linux-gnu] + - Set({test::library/stdarch/crates/stdarch-verify}) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs index 39293abd4fb94..09e22aad44567 100644 --- a/src/bootstrap/src/core/builder/cli_paths/tests.rs +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -173,8 +173,11 @@ declare_tests!( (x_test_rustdoc, "test rustdoc"), (x_test_rustdoc_html, "test rustdoc-html"), (x_test_skip_coverage, "test --skip=coverage"), + (x_test_skip_coverage_map, "test --skip=coverage-map"), + (x_test_skip_coverage_run, "test --skip=coverage-run"), // FIXME(Zalathar): This doesn't skip the coverage-map or coverage-run tests. (x_test_skip_tests, "test --skip=tests"), + (x_test_skip_tests_coverage, "test --skip=tests/coverage"), // From `src/ci/docker/scripts/stage_2_test_set2.sh`. ( x_test_skip_tests_etc, From 29260f01d6f4b52c4be9de31662fee070dc4ae0f Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 11 Jul 2026 20:33:53 +1000 Subject: [PATCH 09/13] Allow path-based skipping of the coverage test suite When bootstrap runs a step by default, without explicit paths, it will normally act as though the user had explicitly requested all of the paths and aliases that the step registered through `ShouldRun`. For the coverage test suite, that gives the wrong outcome. Running a command like `./x test --skip=tests` or `./x test --skip=coverage` should skip the coverage tests, but instead the coverage tests would run anyway, due to the `coverage-map` and `coverage-run` aliases being treated as implied command-line arguments. This commit fixes that problem by adding a special flag to `ShouldRun`. When creating pathsets for a step that is being run by default, if the step has set the `default_to_suites_only` flag, all non-suite pathsets are discarded. That gives the desired behavior for skipping coverage tests, without affecting other steps, since other steps don't set the flag. --- src/bootstrap/src/core/build_steps/test.rs | 13 +++++----- src/bootstrap/src/core/builder/cli_paths.rs | 3 ++- .../builder/cli_paths/snapshots/x_test.snap | 2 -- .../snapshots/x_test_skip_coverage.snap | 4 --- .../snapshots/x_test_skip_coverage_map.snap | 1 - .../snapshots/x_test_skip_coverage_run.snap | 1 - .../snapshots/x_test_skip_tests.snap | 4 --- .../snapshots/x_test_skip_tests_coverage.snap | 4 --- .../src/core/builder/cli_paths/tests.rs | 1 - src/bootstrap/src/core/builder/mod.rs | 26 ++++++++++++++++++- 10 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 61529da631a06..e363c292d9758 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1975,6 +1975,12 @@ impl Step for Coverage { for mode in Self::ALL_MODES { run = run.alias(mode.as_str()); } + + // Allow `./x test --skip=tests` to properly skip the coverage tests, + // by not treating the `coverage-map` and `coverage-run` aliases as + // implied command-line arguments. + run = run.default_to_suites_only(); + run } @@ -2016,13 +2022,6 @@ impl Step for Coverage { !run.builder.config.skip.iter().any(|skip| skip == Path::new(mode.as_str())) }); - // FIXME(Zalathar): Make these commands skip all coverage tests, as expected: - // - `./x test --skip=tests` - // - `./x test --skip=tests/coverage` - // - `./x test --skip=coverage` - // Skip handling currently doesn't have a way to know that skipping the coverage - // suite should also skip the `coverage-map` and `coverage-run` aliases. - for mode in modes { run.builder.ensure(Coverage { compiler, target, mode }); } diff --git a/src/bootstrap/src/core/builder/cli_paths.rs b/src/bootstrap/src/core/builder/cli_paths.rs index 1b0caa980e1de..b645ce9f417ae 100644 --- a/src/bootstrap/src/core/builder/cli_paths.rs +++ b/src/bootstrap/src/core/builder/cli_paths.rs @@ -138,7 +138,8 @@ pub(crate) fn match_paths_to_steps_and_run( if paths.is_empty() || builder.config.include_default_paths { for StepExtra { desc, should_run } in &steps { if (desc.is_default_step_fn)(builder) { - desc.maybe_run(builder, should_run.paths.iter().cloned().collect()); + let default_pathsets = should_run.default_pathsets(); + desc.maybe_run(builder, default_pathsets); } } } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 60e8a219585c6..c167067fda67a 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -13,8 +13,6 @@ expression: test - Suite(test::tests/crashes) [Test] test::Coverage targets: [aarch64-unknown-linux-gnu] - - Set({test::coverage-map}) - - Set({test::coverage-run}) - Suite(test::tests/coverage) [Test] test::MirOpt targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index fb83986445bea..942d71af123c8 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -11,10 +11,6 @@ expression: test --skip=coverage [Test] test::Crashes targets: [aarch64-unknown-linux-gnu] - Suite(test::tests/crashes) -[Test] test::Coverage - targets: [aarch64-unknown-linux-gnu] - - Set({test::coverage-map}) - - Set({test::coverage-run}) [Test] test::MirOpt targets: [aarch64-unknown-linux-gnu] - Suite(test::tests/mir-opt) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 15ca131465d2e..53470834428a6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -13,7 +13,6 @@ expression: test --skip=coverage-map - Suite(test::tests/crashes) [Test] test::Coverage targets: [aarch64-unknown-linux-gnu] - - Set({test::coverage-run}) - Suite(test::tests/coverage) [Test] test::MirOpt targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index b7dece97cdb12..b4976a7f894f4 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -13,7 +13,6 @@ expression: test --skip=coverage-run - Suite(test::tests/crashes) [Test] test::Coverage targets: [aarch64-unknown-linux-gnu] - - Set({test::coverage-map}) - Suite(test::tests/coverage) [Test] test::MirOpt targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index 3737272dd83a4..08674853caa42 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -5,10 +5,6 @@ expression: test --skip=tests [Test] test::Tidy targets: [x86_64-unknown-linux-gnu] - Set({test::src/tools/tidy}) -[Test] test::Coverage - targets: [aarch64-unknown-linux-gnu] - - Set({test::coverage-map}) - - Set({test::coverage-run}) [Test] test::CodegenCranelift targets: [x86_64-unknown-linux-gnu] - Set({test::compiler/rustc_codegen_cranelift}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 050b1c5f699da..9cc6f97bc193b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -11,10 +11,6 @@ expression: test --skip=tests/coverage [Test] test::Crashes targets: [aarch64-unknown-linux-gnu] - Suite(test::tests/crashes) -[Test] test::Coverage - targets: [aarch64-unknown-linux-gnu] - - Set({test::coverage-map}) - - Set({test::coverage-run}) [Test] test::MirOpt targets: [aarch64-unknown-linux-gnu] - Suite(test::tests/mir-opt) diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs index 09e22aad44567..2cde1d9a0b89b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/tests.rs +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -175,7 +175,6 @@ declare_tests!( (x_test_skip_coverage, "test --skip=coverage"), (x_test_skip_coverage_map, "test --skip=coverage-map"), (x_test_skip_coverage_run, "test --skip=coverage-run"), - // FIXME(Zalathar): This doesn't skip the coverage-map or coverage-run tests. (x_test_skip_tests, "test --skip=tests"), (x_test_skip_tests_coverage, "test --skip=tests/coverage"), // From `src/ci/docker/scripts/stage_2_test_set2.sh`. diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 0f68988a683cf..0d17f0f792a01 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -515,11 +515,13 @@ pub struct ShouldRun<'a> { // use a BTreeSet to maintain sort order paths: BTreeSet, + + default_to_suites_only: bool, } impl<'a> ShouldRun<'a> { fn new(builder: &'a Builder<'_>, kind: Kind) -> ShouldRun<'a> { - ShouldRun { builder, kind, paths: BTreeSet::new() } + ShouldRun { builder, kind, paths: BTreeSet::new(), default_to_suites_only: false } } /// Indicates it should run if the command-line selects the given crate or @@ -636,6 +638,28 @@ impl<'a> ShouldRun<'a> { } sets } + + /// When generating pathsets for a step that is being run "by default" + /// (i.e. when running bootstrap without an explicit command-line path), + /// discard any paths that were not registered as test suites. + /// + /// This is basically a hack to make path-based skipping work properly for + /// coverage tests, since otherwise the `coverage-map` and `coverage-run` + /// aliases would prevent `./x test --skip=tests` from skipping them. + pub(crate) fn default_to_suites_only(mut self) -> Self { + self.default_to_suites_only = true; + self + } + + /// When the corresponding step is run "by default" (without explicit command-line paths), + /// act as though the user had explicitly specified these paths. + fn default_pathsets(&self) -> Vec { + let mut default_pathsets = self.paths.iter().cloned().collect::>(); + if self.default_to_suites_only { + default_pathsets.retain(|p| matches!(p, PathSet::Suite(_))); + } + default_pathsets + } } #[derive(Debug, Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord, ValueEnum)] From a4d03c4b9fdee43ed698608f2bf5f5911a1ee0bd Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 11 Jul 2026 20:37:27 +1000 Subject: [PATCH 10/13] CI scripts no longer need to `--skip=coverage-map --skip=coverage-run` --- src/bootstrap/mk/Makefile.in | 2 +- src/bootstrap/src/core/builder/cli_paths/tests.rs | 5 +---- src/ci/docker/scripts/stage_2_test_set2.sh | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 4d4b37eec08b0..b265185a21413 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -106,7 +106,7 @@ prepare: SKIP_COMPILER := --skip=compiler SKIP_SRC := --skip=src TEST_SET1 := $(SKIP_COMPILER) $(SKIP_SRC) -TEST_SET2 := --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest +TEST_SET2 := --skip=tests --skip=library --skip=tidyselftest ## MSVC native builders diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs index 2cde1d9a0b89b..40a37e5cf5631 100644 --- a/src/bootstrap/src/core/builder/cli_paths/tests.rs +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -178,10 +178,7 @@ declare_tests!( (x_test_skip_tests, "test --skip=tests"), (x_test_skip_tests_coverage, "test --skip=tests/coverage"), // From `src/ci/docker/scripts/stage_2_test_set2.sh`. - ( - x_test_skip_tests_etc, - "test --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest" - ), + (x_test_skip_tests_etc, "test --skip=tests --skip=library --skip=tidyselftest"), (x_test_tests, "test tests"), (x_test_tests_skip_coverage, "test tests --skip=coverage"), (x_test_tests_ui, "test tests/ui"), diff --git a/src/ci/docker/scripts/stage_2_test_set2.sh b/src/ci/docker/scripts/stage_2_test_set2.sh index a47981c76d6d1..2c72992f66945 100755 --- a/src/ci/docker/scripts/stage_2_test_set2.sh +++ b/src/ci/docker/scripts/stage_2_test_set2.sh @@ -25,7 +25,5 @@ fi ${SKIP_TIDY:+$SKIP_TIDY} \ ${SKIP_RUST_ANALYZER:+$SKIP_RUST_ANALYZER} \ --skip tests \ - --skip coverage-map \ - --skip coverage-run \ --skip library \ --skip tidyselftest From 64811e9c662149ce71bc047c0b3ba97b74a3a473 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 12 Jul 2026 11:35:46 +0200 Subject: [PATCH 11/13] Fix building for xous --- library/unwind/src/libunwind.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index d3200d7f2c466..f8d66fc7a2e3e 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -4,7 +4,9 @@ use core::ffi::{c_int, c_void}; // Use the unwinding crate as unwinder on Xous #[cfg(target_os = "xous")] -use unwinding as _; +pub use unwinding::custom_eh_frame_finder::{ + EhFrameFinder, FrameInfo, FrameInfoKind, set_custom_eh_frame_finder, +}; #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq)] From b7990bab70cf7b66ea0867c4aa21092fd8d4aeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 12 Jul 2026 14:36:15 +0200 Subject: [PATCH 12/13] Print duration of BOLT instrumentation and optimization steps --- src/tools/opt-dist/src/main.rs | 35 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index cdbeee63d6c26..58e33c12271e5 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -329,9 +329,16 @@ fn execute_pipeline( // FIXME(kobzol): try gather profiles together, at once for LLVM and rustc // Instrument the libraries and gather profiles - let llvm_profile = with_bolt_instrumented(env, &llvm_lib, |llvm_profile_dir| { - stage.section("Gather profiles", |_| { - gather_bolt_profiles(env, "LLVM", llvm_benchmarks(env), llvm_profile_dir) + let llvm_profile = stage.section("Instrument & gather profiles", |stage| { + with_bolt_instrumented(env, &llvm_lib, |llvm_profile_dir| { + stage.section("Gather profiles", |_| { + gather_bolt_profiles( + env, + "LLVM", + llvm_benchmarks(env), + llvm_profile_dir, + ) + }) }) })?; print_free_disk_space()?; @@ -341,9 +348,10 @@ fn execute_pipeline( // the final dist build. However, when BOLT optimizes an artifact, it does so *in-place*, // therefore it will actually optimize all the hard links, which means that the final // packaged `libLLVM.so` file *will* be BOLT optimized. - bolt_optimize(&llvm_lib, &llvm_profile, env) - .context("Could not optimize LLVM with BOLT")?; - + stage.section("Optimize", |_| { + bolt_optimize(&llvm_lib, &llvm_profile, env) + .context("Could not optimize LLVM with BOLT") + })?; Some(llvm_profile) } else { None @@ -354,17 +362,20 @@ fn execute_pipeline( log::info!("Optimizing {rustc_lib} with BOLT"); // Instrument it and gather profiles - let rustc_profile = with_bolt_instrumented(env, &rustc_lib, |rustc_profile_dir| { - stage.section("Gather profiles", |_| { - gather_bolt_profiles(env, "rustc", rustc_benchmarks(env), rustc_profile_dir) + let rustc_profile = stage.section("Instrument & gather profiles", |stage| { + with_bolt_instrumented(env, &rustc_lib, |rustc_profile_dir| { + stage.section("Gather profiles", |_| { + gather_bolt_profiles(env, "rustc", rustc_benchmarks(env), rustc_profile_dir) + }) }) })?; print_free_disk_space()?; // Now optimize the library with BOLT. - bolt_optimize(&rustc_lib, &rustc_profile, env) - .context("Could not optimize rustc with BOLT")?; - + stage.section("Optimize", |_| { + bolt_optimize(&rustc_lib, &rustc_profile, env) + .context("Could not optimize rustc with BOLT") + })?; // LLVM is not being cleared here. Either we built it and we want to use the BOLT-optimized LLVM, or we // didn't build it, so we don't want to remove it. Ok(vec![llvm_profile, Some(rustc_profile)]) From 65ed52f2ba2f1af7025052f38502f47878e57348 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 10 Jul 2026 12:18:51 +0200 Subject: [PATCH 13/13] Apply MCP 1003 and move `diagnostics.rs` into its own module and move `error_helper.rs` into the `diagnostics` folder in `rustc_resolve` --- compiler/rustc_resolve/src/build_reduced_graph.rs | 2 +- .../src/{error_helper.rs => diagnostics/impls.rs} | 0 .../src/{diagnostics.rs => diagnostics/mod.rs} | 2 ++ compiler/rustc_resolve/src/imports.rs | 2 +- compiler/rustc_resolve/src/late/diagnostics.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 6 +++--- 6 files changed, 8 insertions(+), 6 deletions(-) rename compiler/rustc_resolve/src/{error_helper.rs => diagnostics/impls.rs} (100%) rename compiler/rustc_resolve/src/{diagnostics.rs => diagnostics/mod.rs} (99%) diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index ab4861a59df61..3f4c260a496af 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -32,7 +32,7 @@ use tracing::debug; use crate::Namespace::{MacroNS, TypeNS, ValueNS}; use crate::def_collector::DefCollector; -use crate::error_helper::{OnUnknownData, StructCtor}; +use crate::diagnostics::impls::{OnUnknownData, StructCtor}; use crate::imports::{ImportData, ImportKind, NameResolution, NameResolutionRef}; use crate::macros::{MacroRulesDecl, MacroRulesScope, MacroRulesScopeRef}; use crate::ref_mut::CmCell; diff --git a/compiler/rustc_resolve/src/error_helper.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs similarity index 100% rename from compiler/rustc_resolve/src/error_helper.rs rename to compiler/rustc_resolve/src/diagnostics/impls.rs diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics/mod.rs similarity index 99% rename from compiler/rustc_resolve/src/diagnostics.rs rename to compiler/rustc_resolve/src/diagnostics/mod.rs index 3e2cb94dc2858..9de2a682dc1fd 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics/mod.rs @@ -10,6 +10,8 @@ use rustc_span::{Ident, Span, Spanned, Symbol}; use crate::Res; use crate::late::{PatternSource, ResolvingRestrictionKind}; +pub(crate) mod impls; + #[derive(Diagnostic)] #[diag("can't use {$is_self -> [true] `Self` diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 4daa549b1e109..d62bf538133f2 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -25,13 +25,13 @@ use rustc_span::{Ident, Span, Symbol, kw, sym}; use tracing::debug; use crate::Namespace::{self, *}; +use crate::diagnostics::impls::{OnUnknownData, Suggestion}; use crate::diagnostics::{ self, CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate, CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates, ConsiderAddingMacroExport, ConsiderMarkingAsPub, ConsiderMarkingAsPubCrate, }; -use crate::error_helper::{OnUnknownData, Suggestion}; use crate::ref_mut::{CmCell, CmRefCell}; use crate::{ AmbiguityError, BindingKey, CmResolver, Decl, DeclData, DeclKind, Determinacy, Finalize, diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 42ac352df6bfb..4874ccdcd460a 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -32,7 +32,7 @@ use thin_vec::{ThinVec, thin_vec}; use tracing::debug; use super::NoConstantGenericsReason; -use crate::error_helper::{ImportSuggestion, LabelSuggestion, TypoSuggestion}; +use crate::diagnostics::impls::{ImportSuggestion, LabelSuggestion, TypoSuggestion}; use crate::late::{ AliasPossibility, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind, LifetimeUseSet, QSelf, RibKind, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 649d56fb11edf..13576c24e6c08 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -29,7 +29,6 @@ use std::{fmt, mem}; use diagnostics::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst}; use effective_visibilities::EffectiveVisibilitiesVisitor; -use error_helper::{ImportSuggestion, LabelSuggestion, StructCtor, Suggestion}; use hygiene::Macros20NormalizedSyntaxContext; use imports::{Import, ImportData, ImportKind, NameResolution, PendingDecl}; use late::{ @@ -77,7 +76,9 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; -use crate::error_helper::OnUnknownData; +use crate::diagnostics::impls::{ + ImportSuggestion, LabelSuggestion, OnUnknownData, StructCtor, Suggestion, +}; use crate::imports::NameResolutionRef; use crate::ref_mut::{CmCell, CmRefCell}; @@ -86,7 +87,6 @@ mod check_unused; mod def_collector; mod diagnostics; mod effective_visibilities; -mod error_helper; mod ident; mod imports; mod late;