Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
314a75b
`TrivialTypeTraversalImpls!`: also impl `GenericTypeVisitable`
ada4a Sep 16, 2026
e394051
dogfood: add missing `GenericTypeVisitable` impls
ada4a Sep 30, 2026
3d8a17a
Make partial `-Z stack-protector` a future-compat warning by default …
Jun 15, 2026
df42c7b
elide potentially-problematic projection clauses
dianne Oct 6, 2026
307ecc0
vexos: clear .bss from assembly
tropicaaal Oct 8, 2026
3e2bec1
Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports
cezarbbb Sep 29, 2026
85bdd9d
std: vexos: use mov rather than movs to clear bss
tropicaaal Oct 8, 2026
810627f
vexos: use post-indexed str over stm for clarity
tropicaaal Oct 8, 2026
a9388e6
run `tests/debuginfo` on `x86_64-mingw`
Walnut356 Oct 6, 2026
19735e0
add MISSING_GENERIC_TYPE_VISITABLE lint
ada4a Aug 1, 2026
7cbe17e
Condense AdtDef lang item checks into one match
oli-obk Oct 8, 2026
02f6b38
_Complex for mips
folkertdev Jul 26, 2026
e5ddf33
Add `bf16` to arm features
Jamesbarford Oct 8, 2026
8186e2c
Include enclosing item's context on const errors
estebank Oct 8, 2026
13703b5
comptime fn error: suggest wrapping in const block
mejrs Oct 8, 2026
a61d626
run completions-check and tidy in parallel
the8472 Aug 16, 2026
7f191f9
reduce str.contains(&str) calls in tidy
the8472 Aug 16, 2026
1eed105
run tidy::deps in multiple threads
the8472 Aug 16, 2026
2c43f7a
Revert "compiletest: stream output of executor process when --no-capt…
jieyouxu Oct 8, 2026
916dda0
Distinguish `repr(C)` ZSTs from others in ABI computation
Jules-Bertholet Oct 2, 2026
e4dc7a1
m68k-unknown-none-elf: Remove code model
techmetx11 Oct 8, 2026
43ee7e6
replace instances of NonNull::new(&mut x).expect(...) with NonNull::f…
Cheese-Space Oct 8, 2026
54e7952
use pre-borrowck typing env during initial MIR analysis
amirHdev Oct 5, 2026
c3054b8
update UI tests for pre-borrowck typing environment
amirHdev Oct 8, 2026
28583f5
Add more test cases of type not found caused by derive macro
estebank Sep 26, 2026
afe9fa8
Tweak `WellFormedLoc`
estebank Oct 7, 2026
6360772
Add tests for 84346 and 105753
estebank Oct 7, 2026
7328f11
Silence redundant failed obligations on the same statement
estebank Oct 7, 2026
98cd354
Use `WellFormedLoc::HirId` for `offset_of!` `Sized` obligation cause …
estebank Oct 7, 2026
83bd0e0
Update test output
estebank Oct 8, 2026
c77999a
On name not found in derive macro, point at the attribute
estebank Sep 26, 2026
2ac3993
Do not provide useless context on resolve error in derive macro
estebank Sep 26, 2026
746e155
Do not suggest adding params to item when error comes from derive macro
estebank Sep 26, 2026
9025bde
Rollup merge of #156112 - Jules-Bertholet:distinguish-c-zsts, r=oli-obk
JonathanBrouwer Oct 8, 2026
4a1f44c
Rollup merge of #157941 - arielb1:deny-partial-stack-protector, r=rcv…
JonathanBrouwer Oct 8, 2026
364c485
Rollup merge of #163462 - cezarbbb:symbol-edit-undecorate-coff, r=bjorn3
JonathanBrouwer Oct 8, 2026
1cf13b7
Rollup merge of #163855 - estebank:const-context-spans, r=oli-obk
JonathanBrouwer Oct 8, 2026
bc149fe
Rollup merge of #163861 - Walnut356:windows_gnu_di_test, r=Kobzol
JonathanBrouwer Oct 8, 2026
41dce4c
Rollup merge of #163913 - estebank:wellformedloc, r=oli-obk
JonathanBrouwer Oct 8, 2026
a0ae9d9
Rollup merge of #161201 - the8472:tidy-opts, r=Kobzol
JonathanBrouwer Oct 8, 2026
3c02a3e
Rollup merge of #163380 - estebank:issue-160463-2, r=TaKO8Ki
JonathanBrouwer Oct 8, 2026
0a2f88c
Rollup merge of #163538 - ada4a:missing-generic-type-visitable, r=Jon…
JonathanBrouwer Oct 8, 2026
30a1a4a
Rollup merge of #163617 - folkertdev:complex-mips, r=beetrees
JonathanBrouwer Oct 8, 2026
f90de16
Rollup merge of #163772 - mejrs:comptime_error, r=nnethercote
JonathanBrouwer Oct 8, 2026
32014bc
Rollup merge of #163813 - amirHdev:typing-env-early-analysis, r=lcnr
JonathanBrouwer Oct 8, 2026
067b3e8
Rollup merge of #163924 - Cheese-Space:main, r=hanna-kruppe
JonathanBrouwer Oct 8, 2026
e8b6023
Rollup merge of #163958 - dianne:fix-rustaceansareawesome-take-2-part…
JonathanBrouwer Oct 8, 2026
b0c172e
Rollup merge of #163960 - vexide:tropicaaal/asm-bss-clear, r=hanna-kr…
JonathanBrouwer Oct 8, 2026
8fe783e
Rollup merge of #163974 - oli-obk:push-psmmpmqzwvmo, r=lqd
JonathanBrouwer Oct 8, 2026
9d20839
Rollup merge of #163979 - Jamesbarford:feat/add-bf16-to-arm-features,…
JonathanBrouwer Oct 8, 2026
180887a
Rollup merge of #163989 - jieyouxu:revert-stream-output, r=lqd
JonathanBrouwer Oct 8, 2026
bbed2e8
Rollup merge of #163995 - techmetx11:m68k-target-specs, r=folkertdev
JonathanBrouwer Oct 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size,
max_repr_align: None,
unadjusted_abi_align: element.align.abi,
repr_c: element.repr_c,
randomization_seed: element.randomization_seed.wrapping_add(Hash64::new(count)),
})
}
Expand Down Expand Up @@ -501,6 +502,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
return Err(LayoutCalculatorError::EmptyUnion);
};

