Skip to content

Commit 105f4b8

Browse files
Rollup merge of #78875 - petrochenkov:cleantarg, r=Mark-Simulacrum
rustc_target: Further cleanup use of target options Follow up to #77729. Implements items 2 and 4 from the list in #77729 (comment). The first commit collapses uses of `target.options.foo` into `target.foo`. The second commit renames some target options to avoid tautology: `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` r? `@Mark-Simulacrum`
2 parents e15fee9 + 7f91175 commit 105f4b8

File tree

153 files changed

+453
-503
lines changed

Some content is hidden

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

153 files changed

+453
-503
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
796796

797797
fn visit_expr(&mut self, expr: &'a Expr) {
798798
match &expr.kind {
799-
ExprKind::LlvmInlineAsm(..) if !self.session.target.options.allow_asm => {
799+
ExprKind::LlvmInlineAsm(..) if !self.session.target.allow_asm => {
800800
struct_span_err!(
801801
self.session,
802802
expr.span,

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct TestCtxt<'a> {
3737
pub fn inject(sess: &Session, resolver: &mut dyn ResolverExpand, krate: &mut ast::Crate) {
3838
let span_diagnostic = sess.diagnostic();
3939
let panic_strategy = sess.panic_strategy();
40-
let platform_panic_strategy = sess.target.options.panic_strategy;
40+
let platform_panic_strategy = sess.target.panic_strategy;
4141

4242
// Check for #![reexport_test_harness_main = "some_name"] which gives the
4343
// main test function the name `some_name` without hygiene. This needs to be

compiler/rustc_codegen_cranelift/src/archive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
6363
sess,
6464
dst: output.to_path_buf(),
6565
lib_search_paths: archive_search_paths(sess),
66-
use_gnu_style_archive: sess.target.options.archive_format == "gnu",
66+
use_gnu_style_archive: sess.target.archive_format == "gnu",
6767
// FIXME fix builtin ranlib on macOS
68-
no_builtin_ranlib: sess.target.options.is_like_osx,
68+
no_builtin_ranlib: sess.target.is_like_osx,
6969

7070
src_archives,
7171
entries,

compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> DebugContext<'tcx> {
5050
// TODO: this should be configurable
5151
// macOS doesn't seem to support DWARF > 3
5252
// 5 version is required for md5 file hash
53-
version: if tcx.sess.target.options.is_like_osx {
53+
version: if tcx.sess.target.is_like_osx {
5454
3
5555
} else {
5656
// FIXME change to version 5 once the gdb and lldb shipping with the latest debian

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) {
320320
}
321321

322322
if cfg!(not(feature = "inline_asm"))
323-
|| tcx.sess.target.options.is_like_osx
324-
|| tcx.sess.target.options.is_like_windows
323+
|| tcx.sess.target.is_like_osx
324+
|| tcx.sess.target.is_like_windows
325325
{
326326
if global_asm.contains("__rust_probestack") {
327327
return;

compiler/rustc_codegen_cranelift/src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub(crate) fn write_metadata<P: WriteMetadata>(
101101
product.add_rustc_section(
102102
rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx),
103103
compressed,
104-
tcx.sess.target.options.is_like_osx,
104+
tcx.sess.target.is_like_osx,
105105
);
106106

107107
metadata

compiler/rustc_codegen_cranelift/src/toolchain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
9191
} else if stem == "link" || stem == "lld-link" {
9292
LinkerFlavor::Msvc
9393
} else if stem == "lld" || stem == "rust-lld" {
94-
LinkerFlavor::Lld(sess.target.options.lld_flavor)
94+
LinkerFlavor::Lld(sess.target.lld_flavor)
9595
} else {
9696
// fall back to the value in the target spec
9797
sess.target.linker_flavor
@@ -115,7 +115,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
115115

116116
if let Some(ret) = infer_from(
117117
sess,
118-
sess.target.options.linker.clone().map(PathBuf::from),
118+
sess.target.linker.clone().map(PathBuf::from),
119119
Some(sess.target.linker_flavor),
120120
) {
121121
return ret;

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen(
5757
let name = format!("__rust_{}", method.name);
5858
let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);
5959

60-
if tcx.sess.target.options.default_hidden_visibility {
60+
if tcx.sess.target.default_hidden_visibility {
6161
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
6262
}
6363
if tcx.sess.must_emit_unwind_tables() {
@@ -98,7 +98,7 @@ pub(crate) unsafe fn codegen(
9898
// -> ! DIFlagNoReturn
9999
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
100100

101-
if tcx.sess.target.options.default_hidden_visibility {
101+
if tcx.sess.target.default_hidden_visibility {
102102
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
103103
}
104104
if tcx.sess.must_emit_unwind_tables() {

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
9090

9191
// The function name varies on platforms.
9292
// See test/CodeGen/mcount.c in clang.
93-
let mcount_name =
94-
CString::new(cx.sess().target.options.target_mcount.as_str().as_bytes()).unwrap();
93+
let mcount_name = CString::new(cx.sess().target.mcount.as_str().as_bytes()).unwrap();
9594

9695
llvm::AddFunctionAttrStringValue(
9796
llfn,
@@ -105,7 +104,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
105104
fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
106105
// Only use stack probes if the target specification indicates that we
107106
// should be using stack probes
108-
if !cx.sess().target.options.stack_probes {
107+
if !cx.sess().target.stack_probes {
109108
return;
110109
}
111110

@@ -174,7 +173,6 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
174173
.split(',')
175174
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
176175
sess.target
177-
.options
178176
.features
179177
.split(',')
180178
.chain(cmdline)

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
206206
}
207207

208208
fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
209-
let kind = &*self.config.sess.target.options.archive_format;
209+
let kind = &*self.config.sess.target.archive_format;
210210
kind.parse().map_err(|_| kind)
211211
}
212212

0 commit comments

Comments
 (0)