Skip to content

Commit 11853ec

Browse files
committed
Auto merge of rust-lang#123517 - GuillaumeGomez:rollup-eys3jfp, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#121419 (Add aarch64-apple-visionos and aarch64-apple-visionos-sim tier 3 targets) - rust-lang#123159 (Fix target-cpu fpu features on Arm R/M-profile) - rust-lang#123487 (CFI: Restore typeid_for_instance default behavior) - rust-lang#123500 (Revert removing miri jobserver workaround) - rust-lang#123505 (Revert "Use OS thread name by default") - rust-lang#123509 (Add jieyouxu to compiler review rotation and as a reviewer for `tests/run-make`, `src/tools/run-make-support` and `src/tools/compiletest`) - rust-lang#123514 (Fix typo in `compiler/rustc_middle/src/traits/solve/inspect.rs`) - rust-lang#123515 (Use `include` command to reduce code duplication) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9d79cd5 + a074d27 commit 11853ec

File tree

110 files changed

+741
-370
lines changed

Some content is hidden

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

110 files changed

+741
-370
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+1
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
912912
|| cgcx.opts.target_triple.triple().contains("-darwin")
913913
|| cgcx.opts.target_triple.triple().contains("-tvos")
914914
|| cgcx.opts.target_triple.triple().contains("-watchos")
915+
|| cgcx.opts.target_triple.triple().contains("-visionos")
915916
}
916917

