Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
100 changes: 0 additions & 100 deletions library/unwind/src/unwinding.rs

This file was deleted.

Loading
Loading