Skip to content

Commit

Permalink
rustc_target: Rename some target options to avoid tautology
Browse files Browse the repository at this point in the history
`target.target_endian` -> `target.endian`
`target.target_c_int_width` -> `target.c_int_width`
`target.target_os` -> `target.os`
`target.target_env` -> `target.env`
`target.target_vendor` -> `target.vendor`
`target.target_family` -> `target.os_family`
`target.target_mcount` -> `target.mcount`
  • Loading branch information
petrochenkov committed Nov 8, 2020
1 parent bf66988 commit dc004d4
Show file tree
Hide file tree
Showing 114 changed files with 218 additions and 243 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

// The function name varies on platforms.
// See test/CodeGen/mcount.c in clang.
let mcount_name = CString::new(cx.sess().target.target_mcount.as_str().as_bytes()).unwrap();
let mcount_name = CString::new(cx.sess().target.mcount.as_str().as_bytes()).unwrap();

llvm::AddFunctionAttrStringValue(
llfn,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
// should use dllimport for functions.
if cx.use_dll_storage_attrs
&& tcx.is_dllimport_foreign_item(instance_def_id)
&& tcx.sess.target.target_env != "gnu"
&& tcx.sess.target.env != "gnu"
{
unsafe {
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ unsafe fn configure_llvm(sess: &Session) {
}
}

if sess.target.target_os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
add("-enable-emscripten-cxx-exceptions", false);
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn emit_direct_ptr_va_arg(
let next = bx.inbounds_gep(addr, &[full_direct_size]);
bx.store(next, va_list_addr, bx.tcx().data_layout.pointer_align.abi);

if size.bytes() < slot_size.bytes() && &*bx.tcx().sess.target.target_endian == "big" {
if size.bytes() < slot_size.bytes() && &*bx.tcx().sess.target.endian == "big" {
let adjusted_size = bx.cx().const_i32((slot_size.bytes() - size.bytes()) as i32);
let adjusted = bx.inbounds_gep(addr, &[adjusted_size]);
(bx.bitcast(adjusted, bx.cx().type_ptr_to(llty)), addr_align)
Expand Down Expand Up @@ -105,7 +105,7 @@ fn emit_aapcs_va_arg(
let mut end = bx.build_sibling_block("va_arg.end");
let zero = bx.const_i32(0);
let offset_align = Align::from_bytes(4).unwrap();
assert!(&*bx.tcx().sess.target.target_endian == "little");
assert!(&*bx.tcx().sess.target.endian == "little");

let gr_type = target_ty.is_any_ptr() || target_ty.is_integral();
let (reg_off, reg_top_index, slot_size) = if gr_type {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn get_linker(
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
let t = &sess.target;
if (flavor == LinkerFlavor::Msvc || flavor == LinkerFlavor::Lld(LldFlavor::Link))
&& t.target_vendor == "uwp"
&& t.vendor == "uwp"
{
if let Some(ref tool) = msvc_tool {
let original_path = tool.path();
Expand Down Expand Up @@ -1236,7 +1236,7 @@ fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
Some(CrtObjectsFallback::Musl) => sess.crt_static(Some(crate_type)),
Some(CrtObjectsFallback::Mingw) => {
sess.host == sess.target
&& sess.target.target_vendor != "uwp"
&& sess.target.vendor != "uwp"
&& detect_self_contained_mingw(&sess)
}
// FIXME: Figure out cases in which WASM needs to link with a native toolchain.
Expand Down Expand Up @@ -1510,7 +1510,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
let base_cmd = get_linker(sess, path, flavor, crt_objects_fallback);
// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
// to the linker args construction.
assert!(base_cmd.get_args().is_empty() || sess.target.target_vendor == "uwp");
assert!(base_cmd.get_args().is_empty() || sess.target.vendor == "uwp");
let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor, target_cpu);
let link_output_kind = link_output_kind(sess, crate_type);

Expand Down Expand Up @@ -2078,9 +2078,9 @@ fn are_upstream_rust_objects_already_included(sess: &Session) -> bool {

fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
let arch = &sess.target.arch;
let os = &sess.target.target_os;
let os = &sess.target.os;
let llvm_target = &sess.target.llvm_target;
if sess.target.target_vendor != "apple"
if sess.target.vendor != "apple"
|| !matches!(os.as_str(), "ios" | "tvos")
|| flavor != LinkerFlavor::Gcc
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<'a> Linker for GccLinker<'a> {
// any `#[link]` attributes in the `libc` crate, see #72782 for details.
// FIXME: Switch to using `#[link]` attributes in the `libc` crate
// similarly to other targets.
if self.sess.target.target_os == "vxworks"
if self.sess.target.os == "vxworks"
&& matches!(
output_kind,
LinkOutputKind::StaticNoPicExe
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
}

fn type_int(&self) -> Self::Type {
match &self.sess().target.target_c_int_width[..] {
match &self.sess().target.c_int_width[..] {
"16" => self.type_i16(),
"32" => self.type_i32(),
"64" => self.type_i64(),
width => bug!("Unsupported target_c_int_width: {}", width),
width => bug!("Unsupported c_int_width: {}", width),
}
}

Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2601,15 +2601,14 @@ where
};

let target = &cx.tcx().sess.target;
let target_env_gnu_like = matches!(&target.target_env[..], "gnu" | "musl");
let win_x64_gnu =
target.target_os == "windows" && target.arch == "x86_64" && target.target_env == "gnu";
let target_env_gnu_like = matches!(&target.env[..], "gnu" | "musl");
let win_x64_gnu = target.os == "windows" && target.arch == "x86_64" && target.env == "gnu";
let linux_s390x_gnu_like =
target.target_os == "linux" && target.arch == "s390x" && target_env_gnu_like;
target.os == "linux" && target.arch == "s390x" && target_env_gnu_like;
let linux_sparc64_gnu_like =
target.target_os == "linux" && target.arch == "sparc64" && target_env_gnu_like;
target.os == "linux" && target.arch == "sparc64" && target_env_gnu_like;
let linux_powerpc_gnu_like =
target.target_os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
target.os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
let rust_abi = matches!(sig.abi, RustIntrinsic | PlatformIntrinsic | Rust | RustCall);

// Handle safe Rust thin and fat pointers.
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,12 @@ pub const fn default_lib_output() -> CrateType {
}

pub fn default_configuration(sess: &Session) -> CrateConfig {
let end = &sess.target.target_endian;
let end = &sess.target.endian;
let arch = &sess.target.arch;
let wordsz = sess.target.pointer_width.to_string();
let os = &sess.target.target_os;
let env = &sess.target.target_env;
let vendor = &sess.target.target_vendor;
let os = &sess.target.os;
let env = &sess.target.env;
let vendor = &sess.target.vendor;
let min_atomic_width = sess.target.min_atomic_width();
let max_atomic_width = sess.target.max_atomic_width();
let atomic_cas = sess.target.atomic_cas;
Expand All @@ -752,7 +752,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
ret.reserve(6); // the minimum number of insertions
// Target bindings.
ret.insert((sym::target_os, Some(Symbol::intern(os))));
if let Some(ref fam) = sess.target.target_family {
if let Some(ref fam) = sess.target.os_family {
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
if fam == "windows" {
ret.insert((sym::windows, None));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
"nvptx64" => nvptx64::compute_abi_info(self),
"hexagon" => hexagon::compute_abi_info(self),
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
"wasm32" if cx.target_spec().target_os != "emscripten" => {
"wasm32" if cx.target_spec().os != "emscripten" => {
wasm32_bindgen_compat::compute_abi_info(self)
}
"wasm32" | "asmjs" => wasm32::compute_abi_info(cx, self),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/call/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ where
Ty: TyAndLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
{
let abi = if cx.target_spec().target_env == "musl" {
let abi = if cx.target_spec().env == "musl" {
ELFv2
} else {
match cx.data_layout().endian {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ impl TargetDataLayout {
Endian::Little => "little",
Endian::Big => "big",
};
if endian_str != target.target_endian {
if endian_str != target.endian {
return Err(format!(
"inconsistent target specification: \"data-layout\" claims \
architecture is {}-endian, while \"target-endian\" is `{}`",
endian_str, target.target_endian
endian_str, target.endian
));
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/aarch64_apple_darwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ pub fn target() -> Target {
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
arch: arch.to_string(),
options: TargetOptions { target_mcount: "\u{1}mcount".to_string(), ..base },
options: TargetOptions { mcount: "\u{1}mcount".to_string(), ..base },
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
arch: "aarch64".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}_mcount".to_string(),
mcount: "\u{1}_mcount".to_string(),
..base
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
arch: "aarch64".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}_mcount".to_string(),
mcount: "\u{1}_mcount".to_string(),
..base
},
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pub fn target() -> Target {
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
options: TargetOptions { target_mcount: "__mcount".to_string(), ..base },
options: TargetOptions { mcount: "__mcount".to_string(), ..base },
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/aarch64_unknown_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp

pub fn target() -> Target {
let opts = TargetOptions {
target_vendor: String::new(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
features: "+strict-align,+neon,+fp-armv8".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp

pub fn target() -> Target {
let opts = TargetOptions {
target_vendor: String::new(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
features: "+strict-align,-neon,-fp-armv8".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/android_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::spec::{LinkerFlavor, TargetOptions};

pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
base.target_os = "android".to_string();
base.os = "android".to_string();
// Many of the symbols defined in compiler-rt are also defined in libgcc.
// Android's linker doesn't like that by default.
base.pre_link_args
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_target/src/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ pub fn opts(os: &str) -> TargetOptions {
let version = macos_deployment_target();

TargetOptions {
target_os: os.to_string(),
target_vendor: "apple".to_string(),
os: os.to_string(),
vendor: "apple".to_string(),
// macOS has -dead_strip, which doesn't rely on function_sections
function_sections: false,
dynamic_linking: true,
executables: true,
target_family: Some("unix".to_string()),
os_family: Some("unix".to_string()),
is_like_osx: true,
dwarf_version: Some(2),
has_rpath: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+strict-align,+v6".to_string(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+strict-align,+v6,+vfp2,-d32".to_string(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn target() -> Target {
arch: "arm".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}mcount".to_string(),
mcount: "\u{1}mcount".to_string(),
..base
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn target() -> Target {
arch: "arm".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}mcount".to_string(),
mcount: "\u{1}mcount".to_string(),
..base
},
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
target_endian: "big".to_string(),
target_vendor: String::new(),
endian: "big".to_string(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".to_owned()),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
target_endian: "big".to_string(),
target_vendor: String::new(),
endian: "big".to_string(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".to_owned()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn target() -> Target {
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
mcount: "\u{1}__gnu_mcount_nc".to_string(),
has_thumb_interworking: true,
..base
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn target() -> Target {
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
mcount: "\u{1}__gnu_mcount_nc".to_string(),
has_thumb_interworking: true,
..base
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn target() -> Target {
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}mcount".to_string(),
mcount: "\u{1}mcount".to_string(),
has_thumb_interworking: true,
..base
},
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armv6_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
target_env: "gnueabihf".to_string(),
env: "gnueabihf".to_string(),
features: "+v6,+vfp2,-d32".to_string(),
max_atomic_width: Some(64),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armv6_unknown_netbsd_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
target_env: "eabihf".to_string(),
env: "eabihf".to_string(),
features: "+v6,+vfp2,-d32".to_string(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "__mcount".to_string(),
mcount: "__mcount".to_string(),
..base
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ pub fn target() -> Target {
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
options: TargetOptions { target_mcount: "\u{1}mcount".to_string(), ..base },
options: TargetOptions { mcount: "\u{1}mcount".to_string(), ..base },
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/armv7_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
target_env: "gnueabihf".to_string(),
env: "gnueabihf".to_string(),
features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(),
max_atomic_width: Some(64),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},
}
Expand Down
Loading

0 comments on commit dc004d4

Please sign in to comment.