917918
fn target_is_aix(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {

compiler/rustc_codegen_llvm/src/declare.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
147147
for options in [
148148
TypeIdOptions::GENERALIZE_POINTERS,
149149
TypeIdOptions::NORMALIZE_INTEGERS,
150-
TypeIdOptions::ERASE_SELF_TYPE,
150+
TypeIdOptions::USE_CONCRETE_SELF,
151151
]
152152
.into_iter()
153153
.powerset()
@@ -173,9 +173,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
173173

174174
if self.tcx.sess.is_sanitizer_kcfi_enabled() {
175175
// LLVM KCFI does not support multiple !kcfi_type attachments
176-
// Default to erasing the self type. If we need the concrete type, there will be a
177-
// hint in the instance.
178-
let mut options = TypeIdOptions::ERASE_SELF_TYPE;
176+
let mut options = TypeIdOptions::empty();
179177
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
180178
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
181179
}

compiler/rustc_codegen_ssa/src/back/link.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2946,7 +2946,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
29462946
let os = &sess.target.os;
29472947
let llvm_target = &sess.target.llvm_target;
29482948
if sess.target.vendor != "apple"
2949-
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "macos")
2949+
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "visionos" | "macos")
29502950
|| !matches!(flavor, LinkerFlavor::Darwin(..))
29512951
{
29522952
return;
@@ -2971,6 +2971,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
29712971
("arm64_32", "watchos") => "watchos",
29722972
("aarch64", "watchos") if llvm_target.ends_with("-simulator") => "watchsimulator",
29732973
("aarch64", "watchos") => "watchos",
2974+
("aarch64", "visionos") if llvm_target.ends_with("-simulator") => "xrsimulator",
2975+
("aarch64", "visionos") => "xros",
29742976
("arm", "watchos") => "watchos",
29752977
(_, "macos") => "macosx",
29762978
_ => {
@@ -3027,6 +3029,10 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
30273029
|| sdkroot.contains("MacOSX.platform") => {}
30283030
"watchsimulator"
30293031
if sdkroot.contains("WatchOS.platform") || sdkroot.contains("MacOSX.platform") => {}
3032+
"visionos"
3033+
if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {}
3034+
"visionossimulator"
3035+
if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {}
30303036
// Ignore `SDKROOT` if it's not a valid path.
30313037
_ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {}
30323038
_ => return Ok(sdkroot),

compiler/rustc_middle/src/traits/solve/inspect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub enum ProbeStep<'tcx> {
130130
pub enum ProbeKind<'tcx> {
131131
/// The root inference context while proving a goal.
132132
Root { result: QueryResult<'tcx> },
133-
/// Trying to normalize an alias by at least one stpe in `NormalizesTo`.
133+
/// Trying to normalize an alias by at least one step in `NormalizesTo`.
134134
TryNormalizeNonRigid { result: QueryResult<'tcx> },
135135
/// Probe entered when normalizing the self ty during candidate assembly
136136
NormalizedSelfTyAssembly,

compiler/rustc_symbol_mangling/src/typeid.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ bitflags! {
2424
/// `-fsanitize-cfi-icall-experimental-normalize-integers` option for cross-language LLVM
2525
/// CFI and KCFI support.
2626
const NORMALIZE_INTEGERS = 4;
27-
/// Generalize the instance by erasing the concrete `Self` type where possible.
28-
/// Only has an effect on `{kcfi_,}typeid_for_instance`.
29-
const ERASE_SELF_TYPE = 8;
27+
/// Do not perform self type erasure for attaching a secondary type id to methods with their
28+
/// concrete self so they can be used as function pointers.
29+
///
30+
/// (This applies to typeid_for_instance only and should be used to attach a secondary type
31+
/// id to methods during their declaration/definition so they match the type ids returned by
32+
/// either typeid_for_instance or typeid_for_fnabi at call sites during code generation for
33+
/// type membership tests when methods are used as function pointers.)
34+
const USE_CONCRETE_SELF = 8;
3035
}
3136
}
3237

@@ -69,10 +74,23 @@ pub fn kcfi_typeid_for_instance<'tcx>(
6974
instance: Instance<'tcx>,
7075
mut options: TypeIdOptions,
7176
) -> u32 {
72-
// If we receive a `ReifyShim` intended to produce a function pointer, we need to remain
73-
// concrete - abstraction is for vtables.
77+
// KCFI support for Rust shares most of its implementation with the CFI support, with some key
78+
// differences:
79+
//
80+
// 1. KCFI performs type tests differently and are implemented as different LLVM passes than CFI
81+
// to not require LTO.
82+
// 2. KCFI has the limitation that a function or method may have one type id assigned only.
83+
//
84+
// Because of the limitation listed above (2), the current KCFI implementation (not CFI) does
85+
// reifying of types (i.e., adds shims/trampolines for indirect calls in these cases) for:
86+
//
87+
// * Supporting casting between function items, closures, and Fn trait objects.
88+
// * Supporting methods being cast as function pointers.
89+
//
90+
// This was implemented for KCFI support in #123106 and #123052 (which introduced the
91+
// ReifyReason). The tracking issue for KCFI support for Rust is #123479.
7492
if matches!(instance.def, InstanceDef::ReifyShim(_, Some(ReifyReason::FnPtr))) {
75-
options.remove(TypeIdOptions::ERASE_SELF_TYPE);
93+
options.insert(TypeIdOptions::USE_CONCRETE_SELF);
7694
}
7795
// A KCFI type metadata identifier is a 32-bit constant produced by taking the lower half of the
7896
// xxHash64 of the type metadata identifier. (See llvm/llvm-project@cff5bef.)

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ pub fn typeid_for_instance<'tcx>(
10981098
instance.args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1));
10991099
}
11001100

1101-
if options.contains(EncodeTyOptions::ERASE_SELF_TYPE) {
1101+
if !options.contains(EncodeTyOptions::USE_CONCRETE_SELF) {
11021102
if let Some(impl_id) = tcx.impl_of_method(instance.def_id())
11031103
&& let Some(trait_ref) = tcx.impl_trait_ref(impl_id)
11041104
{

compiler/rustc_target/src/spec/base/apple/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
102102
"ios" => ios_deployment_target(arch, abi),
103103
"tvos" => tvos_deployment_target(),
104104
"watchos" => watchos_deployment_target(),
105+
"visionos" => visionos_deployment_target(),
105106
"macos" => macos_deployment_target(arch),
106107
_ => unreachable!(),
107108
};
@@ -202,6 +203,8 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> {
202203
| object::macho::PLATFORM_TVOSSIMULATOR
203204
| object::macho::PLATFORM_MACCATALYST => Some((16, 2)),
204205
object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)),
206+
// FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
207+
11 | 12 => Some((1, 0)),
205208
_ => None,
206209
}
207210
}
@@ -216,6 +219,9 @@ pub fn platform(target: &Target) -> Option<u32> {
216219
("watchos", _) => object::macho::PLATFORM_WATCHOS,
217220
("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR,
218221
("tvos", _) => object::macho::PLATFORM_TVOS,
222+
// FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
223+
("visionos", "sim") => 12,
224+
("visionos", _) => 11,
219225
_ => return None,
220226
})
221227
}
@@ -240,6 +246,7 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> {
240246
}
241247
"watchos" => watchos_deployment_target(),
242248
"tvos" => tvos_deployment_target(),
249+
"visionos" => visionos_deployment_target(),
243250
_ => return None,
244251
};
245252

