Skip to content

Commit 18d5c6f

Browse files
committed
Auto merge of rust-lang#121836 - workingjubilee:rollup-vrtx5t9, r=workingjubilee
Rollup of 8 pull requests Successful merges: - rust-lang#117156 (Convert `Unix{Datagram,Stream}::{set_}passcred()` to per-OS traits) - rust-lang#119199 (Add arm64ec-pc-windows-msvc target) - rust-lang#120468 (Add a new `wasm32-wasip1` target to rustc) - rust-lang#121416 (Improve error messages for generics with default parameters) - rust-lang#121475 (Add tidy check for .stderr/.stdout files for non-existent test revisions) - rust-lang#121736 (Remove `Mutex::unlock` Function) - rust-lang#121784 (Make the success arms of `if lhs || rhs` meet up in a separate block) - rust-lang#121818 (CFI: Remove unused `typeid_for_fnsig`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6cbf092 + 9017458 commit 18d5c6f

File tree

81 files changed

+956
-1058
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+956
-1058
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ version = "0.1.0"
447447

448448
[[package]]
449449
name = "cc"
450-
version = "1.0.79"
450+
version = "1.0.88"
451451
source = "registry+https://github.com/rust-lang/crates.io-index"
452-
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
452+
checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc"
453453

454454
[[package]]
455455
name = "cfg-if"

compiler/rustc_codegen_llvm/src/back/archive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ fn llvm_machine_type(cpu: &str) -> LLVMMachineType {
5555
"x86_64" => LLVMMachineType::AMD64,
5656
"x86" => LLVMMachineType::I386,
5757
"aarch64" => LLVMMachineType::ARM64,
58+
"arm64ec" => LLVMMachineType::ARM64EC,
5859
"arm" => LLVMMachineType::ARM,
5960
_ => panic!("unsupported cpu type {cpu}"),
6061
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub enum LLVMMachineType {
5656
AMD64 = 0x8664,
5757
I386 = 0x14c,
5858
ARM64 = 0xaa64,
59+
ARM64EC = 0xa641,
5960
ARM = 0x01c0,
6061
}
6162

compiler/rustc_codegen_llvm/src/llvm_util.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
204204
// which might lead to failures if the oldest tested / supported LLVM version
205205
// doesn't yet support the relevant intrinsics
206206
pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
207-
let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch };
207+
let arch = if sess.target.arch == "x86_64" {
208+
"x86"
209+
} else if sess.target.arch == "arm64ec" {
210+
"aarch64"
211+
} else {
212+
&*sess.target.arch
213+
};
208214
match (arch, s) {
209215
("x86", "sse4.2") => {
210216
LLVMFeature::with_dependency("sse4.2", TargetFeatureFoldStrength::EnableOnly("crc32"))

compiler/rustc_codegen_llvm/src/va_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
266266
// Generic x86
267267
"x86" => emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), true),
268268
// Windows AArch64
269-
"aarch64" if target.is_like_windows => {
269+
"aarch64" | "arm64ec" if target.is_like_windows => {
270270
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
271271
}
272272
// macOS / iOS AArch64

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
# tidy-alphabetical-start
88
ar_archive_writer = "0.1.5"
99
bitflags = "2.4.1"
10-
cc = "1.0.69"
10+
cc = "1.0.88"
1111
itertools = "0.11"
1212
jobserver = "0.1.28"
1313
pathdiff = "0.2.0"

compiler/rustc_codegen_ssa/src/back/metadata.rs

+28-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::path::Path;
88
use object::write::{self, StandardSegment, Symbol, SymbolSection};
99
use object::{
1010
elf, pe, xcoff, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection,
11-
ObjectSymbol, SectionFlags, SectionKind, SymbolFlags, SymbolKind, SymbolScope,
11+
ObjectSymbol, SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope,
1212
};
1313

1414
use rustc_data_structures::memmap::Mmap;
@@ -182,37 +182,40 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
182182
Endian::Little => Endianness::Little,
183183
Endian::Big => Endianness::Big,
184184
};
185-
let architecture = match &sess.target.arch[..] {
186-
"arm" => Architecture::Arm,
187-
"aarch64" => {
185+
let (architecture, sub_architecture) = match &sess.target.arch[..] {
186+
"arm" => (Architecture::Arm, None),
187+
"aarch64" => (
188188
if sess.target.pointer_width == 32 {
189189
Architecture::Aarch64_Ilp32
190190
} else {
191191
Architecture::Aarch64
192-
}
193-
}
194-
"x86" => Architecture::I386,
195-
"s390x" => Architecture::S390x,
196-
"mips" | "mips32r6" => Architecture::Mips,
197-
"mips64" | "mips64r6" => Architecture::Mips64,
198-
"x86_64" => {
192+
},
193+
None,
194+
),
195+
"x86" => (Architecture::I386, None),
196+
"s390x" => (Architecture::S390x, None),
197+
"mips" | "mips32r6" => (Architecture::Mips, None),
198+
"mips64" | "mips64r6" => (Architecture::Mips64, None),
199+
"x86_64" => (
199200
if sess.target.pointer_width == 32 {
200201
Architecture::X86_64_X32
201202
} else {
202203
Architecture::X86_64
203-
}
204-
}
205-
"powerpc" => Architecture::PowerPc,
206-
"powerpc64" => Architecture::PowerPc64,
207-
"riscv32" => Architecture::Riscv32,
208-
"riscv64" => Architecture::Riscv64,
209-
"sparc64" => Architecture::Sparc64,
210-
"avr" => Architecture::Avr,
211-
"msp430" => Architecture::Msp430,
212-
"hexagon" => Architecture::Hexagon,
213-
"bpf" => Architecture::Bpf,
214-
"loongarch64" => Architecture::LoongArch64,
215-
"csky" => Architecture::Csky,
204+
},
205+
None,
206+
),
207+
"powerpc" => (Architecture::PowerPc, None),
208+
"powerpc64" => (Architecture::PowerPc64, None),
209+
"riscv32" => (Architecture::Riscv32, None),
210+
"riscv64" => (Architecture::Riscv64, None),
211+
"sparc64" => (Architecture::Sparc64, None),
212+
"avr" => (Architecture::Avr, None),
213+
"msp430" => (Architecture::Msp430, None),
214+
"hexagon" => (Architecture::Hexagon, None),
215+
"bpf" => (Architecture::Bpf, None),
216+
"loongarch64" => (Architecture::LoongArch64, None),
217+
"csky" => (Architecture::Csky, None),
218+
"arm64ec" => (Architecture::Aarch64, Some(SubArchitecture::Arm64EC)),
216219
// Unsupported architecture.
217220
_ => return None,
218221
};
@@ -227,6 +230,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
227230
};
228231

