Skip to content

Commit

Permalink
Auto merge of #123517 - GuillaumeGomez:rollup-eys3jfp, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #121419 (Add aarch64-apple-visionos and aarch64-apple-visionos-sim tier 3 targets)
 - #123159 (Fix target-cpu fpu features on Arm R/M-profile)
 - #123487 (CFI: Restore typeid_for_instance default behavior)
 - #123500 (Revert removing miri jobserver workaround)
 - #123505 (Revert "Use OS thread name by default")
 - #123509 (Add jieyouxu to compiler review rotation and as a reviewer for `tests/run-make`, `src/tools/run-make-support` and `src/tools/compiletest`)
 - #123514 (Fix typo in `compiler/rustc_middle/src/traits/solve/inspect.rs`)
 - #123515 (Use `include` command to reduce code duplication)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 5, 2024
2 parents 9d79cd5 + a074d27 commit 11853ec
Show file tree
Hide file tree
Showing 110 changed files with 741 additions and 370 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
|| cgcx.opts.target_triple.triple().contains("-darwin")
|| cgcx.opts.target_triple.triple().contains("-tvos")
|| cgcx.opts.target_triple.triple().contains("-watchos")
|| cgcx.opts.target_triple.triple().contains("-visionos")
}

fn target_is_aix(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_codegen_llvm/src/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
for options in [
TypeIdOptions::GENERALIZE_POINTERS,
TypeIdOptions::NORMALIZE_INTEGERS,
TypeIdOptions::ERASE_SELF_TYPE,
TypeIdOptions::USE_CONCRETE_SELF,
]
.into_iter()
.powerset()
Expand All @@ -173,9 +173,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {

if self.tcx.sess.is_sanitizer_kcfi_enabled() {
// LLVM KCFI does not support multiple !kcfi_type attachments
// Default to erasing the self type. If we need the concrete type, there will be a
// hint in the instance.
let mut options = TypeIdOptions::ERASE_SELF_TYPE;
let mut options = TypeIdOptions::empty();
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
}
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
let os = &sess.target.os;
let llvm_target = &sess.target.llvm_target;
if sess.target.vendor != "apple"
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "macos")
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "visionos" | "macos")
|| !matches!(flavor, LinkerFlavor::Darwin(..))
{
return;
Expand All @@ -2971,6 +2971,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
("arm64_32", "watchos") => "watchos",
("aarch64", "watchos") if llvm_target.ends_with("-simulator") => "watchsimulator",
("aarch64", "watchos") => "watchos",
("aarch64", "visionos") if llvm_target.ends_with("-simulator") => "xrsimulator",
("aarch64", "visionos") => "xros",
("arm", "watchos") => "watchos",
(_, "macos") => "macosx",
_ => {
Expand Down Expand Up @@ -3027,6 +3029,10 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
|| sdkroot.contains("MacOSX.platform") => {}
"watchsimulator"
if sdkroot.contains("WatchOS.platform") || sdkroot.contains("MacOSX.platform") => {}
"visionos"
if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {}
"visionossimulator"
if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {}
// Ignore `SDKROOT` if it's not a valid path.
_ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {}
_ => return Ok(sdkroot),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/traits/solve/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub enum ProbeStep<'tcx> {
pub enum ProbeKind<'tcx> {
/// The root inference context while proving a goal.
Root { result: QueryResult<'tcx> },
/// Trying to normalize an alias by at least one stpe in `NormalizesTo`.
/// Trying to normalize an alias by at least one step in `NormalizesTo`.
TryNormalizeNonRigid { result: QueryResult<'tcx> },
/// Probe entered when normalizing the self ty during candidate assembly
NormalizedSelfTyAssembly,
Expand Down
30 changes: 24 additions & 6 deletions compiler/rustc_symbol_mangling/src/typeid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ bitflags! {
/// `-fsanitize-cfi-icall-experimental-normalize-integers` option for cross-language LLVM
/// CFI and KCFI support.
const NORMALIZE_INTEGERS = 4;
/// Generalize the instance by erasing the concrete `Self` type where possible.
/// Only has an effect on `{kcfi_,}typeid_for_instance`.
const ERASE_SELF_TYPE = 8;
/// Do not perform self type erasure for attaching a secondary type id to methods with their
/// concrete self so they can be used as function pointers.
///
/// (This applies to typeid_for_instance only and should be used to attach a secondary type
/// id to methods during their declaration/definition so they match the type ids returned by
/// either typeid_for_instance or typeid_for_fnabi at call sites during code generation for
/// type membership tests when methods are used as function pointers.)
const USE_CONCRETE_SELF = 8;
}
}

Expand Down Expand Up @@ -69,10 +74,23 @@ pub fn kcfi_typeid_for_instance<'tcx>(
instance: Instance<'tcx>,
mut options: TypeIdOptions,
) -> u32 {
// If we receive a `ReifyShim` intended to produce a function pointer, we need to remain
// concrete - abstraction is for vtables.
// KCFI support for Rust shares most of its implementation with the CFI support, with some key
// differences:
//
// 1. KCFI performs type tests differently and are implemented as different LLVM passes than CFI
// to not require LTO.
// 2. KCFI has the limitation that a function or method may have one type id assigned only.
//
// Because of the limitation listed above (2), the current KCFI implementation (not CFI) does
// reifying of types (i.e., adds shims/trampolines for indirect calls in these cases) for:
//
// * Supporting casting between function items, closures, and Fn trait objects.
// * Supporting methods being cast as function pointers.
//
// This was implemented for KCFI support in #123106 and #123052 (which introduced the
// ReifyReason). The tracking issue for KCFI support for Rust is #123479.
if matches!(instance.def, InstanceDef::ReifyShim(_, Some(ReifyReason::FnPtr))) {
options.remove(TypeIdOptions::ERASE_SELF_TYPE);
options.insert(TypeIdOptions::USE_CONCRETE_SELF);
}
// A KCFI type metadata identifier is a 32-bit constant produced by taking the lower half of the
// xxHash64 of the type metadata identifier. (See llvm/llvm-project@cff5bef.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ pub fn typeid_for_instance<'tcx>(
instance.args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1));
}