// We also need to check for a `repr(transparent)` wrapper around `repr(C)`
let repr_c =
repr.c() || (repr.transparent() && only_variant.iter().any(|field| field.repr_c));

let combined_seed = only_variant
.iter()
.map(|v| v.randomization_seed)
Expand All @@ -516,6 +521,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size: size.align_to(align),
max_repr_align,
unadjusted_abi_align,
repr_c,
randomization_seed: combined_seed,
})
}
Expand Down Expand Up @@ -747,6 +753,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
align: AbiAlign::new(align),
max_repr_align,
unadjusted_abi_align,
repr_c: repr.c(),
randomization_seed: combined_seed,
};

Expand Down Expand Up @@ -1055,6 +1062,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size,
max_repr_align,
unadjusted_abi_align,
repr_c: repr.c(),
randomization_seed: combined_seed,
};

Expand Down Expand Up @@ -1409,6 +1417,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
unadjusted_abi_align
};

// We also need to check for a `repr(transparent)` wrapper around `repr(C)`
let repr_c = repr.c() || (repr.transparent() && fields.iter().any(|field| field.repr_c));

let seed = field_seed.wrapping_add(repr.field_shuffle_seed);

Ok(LayoutData {
Expand All @@ -1421,6 +1432,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
size,
max_repr_align,
unadjusted_abi_align,
repr_c,
randomization_seed: seed,
})
}
Expand Down Expand Up @@ -1519,6 +1531,7 @@ where
align: AbiAlign::new(align),
max_repr_align: None,
unadjusted_abi_align: elt.align.abi,
repr_c: false,
randomization_seed: elt.randomization_seed.wrapping_add(Hash64::new(count.as_u64())),
})
}
1 change: 1 addition & 0 deletions compiler/rustc_abi/src/layout/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ where
align,
max_repr_align: None,
unadjusted_abi_align: align.abi,
repr_c: false,
randomization_seed: Default::default(),
})
}
6 changes: 6 additions & 0 deletions compiler/rustc_abi/src/layout/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
repr_c: false,
randomization_seed: Hash64::new(0),
}
}
Expand All @@ -42,6 +43,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
repr_c: false,
randomization_seed: Hash64::ZERO,
}
}
Expand Down Expand Up @@ -84,6 +86,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
align,
max_repr_align: None,
unadjusted_abi_align: align.abi,
repr_c: false,
randomization_seed: Hash64::new(randomization_seed),
}
}
Expand Down Expand Up @@ -117,6 +120,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size,
max_repr_align: None,
unadjusted_abi_align: align,
repr_c: false,
randomization_seed: Hash64::new(combined_seed),
}
}
Expand All @@ -143,6 +147,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
size: Size::ZERO,
max_repr_align: None,
unadjusted_abi_align: dl.i8_align,
repr_c: false,
// Variant layouts never flow back into actual layout computations,
// so dummy values are fine here.
randomization_seed: Hash64::ZERO,
Expand All @@ -169,6 +174,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
align: parent.align,
max_repr_align: parent.max_repr_align,
unadjusted_abi_align: parent.unadjusted_abi_align,
repr_c: parent.repr_c,
// Variant layouts never flow back into actual layout computations,
// so dummy values are fine here.
randomization_seed: Hash64::ZERO,
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,13 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
/// alignment in some cases.
pub unadjusted_abi_align: Align,