@@ -290,6 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
290297
|| sdkroot.contains("AppleTVSimulator.platform")
291298
|| sdkroot.contains("WatchOS.platform")
292299
|| sdkroot.contains("WatchSimulator.platform")
300+
|| sdkroot.contains("XROS.platform")
293301
{
294302
env_remove.push("SDKROOT".into())
295303
}
@@ -299,6 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
299307
// although this is apparently ignored when using the linker at "/usr/bin/ld".
300308
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into());
301309
env_remove.push("TVOS_DEPLOYMENT_TARGET".into());
310+
env_remove.push("XROS_DEPLOYMENT_TARGET".into());
302311
env_remove.into()
303312
} else {
304313
// Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part
@@ -363,3 +372,18 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String {
363372
let (major, minor) = watchos_deployment_target();
364373
format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor)
365374
}
375+
376+
fn visionos_deployment_target() -> (u32, u32) {
377+
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
378+
from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0))
379+
}
380+
381+
pub fn visionos_llvm_target(arch: Arch) -> String {
382+
let (major, minor) = visionos_deployment_target();
383+
format!("{}-apple-visionos{}.{}.0", arch.target_name(), major, minor)
384+
}
385+
386+
pub fn visionos_sim_llvm_target(arch: Arch) -> String {
387+
let (major, minor) = visionos_deployment_target();
388+
format!("{}-apple-visionos{}.{}.0-simulator", arch.target_name(), major, minor)
389+
}

compiler/rustc_target/src/spec/base/apple/tests.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::spec::targets::{
2-
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin,
3-
x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim,
2+
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_visionos_sim,
3+
aarch64_apple_watchos_sim, i686_apple_darwin, x86_64_apple_darwin, x86_64_apple_ios,
4+
x86_64_apple_tvos, x86_64_apple_watchos_sim,
45
};
56

67
#[test]
@@ -12,6 +13,7 @@ fn simulator_targets_set_abi() {
1213
aarch64_apple_ios_sim::target(),
1314
// Note: There is currently no ARM64 tvOS simulator target
1415
aarch64_apple_watchos_sim::target(),
16+
aarch64_apple_visionos_sim::target(),
1517
];
1618

1719
for target in &all_sim_targets {
@@ -32,7 +34,11 @@ fn macos_link_environment_unmodified() {
3234
// for the host.
3335
assert_eq!(
3436
target.link_env_remove,
35-
crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET"],
37+
crate::spec::cvs![
38+
"IPHONEOS_DEPLOYMENT_TARGET",
39+
"TVOS_DEPLOYMENT_TARGET",
40+
"XROS_DEPLOYMENT_TARGET"
41+
],
3642
);
3743
}
3844
}