if options.contains(EncodeTyOptions::ERASE_SELF_TYPE) {
if !options.contains(EncodeTyOptions::USE_CONCRETE_SELF) {
if let Some(impl_id) = tcx.impl_of_method(instance.def_id())
&& let Some(trait_ref) = tcx.impl_trait_ref(impl_id)
{
Expand Down
24 changes: 24 additions & 0 deletions compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
"ios" => ios_deployment_target(arch, abi),
"tvos" => tvos_deployment_target(),
"watchos" => watchos_deployment_target(),
"visionos" => visionos_deployment_target(),
"macos" => macos_deployment_target(arch),
_ => unreachable!(),
};
Expand Down Expand Up @@ -202,6 +203,8 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> {
| object::macho::PLATFORM_TVOSSIMULATOR
| object::macho::PLATFORM_MACCATALYST => Some((16, 2)),
object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)),
// FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
11 | 12 => Some((1, 0)),
_ => None,
}
}
Expand All @@ -216,6 +219,9 @@ pub fn platform(target: &Target) -> Option<u32> {
("watchos", _) => object::macho::PLATFORM_WATCHOS,
("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR,
("tvos", _) => object::macho::PLATFORM_TVOS,
// FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
("visionos", "sim") => 12,
("visionos", _) => 11,
_ => return None,
})
}
Expand All @@ -240,6 +246,7 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> {
}
"watchos" => watchos_deployment_target(),
"tvos" => tvos_deployment_target(),
"visionos" => visionos_deployment_target(),
_ => return None,
};

Expand Down Expand Up @@ -290,6 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
|| sdkroot.contains("AppleTVSimulator.platform")
|| sdkroot.contains("WatchOS.platform")
|| sdkroot.contains("WatchSimulator.platform")
|| sdkroot.contains("XROS.platform")
{
env_remove.push("SDKROOT".into())
}
Expand All @@ -299,6 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
// although this is apparently ignored when using the linker at "/usr/bin/ld".
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into());
env_remove.push("TVOS_DEPLOYMENT_TARGET".into());
env_remove.push("XROS_DEPLOYMENT_TARGET".into());
env_remove.into()
} else {
// Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part
Expand Down Expand Up @@ -363,3 +372,18 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = watchos_deployment_target();
format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor)
}

fn visionos_deployment_target() -> (u32, u32) {
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0))
}

pub fn visionos_llvm_target(arch: Arch) -> String {
let (major, minor) = visionos_deployment_target();
format!("{}-apple-visionos{}.{}.0", arch.target_name(), major, minor)
}

