Skip to content

Commit d98f47e

Browse files
committed
Rename target triple to target tuple in many places in the compiler
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
1 parent 02c8f8e commit d98f47e

File tree

27 files changed

+151
-152
lines changed

27 files changed

+151
-152
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data:
945945
}
946946

947947
fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
948-
let triple = cgcx.opts.target_triple.triple();
948+
let triple = cgcx.opts.target_triple.tuple();
949949
triple.contains("-ios")
950950
|| triple.contains("-darwin")
951951
|| triple.contains("-tvos")
@@ -954,7 +954,7 @@ fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
954954
}
955955

956956
fn target_is_aix(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
957-
cgcx.opts.target_triple.triple().contains("-aix")
957+
cgcx.opts.target_triple.tuple().contains("-aix")
958958
}
959959

960960
//FIXME use c string literals here too
@@ -1031,7 +1031,7 @@ unsafe fn embed_bitcode(
10311031
let is_aix = target_is_aix(cgcx);
10321032
let is_apple = target_is_apple(cgcx);
10331033
unsafe {
1034-
if is_apple || is_aix || cgcx.opts.target_triple.triple().starts_with("wasm") {
1034+
if is_apple || is_aix || cgcx.opts.target_triple.tuple().starts_with("wasm") {
10351035
// We don't need custom section flags, create LLVM globals.
10361036
let llconst = common::bytes_in_context(llcx, bitcode);
10371037
let llglobal = llvm::LLVMAddGlobal(

compiler/rustc_codegen_ssa/src/back/link.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ fn link_natively(
996996
{
997997
let is_vs_installed = windows_registry::find_vs_version().is_ok();
998998
let has_linker = windows_registry::find_tool(
999-
sess.opts.target_triple.triple(),
999+
sess.opts.target_triple.tuple(),
10001000
"link.exe",
10011001
)
10021002
.is_some();
@@ -1322,10 +1322,8 @@ fn link_sanitizer_runtime(
13221322
} else {
13231323
let default_sysroot =
13241324
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
1325-
let default_tlib = filesearch::make_target_lib_path(
1326-
&default_sysroot,
1327-
sess.opts.target_triple.triple(),
1328-
);
1325+
let default_tlib =
1326+
filesearch::make_target_lib_path(&default_sysroot, sess.opts.target_triple.tuple());
13291327
default_tlib
13301328
}
13311329
}

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) fn get_linker<'a>(
4747
self_contained: bool,
4848
target_cpu: &'a str,
4949
) -> Box<dyn Linker + 'a> {
50-
let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.triple(), "link.exe");
50+
let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.tuple(), "link.exe");
5151

5252
// If our linker looks like a batch script on Windows then to execute this
5353
// we'll need to spawn `cmd` explicitly. This is primarily done to handle

compiler/rustc_driver_impl/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use rustc_session::{EarlyDiagCtxt, Session, config, filesearch};
6161
use rustc_span::FileName;
6262
use rustc_span::source_map::FileLoader;
6363
use rustc_target::json::ToJson;
64-
use rustc_target::spec::{Target, TargetTriple};
64+
use rustc_target::spec::{Target, TargetTuple};
6565
use time::OffsetDateTime;
6666
use tracing::trace;
6767

@@ -738,7 +738,7 @@ fn print_crate_info(
738738
AllTargetSpecs => {
739739
let mut targets = BTreeMap::new();
740740
for name in rustc_target::spec::TARGETS {
741-
let triple = TargetTriple::from_triple(name);
741+
let triple = TargetTuple::from_tuple(name);
742742
let target = Target::expect_builtin(&triple);
743743
targets.insert(name, target.to_json());
744744
}
@@ -918,7 +918,7 @@ pub fn version_at_macro_invocation(
918918
safe_println!("binary: {binary}");
919919
safe_println!("commit-hash: {commit_hash}");
920920
safe_println!("commit-date: {commit_date}");
921-
safe_println!("host: {}", config::host_triple());
921+
safe_println!("host: {}", config::host_tuple());
922922
safe_println!("release: {release}");
923923

924924
let debug_flags = matches.opt_strs("Z");
@@ -1495,7 +1495,7 @@ fn report_ice(
14951495
}
14961496

14971497
let version = util::version_str!().unwrap_or("unknown_version");
1498-
let triple = config::host_triple();
1498+
let tuple = config::host_tuple();
14991499

15001500
static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
15011501

@@ -1505,7 +1505,7 @@ fn report_ice(
15051505
Ok(mut file) => {
15061506
dcx.emit_note(session_diagnostics::IcePath { path: path.clone() });
15071507
if FIRST_PANIC.swap(false, Ordering::SeqCst) {
1508-
let _ = write!(file, "\n\nrustc version: {version}\nplatform: {triple}");
1508+
let _ = write!(file, "\n\nrustc version: {version}\nplatform: {tuple}");
15091509
}
15101510
Some(file)
15111511
}
@@ -1518,12 +1518,12 @@ fn report_ice(
15181518
.map(PathBuf::from)
15191519
.map(|env_var| session_diagnostics::IcePathErrorEnv { env_var }),
15201520
});
1521-
dcx.emit_note(session_diagnostics::IceVersion { version, triple });
1521+
dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple });
15221522
None
15231523
}
15241524
}
15251525
} else {
1526-
dcx.emit_note(session_diagnostics::IceVersion { version, triple });
1526+
dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple });
15271527
None
15281528
};
15291529