/// Whether this type is `repr(C)`, or a `repr(transparent)` wrapper around such,
/// or an array of such.
/// This matters because we must follow the C ABI for these types.
/// Some C ABIs pass `repr(C)` ZSTs by pointer, but `repr(Rust)` ZSTs should always
/// be ignored.
pub repr_c: bool,

/// The randomization seed based on this type's own repr and its fields.
///
/// Since randomization is toggled on a per-crate basis even crates that do not have randomization
Expand Down Expand Up @@ -2303,6 +2310,12 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
}
}
}

/// Returns `true` if this is a `repr(C)` type,
/// or an array of such, or a `repr(transparent)` wrapper around such
pub fn is_repr_c(&self) -> bool {
self.repr_c
}
}

impl<FieldIdx: Idx, VariantIdx: Idx> fmt::Debug for LayoutData<FieldIdx, VariantIdx>
Expand All @@ -2324,6 +2337,7 @@ where
variants,
max_repr_align,
unadjusted_abi_align,
repr_c,
randomization_seed,
} = self;
f.debug_struct("Layout")
Expand All @@ -2336,6 +2350,7 @@ where
.field("variants", variants)
.field("max_repr_align", max_repr_align)
.field("unadjusted_abi_align", unadjusted_abi_align)
.field("repr_c", repr_c)
.field("randomization_seed", randomization_seed)
.finish()
}
Expand Down
52 changes: 6 additions & 46 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use rustc_span::{Symbol, bug};
use rustc_structures::{CrateType, NativeLibKind};
use rustc_target::spec::crt_objects::CrtObjects;
use rustc_target::spec::{
Arch, BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents,
BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents,
LinkSelfContainedDefault, LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, Os, RelocModel,
RelroLevel, SanitizerSet, SplitDebuginfo,
};
Expand All @@ -58,7 +58,7 @@ use super::linker::{self, Linker};
use super::metadata::{MetadataPosition, create_wrapper_file};
use super::rmeta_link::RmetaLinkCache;
use super::rpath::{self, RPathConfig};
use super::{apple, rmeta_link, versioned_llvm_target};
use super::{apple, rmeta_link, symbol_export, versioned_llvm_target};
use crate::base::needs_allocator_shim_for_linking;
use crate::{
CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport,
Expand Down Expand Up @@ -2759,10 +2759,6 @@ fn add_rpath_args(
}
}

