Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7813358
Use cfg_select! for unwinder_private_data_size
bjorn3 Jul 9, 2026
4866a9c
Unify the type definitions for libunwind and the unwinding crate
bjorn3 Jul 9, 2026
d703dae
Add constructor for _Unwind_Exception and hide private field
bjorn3 Jul 10, 2026
407410c
Remove unused include in unwind/Cargo.toml
bjorn3 Jul 10, 2026
4daa033
compiletest: use VecDeque::pop_front_if
kn1g78 Jul 11, 2026
5d637fd
std: increase Windows console stdin scratch buffer
rabindra789 Jul 11, 2026
6194bec
Fix segfault in env access in statically linked FreeBSD binaries
sbogomolov Jul 11, 2026
9f9b2d9
More snapshot tests for skipping coverage tests
Zalathar Jul 11, 2026
29260f0
Allow path-based skipping of the coverage test suite
Zalathar Jul 11, 2026
a4d03c4
CI scripts no longer need to `--skip=coverage-map --skip=coverage-run`
Zalathar Jul 11, 2026
64811e9
Fix building for xous
bjorn3 Jul 12, 2026
b7990ba
Print duration of BOLT instrumentation and optimization steps
Kobzol Jul 12, 2026
65ed52f
Apply MCP 1003 and move `diagnostics.rs` into its own module and move…
GuillaumeGomez Jul 10, 2026
9a5dea4
Rollup merge of #158732 - GuillaumeGomez:rename-diagnostics, r=Jonath…
JonathanBrouwer Jul 12, 2026
6ce8304
Rollup merge of #159010 - bjorn3:refactor_unwind, r=Mark-Simulacrum
JonathanBrouwer Jul 12, 2026
d8658da
Rollup merge of #159131 - Zalathar:skip-coverage, r=jieyouxu
JonathanBrouwer Jul 12, 2026
c8bdc49
Rollup merge of #159134 - rabindra789:fix-158096-stdin-panic, r=Darksonn
JonathanBrouwer Jul 12, 2026
a377d0c
Rollup merge of #159178 - Kobzol:opt-dist-log-bolt, r=lqd
JonathanBrouwer Jul 12, 2026
dcc662d
Rollup merge of #159112 - sbogomolov:freebsd-static-environ, r=clarfo…
JonathanBrouwer Jul 12, 2026
6e2afdd
Rollup merge of #159124 - kn1g78:fix/compiletest-pop-front-if, r=jiey…
JonathanBrouwer Jul 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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};

Expand All @@ -86,7 +87,6 @@ mod check_unused;
mod def_collector;
mod diagnostics;
mod effective_visibilities;
mod error_helper;
mod ident;
mod imports;
mod late;
Expand Down
6 changes: 1 addition & 5 deletions library/panic_unwind/src/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ struct Exception {

pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
let exception = Box::new(Exception {
_uwe: uw::_Unwind_Exception {
exception_class: RUST_EXCEPTION_CLASS,
exception_cleanup: Some(exception_cleanup),
private: [core::ptr::null(); uw::unwinder_private_data_size],
},
_uwe: uw::_Unwind_Exception::new(RUST_EXCEPTION_CLASS, Some(exception_cleanup)),
canary: &CANARY,
cause: data,
});
Expand Down
41 changes: 22 additions & 19 deletions library/std/src/sys/env/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Environ> = 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.
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/stdio/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions library/unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
117 changes: 49 additions & 68 deletions library/unwind/src/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

use core::ffi::{c_int, c_void};

// Use the unwinding crate as unwinder on Xous
#[cfg(target_os = "xous")]
pub use unwinding::custom_eh_frame_finder::{
EhFrameFinder, FrameInfo, FrameInfoKind, set_custom_eh_frame_finder,
};

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum _Unwind_Reason_Code {
Expand All @@ -24,73 +30,51 @@ 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 {
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.
#[cfg(target_os = "xous")]
const _: () = {
assert!(size_of::<unwinding::abi::UnwindException>() == size_of::<_Unwind_Exception>());
};

pub enum _Unwind_Context {}

pub type _Unwind_Exception_Cleanup_Fn =
Expand All @@ -105,10 +89,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.
Expand Down Expand Up @@ -144,7 +125,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" {
Expand Down Expand Up @@ -203,7 +184,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" {
Expand Down Expand Up @@ -283,14 +264,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" {
Expand Down
Loading
Loading