From e12de251f8513f660bbfbc1c71883383bd1037f4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 9 Jun 2023 15:23:08 -0700 Subject: [PATCH] Let environment variables override some default CPUs --- .../src/spec/targets/powerpc64le_unknown_linux_gnu.rs | 2 +- .../rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs | 2 +- .../rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs index 23913687a1fd..3253fbc84c74 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs @@ -2,7 +2,7 @@ pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); - base.cpu = "ppc64le".into(); + base.cpu = option_env!("RUSTC_TARGET_CPU_PPC64LE").unwrap_or("ppc64le").into(); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); base.max_atomic_width = Some(64); base.stack_probes = StackProbeType::Inline; diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs index 3efbb4648361..bcdaa5b8276d 100644 --- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs @@ -5,7 +5,7 @@ pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); base.endian = Endian::Big; // z10 is the oldest CPU supported by LLVM - base.cpu = "z10".into(); + base.cpu = option_env!("RUSTC_TARGET_CPU_S390X").unwrap_or("z10").into(); // FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector // ABI. Pass the -vector feature string to LLVM to respect this assumption. base.features = "-vector".into(); diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs index 59ec6c7f9d5f..b6f1be890b20 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs @@ -2,7 +2,7 @@ pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); - base.cpu = "x86-64".into(); + base.cpu = option_env!("RUSTC_TARGET_CPU_X86_64").unwrap_or("x86-64").into(); base.plt_by_default = false; base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); -- 2.47.0