fn strip_numeric_suffix<'a>(base: &'a str, suffix: impl AsRef<str>, fallback: &'a str) -> &'a str {
if suffix.as_ref().parse::<u32>().is_ok() { base } else { fallback }
}

fn undecorate_c_symbol<'a>(
name: &'a str,
sess: &Session,
Expand All @@ -2775,47 +2771,11 @@ fn undecorate_c_symbol<'a>(
name.strip_prefix('_')
}
BinaryFormat::Coff => {
// MSVC C++ mangled names start with '?' and use a completely different
// decorating scheme that includes '@@' as structural delimiters.
// They must not be subjected to C calling-convention undecoration.
if name.starts_with('?') {
return Some(name);
// COFF undecoration is shared with `symbol_edit`'s binary-level matching.
match symbol_export::coff_machine_for_arch(&sess.target.arch) {
Some(machine) => Some(symbol_export::undecorate_coff_symbol(name, machine, kind)),
None => Some(name),
}
Some(match sess.target.arch {
Arch::X86 => {
// COFF 32-bit: strip calling-convention decorations.
if let Some(rest) = name.strip_prefix('@') {
// fastcall: @foo@N -> foo
rest.rsplit_once('@')
.map(|(base, suffix)| strip_numeric_suffix(base, suffix, name))
.unwrap_or(name)
} else if let Some(stripped) = name.strip_prefix('_') {
if let Some((base, suffix)) = stripped.rsplit_once('@') {
// stdcall: _foo@N -> foo
strip_numeric_suffix(base, suffix, stripped)
} else {
// cdecl: _foo -> foo
stripped
}
} else {
// vectorcall: foo@@N -> foo
name.rsplit_once("@@")
.map(|(base, suffix)| strip_numeric_suffix(base, suffix, name))
.unwrap_or(name)
}
}
Arch::X86_64 => {
// COFF 64-bit: vectorcall mangling (foo@@N -> foo) also applies on x86_64.
name.rsplit_once("@@")
.map(|(base, suffix)| strip_numeric_suffix(base, suffix, name))
.unwrap_or(name)
}
Arch::Arm64EC if kind == SymbolExportKind::Text => {
// Arm64EC: `#` prefix distinguishes ARM64EC text symbols from x64 thunks.
name.strip_prefix('#').unwrap_or(name)
}
_ => name,
})
}
// ELF: no decoration
_ => Some(name),
Expand Down
67 changes: 22 additions & 45 deletions compiler/rustc_codegen_ssa/src/back/symbol_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use object::read::elf::{SectionHeader as _, Sym as _};
use object::read::macho::Nlist;
use object::{Endianness, elf, macho, pe};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_middle::middle::exported_symbols::SymbolExportKind;

use super::symbol_export::undecorate_coff_symbol;

struct Patch {
offset: usize,
Expand Down Expand Up @@ -58,20 +61,8 @@ pub(super) fn apply_edits<'a>(
rename,
mem::offset_of!(macho::Nlist32<Endianness>, n_type),
),
Some(object::File::Coff(f)) => coff_edit_impl(
data,
f.coff_header(),
hide,
rename,
coff_strip_underscore(f.coff_header()),
),
Some(object::File::CoffBig(f)) => coff_edit_impl(
data,
f.coff_header(),
hide,
rename,
coff_strip_underscore(f.coff_header()),
),
Some(object::File::Coff(f)) => coff_edit_impl(data, f.coff_header(), hide, rename),
Some(object::File::CoffBig(f)) => coff_edit_impl(data, f.coff_header(), hide, rename),
_ => None,
};
match result {
Expand Down Expand Up @@ -99,28 +90,20 @@ pub(super) fn collect_internal_names(
object::File::MachO32(_) => {
macho_collect_impl::<macho::MachHeader32<Endianness>>(data, exported, out)
}
object::File::Coff(f) => coff_collect_impl(
data,
f.coff_header(),
exported,
out,
coff_strip_underscore(f.coff_header()),
),
object::File::CoffBig(f) => coff_collect_impl(
data,
f.coff_header(),
exported,
out,
coff_strip_underscore(f.coff_header()),
),
object::File::Coff(f) => coff_collect_impl(data, f.coff_header(), exported, out),
object::File::CoffBig(f) => coff_collect_impl(data, f.coff_header(), exported, out),
_ => {}
}
}