229232
let mut file = write::Object::new(binary_format, architecture, endianness);
233+
file.set_sub_architecture(sub_architecture);
230234
if sess.target.is_like_osx {
231235
if macho_is_arm64e(&sess.target) {
232236
file.set_macho_cpu_subtype(object::macho::CPU_SUBTYPE_ARM64E);

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,10 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
563563
return undecorated;
564564
}
565565

566-
let x86 = match &target.arch[..] {
567-
"x86" => true,
568-
"x86_64" => false,
566+
let prefix = match &target.arch[..] {
567+
"x86" => Some('_'),
568+
"x86_64" => None,
569+
"arm64ec" => Some('#'),
569570
// Only x86/64 use symbol decorations.
570571
_ => return undecorated,
571572
};
@@ -602,8 +603,8 @@ pub fn linking_symbol_name_for_instance_in_crate<'tcx>(
602603
Conv::X86Stdcall => ("_", "@"),
603604
Conv::X86VectorCall => ("", "@@"),
604605
_ => {
605-
if x86 {
606-
undecorated.insert(0, '_');
606+
if let Some(prefix) = prefix {
607+
undecorated.insert(0, prefix);
607608
}
608609
return undecorated;
609610
}

compiler/rustc_codegen_ssa/src/base.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,11 @@ impl CrateInfo {
907907
lang_items::required(tcx, l).then_some(name)
908908
})
909909
.collect();
910-
let prefix = if target.is_like_windows && target.arch == "x86" { "_" } else { "" };
910+
let prefix = match (target.is_like_windows, target.arch.as_ref()) {
911+
(true, "x86") => "_",
912+
(true, "arm64ec") => "#",
913+
_ => "",
914+
};
911915

912916
// This loop only adds new items to values of the hash map, so the order in which we
913917
// iterate over the values is not important.

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -1247,10 +1247,23 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
12471247
(&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => {
12481248
let did1 = def1.did();
12491249
let did2 = def2.did();
1250-
let sub_no_defaults_1 =
1251-
self.tcx.generics_of(did1).own_args_no_defaults(self.tcx, sub1);
1252-
let sub_no_defaults_2 =
1253-
self.tcx.generics_of(did2).own_args_no_defaults(self.tcx, sub2);
1250+
1251+
let generics1 = self.tcx.generics_of(did1);
1252+
let generics2 = self.tcx.generics_of(did2);
1253+
1254+
let non_default_after_default = generics1
1255+
.check_concrete_type_after_default(self.tcx, sub1)
1256+
|| generics2.check_concrete_type_after_default(self.tcx, sub2);
1257+
let sub_no_defaults_1 = if non_default_after_default {
1258+
generics1.own_args(sub1)
1259+
} else {
1260+
generics1.own_args_no_defaults(self.tcx, sub1)
1261+
};
1262+
let sub_no_defaults_2 = if non_default_after_default {
1263+
generics2.own_args(sub2)
1264+
} else {
1265+
generics2.own_args_no_defaults(self.tcx, sub2)
1266+
};
12541267
let mut values = (DiagStyledString::new(), DiagStyledString::new());
12551268
let path1 = self.tcx.def_path_str(did1);
12561269
let path2 = self.tcx.def_path_str(did2);

compiler/rustc_llvm/Cargo.toml

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ edition = "2021"
88
libc = "0.2.73"
99
# tidy-alphabetical-end
1010

11-
# FIXME: updating cc past 1.0.79 breaks libstd bootstrapping, pin
12-
# to the last working version here so `cargo update` doesn't cause the
13-
# a higher version to be selected
14-
# https://github.com/rust-lang/cc-rs/issues/913
15-
# 1.0.{84, 85} fix this but have been yanked
1611
[build-dependencies]
1712
# tidy-alphabetical-start
18-
cc = "=1.0.79"
13+
cc = "1.0.79"
1914
# tidy-alphabetical-end

compiler/rustc_middle/src/ty/generics.rs

+24
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,30 @@ impl<'tcx> Generics {
360360
let own = &args[self.parent_count..][..self.params.len()];
361361
if self.has_self && self.parent.is_none() { &own[1..] } else { own }
362362
}
363+
364+
/// Returns true if a concrete type is specified after a default type.
365+
/// For example, consider `struct T<W = usize, X = Vec<W>>(W, X)`
366+
/// `T<usize, String>` will return true
367+
/// `T<usize>` will return false
368+
pub fn check_concrete_type_after_default(
369+
&'tcx self,
370+
tcx: TyCtxt<'tcx>,
371+
args: &'tcx [ty::GenericArg<'tcx>],
372+
) -> bool {
373+
let mut default_param_seen = false;
374+
for param in self.params.iter() {
375+
if let Some(inst) =
376+
param.default_value(tcx).map(|default| default.instantiate(tcx, args))
377+
{
378+
if inst == args[param.index as usize] {
379+
default_param_seen = true;
380+
} else if default_param_seen {
381+
return true;
382+
}
383+
}
384+
}
385+
false
386+
}
363387
}
364388

365389
/// Bounds on generics.

compiler/rustc_mir_build/src/build/matches/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
9393
variable_source_info,
9494
true,
9595
));
96-
this.cfg.goto(lhs_success_block, variable_source_info, rhs_success_block);
97-
rhs_success_block.unit()
96+
97+
// Make the LHS and RHS success arms converge to a common block.
98+
// (We can't just make LHS goto RHS, because `rhs_success_block`
99+
// might contain statements that we don't want on the LHS path.)
100+
let success_block = this.cfg.start_new_block();
101+
this.cfg.goto(lhs_success_block, variable_source_info, success_block);
102+
this.cfg.goto(rhs_success_block, variable_source_info, success_block);
103+
success_block.unit()
98104
}
99105
ExprKind::Unary { op: UnOp::Not, arg } => {
100106
let local_scope = this.local_scope();

compiler/rustc_symbol_mangling/src/typeid.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
/// For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
55
/// see design document in the tracking issue #89653.
66
use bitflags::bitflags;
7-
use rustc_middle::ty::{FnSig, Instance, Ty, TyCtxt};
7+
use rustc_middle::ty::{Instance, Ty, TyCtxt};
88
use rustc_target::abi::call::FnAbi;
99
use std::hash::Hasher;
1010
use twox_hash::XxHash64;
1111

1212
bitflags! {
13-
/// Options for typeid_for_fnabi and typeid_for_fnsig.
13+
/// Options for typeid_for_fnabi.
1414
#[derive(Clone, Copy, Debug)]
1515
pub struct TypeIdOptions: u32 {
1616
const GENERALIZE_POINTERS = 1;
@@ -30,15 +30,6 @@ pub fn typeid_for_fnabi<'tcx>(
3030
typeid_itanium_cxx_abi::typeid_for_fnabi(tcx, fn_abi, options)
3131
}
3232

33-
/// Returns a type metadata identifier for the specified FnSig.
34-
pub fn typeid_for_fnsig<'tcx>(
35-
tcx: TyCtxt<'tcx>,
36-
fn_sig: &FnSig<'tcx>,
37-
options: TypeIdOptions,
38-
) -> String {
39-
typeid_itanium_cxx_abi::typeid_for_fnsig(tcx, fn_sig, options)
40-
}
41-
4233
/// Returns a type metadata identifier for the specified Instance.
4334
pub fn typeid_for_instance<'tcx>(
4435
tcx: TyCtxt<'tcx>,
@@ -61,19 +52,6 @@ pub fn kcfi_typeid_for_fnabi<'tcx>(
6152
hash.finish() as u32
6253
}
6354