compiler/rustc_errors/src/diagnostic_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::Span;
1111
use rustc_span::edition::Edition;
1212
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
1313
use rustc_target::abi::TargetDataLayoutErrors;
14-
use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple};
14+
use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTuple};
1515
use rustc_type_ir::{ClosureKind, FloatTy};
1616
use {rustc_ast as ast, rustc_hir as hir};
1717

@@ -89,7 +89,7 @@ into_diag_arg_using_display!(
8989
MacroRulesNormalizedIdent,
9090
ParseIntError,
9191
StackProtector,
92-
&TargetTriple,
92+
&TargetTuple,
9393
SplitDebuginfo,
9494
ExitStatus,
9595
ErrCode,

compiler/rustc_hir_typeck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ fn fatally_break_rust(tcx: TyCtxt<'_>, span: Span) -> ! {
493493
"we would appreciate a joke overview: \
494494
https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675",
495495
);
496-
diag.note(format!("rustc {} running on {}", tcx.sess.cfg_version, config::host_triple(),));
496+
diag.note(format!("rustc {} running on {}", tcx.sess.cfg_version, config::host_tuple(),));
497497
if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
498498
diag.note(format!("compiler flags: {}", flags.join(" ")));
499499
if excluded_cargo_defaults {

compiler/rustc_interface/src/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::sync;
1111
use rustc_metadata::{DylibError, load_symbol_from_dylib};
1212
use rustc_middle::ty::CurrentGcx;
1313
use rustc_parse::validate_attr;
14-
use rustc_session::config::{Cfg, OutFileName, OutputFilenames, OutputTypes, host_triple};
14+
use rustc_session::config::{Cfg, OutFileName, OutputFilenames, OutputTypes, host_tuple};
1515
use rustc_session::filesearch::sysroot_candidates;
1616
use rustc_session::lint::{self, BuiltinLintDiag, LintBuffer};
1717
use rustc_session::output::{CRATE_TYPES, categorize_crate_type};
@@ -310,7 +310,7 @@ fn get_codegen_sysroot(
310310
"cannot load the default codegen backend twice"
311311
);
312312

313-
let target = host_triple();
313+
let target = host_tuple();
314314
let sysroot_candidates = sysroot_candidates();
315315

316316
let sysroot = iter::once(sysroot)

compiler/rustc_metadata/src/creader.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_session::search_paths::PathKind;
3030
use rustc_span::edition::Edition;
3131
use rustc_span::symbol::{Symbol, sym};
3232
use rustc_span::{DUMMY_SP, Span};
33-
use rustc_target::spec::{PanicStrategy, Target, TargetTriple};
33+
use rustc_target::spec::{PanicStrategy, Target, TargetTuple};
3434
use tracing::{debug, info, trace};
3535

3636
use crate::errors;
@@ -506,7 +506,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
506506
locator.reset();
507507
locator.is_proc_macro = true;
508508
locator.target = &self.sess.host;
509-
locator.triple = TargetTriple::from_triple(config::host_triple());
509+
locator.tuple = TargetTuple::from_tuple(config::host_tuple());
510510
locator.filesearch = self.sess.host_filesearch(path_kind);
511511

512512
let Some(host_result) = self.load(locator)? else {
@@ -635,7 +635,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
635635
// FIXME: why is this condition necessary? It was adding in #33625 but I
636636
// don't know why and the original author doesn't remember ...
637637
let can_reuse_cratenum =
638-
locator.triple == self.sess.opts.target_triple || locator.is_proc_macro;
638+
locator.tuple == self.sess.opts.target_triple || locator.is_proc_macro;
639639
Ok(Some(if can_reuse_cratenum {
640640
let mut result = LoadResult::Loaded(library);
641641
for (cnum, data) in self.cstore.iter_crate_data() {

compiler/rustc_metadata/src/errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_errors::codes::*;
55
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
66
use rustc_macros::{Diagnostic, Subdiagnostic};
77
use rustc_span::{Span, Symbol, sym};
8-
use rustc_target::spec::{PanicStrategy, TargetTriple};
8+
use rustc_target::spec::{PanicStrategy, TargetTuple};
99

1010
use crate::fluent_generated as fluent;
1111
use crate::locator::CrateFlavor;
@@ -630,7 +630,7 @@ pub struct CannotFindCrate {
630630
pub current_crate: String,
631631
pub is_nightly_build: bool,
632632
pub profiler_runtime: Symbol,
633-
pub locator_triple: TargetTriple,
633+
pub locator_triple: TargetTuple,
634634
pub is_ui_testing: bool,
635635
}
636636

@@ -641,7 +641,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
641641
diag.arg("crate_name", self.crate_name);
642642
diag.arg("current_crate", self.current_crate);
643643
diag.arg("add_info", self.add_info);
644-
diag.arg("locator_triple", self.locator_triple.triple());
644+
diag.arg("locator_triple", self.locator_triple.tuple());
645645
diag.code(E0463);
646646
diag.span(self.span);
647647
if self.crate_name == sym::std || self.crate_name == sym::core {

compiler/rustc_metadata/src/locator.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ use rustc_session::search_paths::PathKind;
231231
use rustc_session::utils::CanonicalizedPath;
232232
use rustc_span::Span;
233233
use rustc_span::symbol::Symbol;
234-
use rustc_target::spec::{Target, TargetTriple};
234+
use rustc_target::spec::{Target, TargetTuple};
235235
use snap::read::FrameDecoder;
236236
use tracing::{debug, info};
237237

@@ -253,7 +253,7 @@ pub(crate) struct CrateLocator<'a> {
253253
pub hash: Option<Svh>,
254254
extra_filename: Option<&'a str>,
255255
pub target: &'a Target,
256-
pub triple: TargetTriple,
256+
pub tuple: TargetTuple,
257257
pub filesearch: FileSearch<'a>,
258258
pub is_proc_macro: bool,
259259

@@ -339,7 +339,7 @@ impl<'a> CrateLocator<'a> {
339339
hash,
340340
extra_filename,
341341
target: &sess.target,
342-
triple: sess.opts.target_triple.clone(),
342+
tuple: sess.opts.target_triple.clone(),
343343
filesearch: sess.target_filesearch(path_kind),
344344
is_proc_macro: false,
345345
crate_rejections: CrateRejections::default(),
@@ -675,8 +675,8 @@ impl<'a> CrateLocator<'a> {
675675
return None;
676676
}
677677

678-
if header.triple != self.triple {
679-
info!("Rejecting via crate triple: expected {} got {}", self.triple, header.triple);
678+
if header.triple != self.tuple {
679+
info!("Rejecting via crate triple: expected {} got {}", self.tuple, header.triple);
680680
self.crate_rejections.via_triple.push(CrateMismatch {
681681
path: libpath.to_path_buf(),
682682
got: header.triple.to_string(),
@@ -760,7 +760,7 @@ impl<'a> CrateLocator<'a> {
760760
CrateError::LocatorCombined(Box::new(CombinedLocatorError {
761761
crate_name: self.crate_name,
762762
root,
763-
triple: self.triple,
763+
triple: self.tuple,
764764
dll_prefix: self.target.dll_prefix.to_string(),
765765
dll_suffix: self.target.dll_suffix.to_string(),
766766
crate_rejections: self.crate_rejections,
@@ -923,7 +923,7 @@ struct CrateRejections {
923923
pub(crate) struct CombinedLocatorError {
924924
crate_name: Symbol,
925925
root: Option<CratePaths>,
926-
triple: TargetTriple,
926+
triple: TargetTuple,
927927
dll_prefix: String,
928928
dll_suffix: String,
929929
crate_rejections: CrateRejections,
@@ -1048,7 +1048,7 @@ impl CrateError {
10481048
dcx.emit_err(errors::NoCrateWithTriple {
10491049
span,
10501050
crate_name,
1051-
locator_triple: locator.triple.triple(),
1051+
locator_triple: locator.triple.tuple(),
10521052
add_info,
10531053
found_crates,
10541054
});

compiler/rustc_metadata/src/rmeta/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ impl MetadataBlob {
770770
root.stable_crate_id
771771
)?;
772772
writeln!(out, "proc_macro {:?}", root.proc_macro_data.is_some())?;
773-
writeln!(out, "triple {}", root.header.triple.triple())?;
773+
writeln!(out, "triple {}", root.header.triple.tuple())?;
774774
writeln!(out, "edition {}", root.edition)?;
775775
writeln!(out, "symbol_mangling_version {:?}", root.symbol_mangling_version)?;
776776
writeln!(

compiler/rustc_metadata/src/rmeta/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use rustc_span::hygiene::{ExpnIndex, MacroKind, SyntaxContextData};
3838
use rustc_span::symbol::{Ident, Symbol};
3939
use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
4040
use rustc_target::abi::{FieldIdx, VariantIdx};
41-
use rustc_target::spec::{PanicStrategy, TargetTriple};
41+
use rustc_target::spec::{PanicStrategy, TargetTuple};
4242
use table::TableBuilder;
4343
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
4444

@@ -213,7 +213,7 @@ pub(crate) struct ProcMacroData {
213213
/// If you do modify this struct, also bump the [`METADATA_VERSION`] constant.
214214
#[derive(MetadataEncodable, MetadataDecodable)]
215215
pub(crate) struct CrateHeader {
216-
pub(crate) triple: TargetTriple,
216+
pub(crate) triple: TargetTuple,
217217
pub(crate) hash: Svh,
218218
pub(crate) name: Symbol,
219219
/// Whether this is the header for a proc-macro crate.

compiler/rustc_session/src/config.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_span::{
2626
FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm, Symbol, sym,
2727
};
2828
use rustc_target::spec::{
29-
FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTriple,
29+
FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTuple,
3030
};
3131
use tracing::debug;
3232

@@ -1116,7 +1116,7 @@ bitflags::bitflags! {
11161116
}
11171117
}
11181118

1119-
pub fn host_triple() -> &'static str {
1119+
pub fn host_tuple() -> &'static str {
11201120
// Get the host triple out of the build environment. This ensures that our
11211121
// idea of the host triple is the same as for the set of libraries we've
11221122
// actually built. We can't just take LLVM's host triple because they
@@ -1158,7 +1158,7 @@ impl Default for Options {
11581158
output_types: OutputTypes(BTreeMap::new()),
11591159
search_paths: vec![],
11601160
maybe_sysroot: None,
1161-
target_triple: TargetTriple::from_triple(host_triple()),
1161+
target_triple: TargetTuple::from_tuple(host_tuple()),
11621162
test: false,
11631163
incremental: None,
11641164
untracked_state_hash: Default::default(),
@@ -1354,7 +1354,7 @@ pub fn build_target_config(early_dcx: &EarlyDiagCtxt, opts: &Options, sysroot: &
13541354
// rust-lang/compiler-team#695. Warn unconditionally on usage to
13551355
// raise awareness of the renaming. This code will be deleted in
13561356
// October 2024.
1357-
if opts.target_triple.triple() == "wasm32-wasi" {
1357+
if opts.target_triple.tuple() == "wasm32-wasi" {
13581358
early_dcx.early_warn(
13591359
"the `wasm32-wasi` target is being renamed to \
13601360
`wasm32-wasip1` and the `wasm32-wasi` target will be \
@@ -2030,16 +2030,16 @@ fn collect_print_requests(
20302030
prints
20312031
}
20322032

2033-
pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTriple {
2033+
pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTuple {
20342034
match matches.opt_str("target") {
20352035
Some(target) if target.ends_with(".json") => {
20362036
let path = Path::new(&target);
2037-
TargetTriple::from_path(path).unwrap_or_else(|_| {
2037+
TargetTuple::from_path(path).unwrap_or_else(|_| {
20382038
early_dcx.early_fatal(format!("target file {path:?} does not exist"))
20392039
})
20402040
}
2041-
Some(target) => TargetTriple::TargetTriple(target),
2042-
_ => TargetTriple::from_triple(host_triple()),
2041+
Some(target) => TargetTuple::TargetTuple(target),
2042+
_ => TargetTuple::from_tuple(host_tuple()),
20432043
}
20442044
}
20452045

@@ -3017,7 +3017,7 @@ pub(crate) mod dep_tracking {
30173017
use rustc_span::edition::Edition;
30183018
use rustc_target::spec::{
30193019
CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel,
3020-
RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTriple,
3020+
RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTuple,
30213021
TlsModel, WasmCAbi,
30223022
};
30233023

@@ -3102,7 +3102,7 @@ pub(crate) mod dep_tracking {
31023102
SanitizerSet,
31033103
CFGuard,
31043104
CFProtection,
3105-
TargetTriple,
3105+
TargetTuple,
31063106
Edition,
31073107
LinkerPluginLto,
31083108
ResolveDocLinks,

0 commit comments

Comments
 (0)