Skip to content

Commit 09dba77

Browse files
authored
Rollup merge of rust-lang#148760 - tamird:avoid-vendor-logic, r=madsmtm
rustc_target: hide TargetOptions::vendor Discussed in rust-lang#148531 (comment). r? `@bjorn3`
2 parents 32567a2 + c5f2eb6 commit 09dba77

File tree

18 files changed

+93
-69
lines changed

18 files changed

+93
-69
lines changed

compiler/rustc_codegen_cranelift/src/abi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ pub(crate) fn codegen_call_with_unwind_action(
916916
pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam {
917917
let param = AbiParam::new(ty);
918918
if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() {
919-
match (&tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) {
920-
(Arch::X86_64, _) | (Arch::AArch64, "apple") => match (ty, is_signed) {
919+
match (&tcx.sess.target.arch, tcx.sess.target.is_like_darwin) {
920+
(Arch::X86_64, _) | (Arch::AArch64, true) => match (ty, is_signed) {
921921
(types::I8 | types::I16, true) => param.sext(),
922922
(types::I8 | types::I16, false) => param.uext(),
923923
_ => param,

compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::prelude::*;
55

66
pub(crate) fn f16_to_f32(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
77
let (value, arg_ty) =
8-
if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 {
8+
if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
99
(
1010
fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value),
1111
lib_call_arg_param(fx.tcx, types::I16, false),
@@ -22,8 +22,7 @@ fn f16_to_f64(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
2222
}
2323

2424
pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
25-
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
26-
{
25+
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
2726
types::I16
2827
} else {
2928
types::F16
@@ -38,8 +37,7 @@ pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value
3837
}
3938

4039
fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
41-
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
42-
{
40+
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
4341
types::I16
4442
} else {
4543
types::F16

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ fn self_contained_components(
18191819
LinkSelfContainedDefault::InferredForMusl => sess.crt_static(Some(crate_type)),
18201820
LinkSelfContainedDefault::InferredForMingw => {
18211821
sess.host == sess.target
1822-
&& sess.target.vendor != "uwp"
1822+
&& sess.target.abi != "uwp"
18231823
&& detect_self_contained_mingw(sess, linker)
18241824
}
18251825
}

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub(crate) fn get_linker<'a>(
8383
// To comply with the Windows App Certification Kit,
8484
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
8585
let t = &sess.target;
86-
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.vendor == "uwp" {
86+
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.abi == "uwp" {
8787
if let Some(ref tool) = msvc_tool {
8888
let original_path = tool.path();
8989
if let Some(root_lib_path) = original_path.ancestors().nth(4) {
@@ -134,7 +134,7 @@ pub(crate) fn get_linker<'a>(
134134

135135
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
136136
// to the linker args construction.
137-
assert!(cmd.get_args().is_empty() || sess.target.vendor == "uwp");
137+
assert!(cmd.get_args().is_empty() || sess.target.abi == "uwp");
138138
match flavor {
139139
LinkerFlavor::Unix(Cc::No) if sess.target.os == "l4re" => {
140140
Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>

compiler/rustc_codegen_ssa/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub fn asm_const_to_str<'tcx>(
171171
}
172172

173173
pub fn is_mingw_gnu_toolchain(target: &Target) -> bool {
174-
target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
174+
target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
175175
}
176176

177177
pub fn i686_decorated_name(

compiler/rustc_metadata/src/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn walk_native_lib_search_dirs<R>(
6767
// FIXME: On AIX this also has the side-effect of making the list of library search paths
6868
// non-empty, which is needed or the linker may decide to record the LIBPATH env, if
6969
// defined, as the search path instead of appending the default search paths.
70-
if sess.target.vendor == "fortanix"
70+
if sess.target.abi == "fortanix"
7171
|| sess.target.os == "linux"
7272
|| sess.target.os == "fuchsia"
7373
|| sess.target.is_like_aix

compiler/rustc_session/src/config/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
298298
ins_none!(sym::target_thread_local);
299299
}
300300

301-
ins_str!(sym::target_vendor, &sess.target.vendor);
301+
ins_sym!(sym::target_vendor, sess.target.vendor_symbol());
302302

303303
// If the user wants a test runner, then add the test cfg.
304304
if sess.is_test_crate() {
@@ -456,7 +456,7 @@ impl CheckCfg {
456456
);
457457
values_target_os.insert(Symbol::intern(&target.options.os));
458458
values_target_pointer_width.insert(sym::integer(target.pointer_width));
459-
values_target_vendor.insert(Symbol::intern(&target.options.vendor));
459+
values_target_vendor.insert(target.vendor_symbol());
460460
}
461461
}
462462
}

compiler/rustc_target/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
1010
// tidy-alphabetical-start
1111
#![cfg_attr(bootstrap, feature(debug_closure_helpers))]
12+
#![expect(internal_features)]
1213
#![feature(iter_intersperse)]
14+
#![feature(rustc_attrs)]
1315
// tidy-alphabetical-end
1416

1517
use std::path::{Path, PathBuf};

compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::spec::{LinkerFlavor, Lld, TargetOptions, base};
22

33
pub(crate) fn opts() -> TargetOptions {
4-
let mut opts = base::windows_msvc::opts();
4+
let mut opts =
5+
TargetOptions { abi: "uwp".into(), vendor: "uwp".into(), ..base::windows_msvc::opts() };
56

6-
opts.abi = "uwp".into();
7-
opts.vendor = "uwp".into();
87
opts.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/APPCONTAINER", "mincore.lib"]);
98

109
opts

compiler/rustc_target/src/spec/json.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ impl ToJson for Target {
261261
($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }};
262262
($attr:ident, $json_name:expr) => {{
263263
let name = $json_name;
264+
#[allow(rustc::bad_opt_access)]
264265
if default.$attr != target.$attr {
265266
d.insert(name.into(), target.$attr.to_json());
266267
}

0 commit comments

Comments
 (0)