64-
/// Returns a KCFI type metadata identifier for the specified FnSig.
65-
pub fn kcfi_typeid_for_fnsig<'tcx>(
66-
tcx: TyCtxt<'tcx>,
67-
fn_sig: &FnSig<'tcx>,
68-
options: TypeIdOptions,
69-
) -> u32 {
70-
// A KCFI type metadata identifier is a 32-bit constant produced by taking the lower half of the
71-
// xxHash64 of the type metadata identifier. (See llvm/llvm-project@cff5bef.)
72-
let mut hash: XxHash64 = Default::default();
73-
hash.write(typeid_itanium_cxx_abi::typeid_for_fnsig(tcx, fn_sig, options).as_bytes());
74-
hash.finish() as u32
75-
}
76-
7755
/// Returns a KCFI type metadata identifier for the specified Instance.
7856
pub fn kcfi_typeid_for_instance<'tcx>(
7957
tcx: TyCtxt<'tcx>,

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

-35
Original file line numberDiff line numberDiff line change
@@ -1074,41 +1074,6 @@ pub fn typeid_for_fnabi<'tcx>(
10741074
typeid
10751075
}
10761076

1077-
/// Returns a type metadata identifier for the specified FnSig using the Itanium C++ ABI with vendor
1078-
/// extended type qualifiers and types for Rust types that are not used at the FFI boundary.
1079-
pub fn typeid_for_fnsig<'tcx>(
1080-
tcx: TyCtxt<'tcx>,
1081-
fn_sig: &FnSig<'tcx>,
1082-
options: TypeIdOptions,
1083-
) -> String {
1084-
// A name is mangled by prefixing "_Z" to an encoding of its name, and in the case of functions
1085-
// its type.
1086-
let mut typeid = String::from("_Z");
1087-
1088-
// Clang uses the Itanium C++ ABI's virtual tables and RTTI typeinfo structure name as type
1089-
// metadata identifiers for function pointers. The typeinfo name encoding is a two-character
1090-
// code (i.e., 'TS') prefixed to the type encoding for the function.
1091-
typeid.push_str("TS");
1092-
1093-
// A dictionary of substitution candidates used for compression (see
1094-
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression).
1095-
let mut dict: FxHashMap<DictKey<'tcx>, usize> = FxHashMap::default();
1096-
1097-
// Encode the function signature
1098-
typeid.push_str(&encode_fnsig(tcx, fn_sig, &mut dict, options));
1099-
1100-
// Add encoding suffixes
1101-
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
1102-
typeid.push_str(".normalized");
1103-
}
1104-
1105-
if options.contains(EncodeTyOptions::GENERALIZE_POINTERS) {
1106-
typeid.push_str(".generalized");
1107-
}
1108-
1109-
typeid
1110-
}
1111-
11121077
/// Returns a type metadata identifier for the specified Instance using the Itanium C++ ABI with
11131078
/// vendor extended type qualifiers and types for Rust types that are not used at the FFI boundary.
11141079
pub fn typeid_for_instance<'tcx>(