compiler/rustc_target/src/spec/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,9 @@ supported_targets! {
15571557
("aarch64-apple-watchos", aarch64_apple_watchos),
15581558
("aarch64-apple-watchos-sim", aarch64_apple_watchos_sim),
15591559

1560+
("aarch64-apple-visionos", aarch64_apple_visionos),
1561+
("aarch64-apple-visionos-sim", aarch64_apple_visionos_sim),
1562+
15601563
("armebv7r-none-eabi", armebv7r_none_eabi),
15611564
("armebv7r-none-eabihf", armebv7r_none_eabihf),
15621565
("armv7r-none-eabi", armv7r_none_eabi),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::spec::base::apple::{opts, visionos_llvm_target, Arch};
2+
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let arch = Arch::Arm64;
6+
let mut base = opts("visionos", arch);
7+
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
8+
9+
Target {
10+
llvm_target: visionos_llvm_target(arch).into(),
11+
metadata: crate::spec::TargetMetadata {
12+
description: Some("ARM64 Apple visionOS".into()),
13+
tier: Some(3),
14+
host_tools: Some(false),
15+
std: Some(false),
16+
},
17+
pointer_width: 64,
18+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
19+
arch: arch.target_arch(),
20+
options: TargetOptions {
21+
features: "+neon,+fp-armv8,+apple-a16".into(),
22+
max_atomic_width: Some(128),
23+
frame_pointer: FramePointer::NonLeaf,
24+
..base
25+
},
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::spec::base::apple::{opts, visionos_sim_llvm_target, Arch};
2+
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let arch = Arch::Arm64_sim;
6+
let mut base = opts("visionos", arch);
7+
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
8+
9+
Target {
10+
llvm_target: visionos_sim_llvm_target(arch).into(),
11+
metadata: crate::spec::TargetMetadata {
12+
description: Some("ARM64 Apple visionOS simulator".into()),
13+
tier: Some(3),
14+
host_tools: Some(false),
15+
std: Some(false),
16+
},
17+
pointer_width: 64,
18+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
19+
arch: arch.target_arch(),
20+
options: TargetOptions {
21+
features: "+neon,+fp-armv8,+apple-a16".into(),
22+
max_atomic_width: Some(128),
23+
frame_pointer: FramePointer::NonLeaf,
24+
..base
25+
},
26+
}
27+
}

compiler/rustc_target/src/spec/targets/armebv7r_none_eabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn target() -> Target {
2222
linker: Some("rust-lld".into()),
2323
relocation_model: RelocModel::Static,
2424
panic_strategy: PanicStrategy::Abort,
25-
features: "+vfp3,-d32,-fp16".into(),
25+
features: "+vfp3d16".into(),
2626
max_atomic_width: Some(64),
2727
emit_debug_gdb_scripts: false,
2828
// GCC defaults to 8 for arm-none here.

compiler/rustc_target/src/spec/targets/armv7r_none_eabihf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn target() -> Target {
2121
linker: Some("rust-lld".into()),
2222
relocation_model: RelocModel::Static,
2323
panic_strategy: PanicStrategy::Abort,
24-
features: "+vfp3,-d32,-fp16".into(),
24+
features: "+vfp3d16".into(),
2525
max_atomic_width: Some(64),
2626
emit_debug_gdb_scripts: false,
2727
// GCC defaults to 8 for arm-none here.

compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ pub fn target() -> Target {
2525

2626
options: TargetOptions {
2727
abi: "eabihf".into(),
28-
// `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the
29-
// Cortex-M7 (vfp5)
30-
// `-d32` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers
31-
// available
32-
// `-fp64` The Cortex-M4 only supports single precision floating point operations
33-
// whereas in the Cortex-M7 double precision is optional
28+
// vfp4 is the lowest common denominator between the Cortex-M4F (vfp4) and the
29+
// Cortex-M7 (vfp5).
30+
// Both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers
31+
// available, and the Cortex-M4 only supports single-precision floating point operations
32+
// whereas in the Cortex-M7 double-precision is optional.
3433
//
3534
// Reference:
3635
// ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension
37-
features: "+vfp4,-d32,-fp64".into(),
36+
features: "+vfp4d16sp".into(),
3837
max_atomic_width: Some(32),
3938
..base::thumb::opts()
4039
},

compiler/rustc_target/src/spec/targets/thumbv8m_main_none_eabihf.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub fn target() -> Target {
2222
// processor, the Cortex-M33 Technical Reference Manual states that
2323
// the FPU uses the FPv5 architecture, single-precision instructions
2424
// and 16 D registers.
25-
// These parameters map to the following LLVM features.
26-
features: "+fp-armv8,-fp64,-d32".into(),
25+
features: "+fp-armv8d16sp".into(),
2726
max_atomic_width: Some(32),
2827
..base::thumb::opts()
2928
},

library/std/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn main() {
2222
|| target_os == "ios"
2323
|| target_os == "tvos"
2424
|| target_os == "watchos"
25+
|| target_os == "visionos"
2526
|| target_os == "windows"
2627
|| target_os == "fuchsia"
2728
|| (target_vendor == "fortanix" && target_env == "sgx")

0 commit comments

Comments
 (0)