/// Whether this machine's COFF ABI decorates external symbols with a leading `_`
/// (i686 only).
fn coff_strip_underscore(header: &impl CoffHeader) -> bool {
header.machine() == pe::IMAGE_FILE_MACHINE_I386
/// The `SymbolExportKind` of a COFF symbol, so `#`-prefixed `Arm64EC` text symbols are told
/// apart from data symbols during undecoration.
fn coff_symbol_kind(sym: &impl object::read::coff::ImageSymbol) -> SymbolExportKind {
if sym.derived_type() == pe::IMAGE_SYM_DTYPE_FUNCTION {
SymbolExportKind::Text
} else {
SymbolExportKind::Data
}
}

fn elf_collect_impl<Elf: object::read::elf::FileHeader<Endian = Endianness>>(
Expand Down Expand Up @@ -485,10 +468,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>(
header: &'data Coff,
exported: &FxHashSet<String>,
out: &mut FxHashSet<String>,
strip_underscore: bool,
) {
let Ok(symbols) = header.symbols(data) else { return };
let strings = symbols.strings();
let machine = header.machine();

for (_index, sym) in symbols.iter() {
let sclass = sym.storage_class();
Expand All @@ -499,15 +482,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>(
continue;
}
let Ok(name_bytes) = sym.name(strings) else { continue };
let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue };
if strip_underscore {
name = name.strip_prefix('_').unwrap_or(&name).to_string();
}
let is_exported = exported.contains(&name)
|| (header.machine() == pe::IMAGE_FILE_MACHINE_ARM64EC
&& name.strip_prefix('#').is_some_and(|name| exported.contains(name)));
if !is_exported {
out.insert(name);
let Ok(name) = str::from_utf8(name_bytes) else { continue };
let name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym));
if !exported.contains(name) {
out.insert(name.to_string());
}
}
}
Expand All @@ -517,7 +495,6 @@ fn coff_edit_impl<'data, Coff: CoffHeader>(
header: &'data Coff,
hide: bool,
rename: Option<&(FxHashSet<String>, &str)>,
strip_underscore: bool,
) -> Option<Vec<u8>> {
// COFF has no visibility concept, so hiding is unsupported; the caller
// has already warned and does not request it.
Expand Down Expand Up @@ -545,6 +522,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>(

let Ok(symbols) = header.symbols(data) else { return None };
let strings = symbols.strings();
let machine = header.machine();

let mut renames = Vec::new();
for (index, sym) in symbols.iter() {
Expand All @@ -554,8 +532,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>(
}
let Ok(name_bytes) = sym.name(strings) else { continue };
let Ok(name) = str::from_utf8(name_bytes) else { continue };
let check_name =
if strip_underscore { name.strip_prefix('_').unwrap_or(name) } else { name };
let check_name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym));
if rename.is_some_and(|(rename_set, _)| rename_set.contains(check_name)) {
renames.push(RenameEntry {
name_field_offset: symbol_bytes_offset + index.0 * sym_size,
Expand Down
Loading
Loading