pub fn visionos_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = visionos_deployment_target();
format!("{}-apple-visionos{}.{}.0-simulator", arch.target_name(), major, minor)
}
12 changes: 9 additions & 3 deletions compiler/rustc_target/src/spec/base/apple/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::spec::targets::{
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin,
x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim,
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_visionos_sim,
aarch64_apple_watchos_sim, i686_apple_darwin, x86_64_apple_darwin, x86_64_apple_ios,
x86_64_apple_tvos, x86_64_apple_watchos_sim,
};

#[test]
Expand All @@ -12,6 +13,7 @@ fn simulator_targets_set_abi() {
aarch64_apple_ios_sim::target(),
// Note: There is currently no ARM64 tvOS simulator target
aarch64_apple_watchos_sim::target(),
aarch64_apple_visionos_sim::target(),
];

for target in &all_sim_targets {
Expand All @@ -32,7 +34,11 @@ fn macos_link_environment_unmodified() {
// for the host.
assert_eq!(
target.link_env_remove,
crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET"],
crate::spec::cvs![
"IPHONEOS_DEPLOYMENT_TARGET",
"TVOS_DEPLOYMENT_TARGET",
"XROS_DEPLOYMENT_TARGET"
],
);
}
}
3 changes: 3 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,9 @@ supported_targets! {
("aarch64-apple-watchos", aarch64_apple_watchos),
("aarch64-apple-watchos-sim", aarch64_apple_watchos_sim),

("aarch64-apple-visionos", aarch64_apple_visionos),
("aarch64-apple-visionos-sim", aarch64_apple_visionos_sim),

("armebv7r-none-eabi", armebv7r_none_eabi),
("armebv7r-none-eabihf", armebv7r_none_eabihf),
("armv7r-none-eabi", armv7r_none_eabi),
Expand Down
27 changes: 27 additions & 0 deletions compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::spec::base::apple::{opts, visionos_llvm_target, Arch};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("visionos", arch);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

Target {
llvm_target: visionos_llvm_target(arch).into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Apple visionOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a16".into(),
max_atomic_width: Some(128),
frame_pointer: FramePointer::NonLeaf,
..base
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::spec::base::apple::{opts, visionos_sim_llvm_target, Arch};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64_sim;
let mut base = opts("visionos", arch);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

Target {
llvm_target: visionos_sim_llvm_target(arch).into(),
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Apple visionOS simulator".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(false),
},
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a16".into(),
max_atomic_width: Some(128),
frame_pointer: FramePointer::NonLeaf,
..base
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn target() -> Target {
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
features: "+vfp3,-d32,-fp16".into(),
features: "+vfp3d16".into(),
max_atomic_width: Some(64),
emit_debug_gdb_scripts: false,
// GCC defaults to 8 for arm-none here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn target() -> Target {
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
features: "+vfp3,-d32,-fp16".into(),
features: "+vfp3d16".into(),
max_atomic_width: Some(64),
emit_debug_gdb_scripts: false,
// GCC defaults to 8 for arm-none here.
Expand Down
13 changes: 6 additions & 7 deletions compiler/rustc_target/src/spec/targets/thumbv7em_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ pub fn target() -> Target {

options: TargetOptions {
abi: "eabihf".into(),
// `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the
// Cortex-M7 (vfp5)
// `-d32` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers
// available
// `-fp64` The Cortex-M4 only supports single precision floating point operations
// whereas in the Cortex-M7 double precision is optional
// vfp4 is the lowest common denominator between the Cortex-M4F (vfp4) and the
// Cortex-M7 (vfp5).
// Both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers
// available, and the Cortex-M4 only supports single-precision floating point operations
// whereas in the Cortex-M7 double-precision is optional.
//
// Reference:
// ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension
features: "+vfp4,-d32,-fp64".into(),
features: "+vfp4d16sp".into(),
max_atomic_width: Some(32),
..base::thumb::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ pub fn target() -> Target {
// processor, the Cortex-M33 Technical Reference Manual states that
// the FPU uses the FPv5 architecture, single-precision instructions
// and 16 D registers.
// These parameters map to the following LLVM features.
features: "+fp-armv8,-fp64,-d32".into(),
features: "+fp-armv8d16sp".into(),
max_atomic_width: Some(32),
..base::thumb::opts()
},
Expand Down
1 change: 1 addition & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn main() {
|| target_os == "ios"
|| target_os == "tvos"
|| target_os == "watchos"
|| target_os == "visionos"
|| target_os == "windows"
|| target_os == "fuchsia"
|| (target_vendor == "fortanix" && target_env == "sgx")
Expand Down
Loading

0 comments on commit 11853ec

Please sign in to comment.