compiler/rustc_target/src/abi/call/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
814814
}
815815
}
816816
},
817-
"aarch64" => {
817+
"aarch64" | "arm64ec" => {
818818
let kind = if cx.target_spec().is_like_osx {
819819
aarch64::AbiKind::DarwinPCS
820820
} else if cx.target_spec().is_like_windows {

compiler/rustc_target/src/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,7 @@ supported_targets! {
15621562

15631563
("aarch64-pc-windows-msvc", aarch64_pc_windows_msvc),
15641564
("aarch64-uwp-windows-msvc", aarch64_uwp_windows_msvc),
1565+
("arm64ec-pc-windows-msvc", arm64ec_pc_windows_msvc),
15651566
("x86_64-pc-windows-msvc", x86_64_pc_windows_msvc),
15661567
("x86_64-uwp-windows-msvc", x86_64_uwp_windows_msvc),
15671568
("x86_64-win7-windows-msvc", x86_64_win7_windows_msvc),
@@ -1575,6 +1576,7 @@ supported_targets! {
15751576
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
15761577
("wasm32-unknown-unknown", wasm32_unknown_unknown),
15771578
("wasm32-wasi", wasm32_wasi),
1579+
("wasm32-wasip1", wasm32_wasip1),
15781580
("wasm32-wasip2", wasm32_wasip2),
15791581
("wasm32-wasi-preview1-threads", wasm32_wasi_preview1_threads),
15801582
("wasm64-unknown-unknown", wasm64_unknown_unknown),

0 commit comments

Comments
 (0)