From a26450cf81d67d68d3c6157579f8d968349129e7 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:02:32 +0200 Subject: [PATCH] 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. --- .../rustc_codegen_cranelift/src/global_asm.rs | 4 +- compiler/rustc_codegen_gcc/src/consts.rs | 2 +- compiler/rustc_codegen_llvm/src/back/write.rs | 6 +- compiler/rustc_codegen_ssa/src/back/link.rs | 8 +- compiler/rustc_codegen_ssa/src/back/linker.rs | 2 +- compiler/rustc_driver_impl/src/lib.rs | 14 +- compiler/rustc_errors/src/diagnostic_impls.rs | 4 +- compiler/rustc_hir_typeck/src/lib.rs | 2 +- compiler/rustc_interface/src/util.rs | 4 +- compiler/rustc_metadata/src/creader.rs | 6 +- compiler/rustc_metadata/src/errors.rs | 6 +- compiler/rustc_metadata/src/locator.rs | 16 +- compiler/rustc_metadata/src/rmeta/decoder.rs | 2 +- compiler/rustc_metadata/src/rmeta/mod.rs | 4 +- compiler/rustc_session/src/config.rs | 20 +-- compiler/rustc_session/src/config/cfg.rs | 4 +- compiler/rustc_session/src/errors.rs | 8 +- compiler/rustc_session/src/filesearch.rs | 4 +- compiler/rustc_session/src/options.rs | 4 +- compiler/rustc_session/src/search_paths.rs | 6 +- compiler/rustc_session/src/session.rs | 12 +- compiler/rustc_target/src/spec/mod.rs | 145 +++++++++--------- src/doc/rustdoc/src/command-line-arguments.md | 2 +- src/librustdoc/config.rs | 4 +- src/librustdoc/doctest.rs | 12 +- src/tools/compiletest/src/common.rs | 8 +- src/tools/compiletest/src/runtest.rs | 2 +- src/tools/miri/src/machine.rs | 2 +- src/tools/opt-dist/src/environment.rs | 8 +- src/tools/opt-dist/src/exec.rs | 4 +- src/tools/opt-dist/src/main.rs | 6 +- src/tools/opt-dist/src/tests.rs | 4 +- 32 files changed, 167 insertions(+), 168 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/global_asm.rs b/compiler/rustc_codegen_cranelift/src/global_asm.rs index 0c99a5ce12f..6f90d17920d 100644 --- a/compiler/rustc_codegen_cranelift/src/global_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/global_asm.rs @@ -118,8 +118,8 @@ pub(crate) fn new(tcx: TyCtxt<'_>) -> Self { GlobalAsmConfig { assembler: crate::toolchain::get_toolchain_binary(tcx.sess, "as"), target: match &tcx.sess.opts.target_triple { - rustc_target::spec::TargetTriple::TargetTriple(triple) => triple.clone(), - rustc_target::spec::TargetTriple::TargetJson { path_for_rustdoc, .. } => { + rustc_target::spec::TargetTuple::TargetTuple(triple) => triple.clone(), + rustc_target::spec::TargetTuple::TargetJson { path_for_rustdoc, .. } => { path_for_rustdoc.to_str().unwrap().to_owned() } }, diff --git a/compiler/rustc_codegen_gcc/src/consts.rs b/compiler/rustc_codegen_gcc/src/consts.rs index 3029b934179..660badb6a50 100644 --- a/compiler/rustc_codegen_gcc/src/consts.rs +++ b/compiler/rustc_codegen_gcc/src/consts.rs @@ -146,7 +146,7 @@ fn codegen_static(&self, def_id: DefId) { // Wasm statics with custom link sections get special treatment as they // go into custom sections of the wasm executable. - if self.tcx.sess.opts.target_triple.triple().starts_with("wasm32") { + if self.tcx.sess.opts.target_triple.tuple().starts_with("wasm32") { if let Some(_section) = attrs.link_section { unimplemented!(); } diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 01e2c308ca4..647e9e13fbc 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -946,7 +946,7 @@ fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data: } fn target_is_apple(cgcx: &CodegenContext) -> bool { - let triple = cgcx.opts.target_triple.triple(); + let triple = cgcx.opts.target_triple.tuple(); triple.contains("-ios") || triple.contains("-darwin") || triple.contains("-tvos") @@ -955,7 +955,7 @@ fn target_is_apple(cgcx: &CodegenContext) -> bool { } fn target_is_aix(cgcx: &CodegenContext) -> bool { - cgcx.opts.target_triple.triple().contains("-aix") + cgcx.opts.target_triple.tuple().contains("-aix") } pub(crate) fn bitcode_section_name(cgcx: &CodegenContext) -> &'static CStr { @@ -1031,7 +1031,7 @@ unsafe fn embed_bitcode( let is_aix = target_is_aix(cgcx); let is_apple = target_is_apple(cgcx); unsafe { - if is_apple || is_aix || cgcx.opts.target_triple.triple().starts_with("wasm") { + if is_apple || is_aix || cgcx.opts.target_triple.tuple().starts_with("wasm") { // We don't need custom section flags, create LLVM globals. let llconst = common::bytes_in_context(llcx, bitcode); let llglobal = llvm::LLVMAddGlobal( diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index b01a62b394b..20920d16f3c 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -997,7 +997,7 @@ fn is_illegal_instruction(_status: &ExitStatus) -> bool { { let is_vs_installed = windows_registry::find_vs_version().is_ok(); let has_linker = windows_registry::find_tool( - sess.opts.target_triple.triple(), + sess.opts.target_triple.tuple(), "link.exe", ) .is_some(); @@ -1323,10 +1323,8 @@ fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf { } else { let default_sysroot = filesearch::get_or_default_sysroot().expect("Failed finding sysroot"); - let default_tlib = filesearch::make_target_lib_path( - &default_sysroot, - sess.opts.target_triple.triple(), - ); + let default_tlib = + filesearch::make_target_lib_path(&default_sysroot, sess.opts.target_triple.tuple()); default_tlib } } diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index c4bb82d0dd7..3b4429535d4 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -47,7 +47,7 @@ pub(crate) fn get_linker<'a>( self_contained: bool, target_cpu: &'a str, ) -> Box { - let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.triple(), "link.exe"); + let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.tuple(), "link.exe"); // If our linker looks like a batch script on Windows then to execute this // we'll need to spawn `cmd` explicitly. This is primarily done to handle diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 92b622fccf2..97210d9a662 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -62,7 +62,7 @@ use rustc_span::FileName; use rustc_span::source_map::FileLoader; use rustc_target::json::ToJson; -use rustc_target::spec::{Target, TargetTriple}; +use rustc_target::spec::{Target, TargetTuple}; use time::OffsetDateTime; use tracing::trace; @@ -739,7 +739,7 @@ fn print_crate_info( AllTargetSpecs => { let mut targets = BTreeMap::new(); for name in rustc_target::spec::TARGETS { - let triple = TargetTriple::from_triple(name); + let triple = TargetTuple::from_tuple(name); let target = Target::expect_builtin(&triple); targets.insert(name, target.to_json()); } @@ -918,7 +918,7 @@ pub fn version_at_macro_invocation( safe_println!("binary: {binary}"); safe_println!("commit-hash: {commit_hash}"); safe_println!("commit-date: {commit_date}"); - safe_println!("host: {}", config::host_triple()); + safe_println!("host: {}", config::host_tuple()); safe_println!("release: {release}"); let debug_flags = matches.opt_strs("Z"); @@ -1495,7 +1495,7 @@ fn report_ice( } let version = util::version_str!().unwrap_or("unknown_version"); - let triple = config::host_triple(); + let tuple = config::host_tuple(); static FIRST_PANIC: AtomicBool = AtomicBool::new(true); @@ -1505,7 +1505,7 @@ fn report_ice( Ok(mut file) => { dcx.emit_note(session_diagnostics::IcePath { path: path.clone() }); if FIRST_PANIC.swap(false, Ordering::SeqCst) { - let _ = write!(file, "\n\nrustc version: {version}\nplatform: {triple}"); + let _ = write!(file, "\n\nrustc version: {version}\nplatform: {tuple}"); } Some(file) } @@ -1518,12 +1518,12 @@ fn report_ice( .map(PathBuf::from) .map(|env_var| session_diagnostics::IcePathErrorEnv { env_var }), }); - dcx.emit_note(session_diagnostics::IceVersion { version, triple }); + dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); None } } } else { - dcx.emit_note(session_diagnostics::IceVersion { version, triple }); + dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); None }; diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 09a608dda7b..798668b8bc1 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -11,7 +11,7 @@ use rustc_span::Span; use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; -use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; +use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTuple}; use rustc_type_ir::{ClosureKind, FloatTy}; use {rustc_ast as ast, rustc_hir as hir}; @@ -89,7 +89,7 @@ fn into_diag_arg(self) -> DiagArgValue { MacroRulesNormalizedIdent, ParseIntError, StackProtector, - &TargetTriple, + &TargetTuple, SplitDebuginfo, ExitStatus, ErrCode, diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 85e11ff6745..d8b63eef577 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -493,7 +493,7 @@ fn fatally_break_rust(tcx: TyCtxt<'_>, span: Span) -> ! { "we would appreciate a joke overview: \ https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675", ); - diag.note(format!("rustc {} running on {}", tcx.sess.cfg_version, config::host_triple(),)); + diag.note(format!("rustc {} running on {}", tcx.sess.cfg_version, config::host_tuple(),)); if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() { diag.note(format!("compiler flags: {}", flags.join(" "))); if excluded_cargo_defaults { diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 71e8accf5a3..b5bddc4b21a 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -11,7 +11,7 @@ use rustc_metadata::{DylibError, load_symbol_from_dylib}; use rustc_middle::ty::CurrentGcx; use rustc_parse::validate_attr; -use rustc_session::config::{Cfg, OutFileName, OutputFilenames, OutputTypes, host_triple}; +use rustc_session::config::{Cfg, OutFileName, OutputFilenames, OutputTypes, host_tuple}; use rustc_session::filesearch::sysroot_candidates; use rustc_session::lint::{self, BuiltinLintDiag, LintBuffer}; use rustc_session::output::{CRATE_TYPES, categorize_crate_type}; @@ -310,7 +310,7 @@ fn get_codegen_sysroot( "cannot load the default codegen backend twice" ); - let target = host_triple(); + let target = host_tuple(); let sysroot_candidates = sysroot_candidates(); let sysroot = iter::once(sysroot) diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index d2be6ae8d69..e525d94a0c1 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -30,7 +30,7 @@ use rustc_span::edition::Edition; use rustc_span::symbol::{Ident, Symbol, sym}; use rustc_span::{DUMMY_SP, Span}; -use rustc_target::spec::{PanicStrategy, Target, TargetTriple}; +use rustc_target::spec::{PanicStrategy, Target, TargetTuple}; use tracing::{debug, info, trace}; use crate::errors; @@ -506,7 +506,7 @@ fn load_proc_macro<'b>( locator.reset(); locator.is_proc_macro = true; locator.target = &self.sess.host; - locator.triple = TargetTriple::from_triple(config::host_triple()); + locator.tuple = TargetTuple::from_tuple(config::host_tuple()); locator.filesearch = self.sess.host_filesearch(path_kind); let Some(host_result) = self.load(locator)? else { @@ -635,7 +635,7 @@ fn load(&self, locator: &mut CrateLocator<'_>) -> Result, Cra // FIXME: why is this condition necessary? It was adding in #33625 but I // don't know why and the original author doesn't remember ... let can_reuse_cratenum = - locator.triple == self.sess.opts.target_triple || locator.is_proc_macro; + locator.tuple == self.sess.opts.target_triple || locator.is_proc_macro; Ok(Some(if can_reuse_cratenum { let mut result = LoadResult::Loaded(library); for (cnum, data) in self.cstore.iter_crate_data() { diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 6587125ec67..16684ae6f26 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -5,7 +5,7 @@ use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol, sym}; -use rustc_target::spec::{PanicStrategy, TargetTriple}; +use rustc_target::spec::{PanicStrategy, TargetTuple}; use crate::fluent_generated as fluent; use crate::locator::CrateFlavor; @@ -630,7 +630,7 @@ pub struct CannotFindCrate { pub current_crate: String, pub is_nightly_build: bool, pub profiler_runtime: Symbol, - pub locator_triple: TargetTriple, + pub locator_triple: TargetTuple, pub is_ui_testing: bool, } @@ -641,7 +641,7 @@ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { diag.arg("crate_name", self.crate_name); diag.arg("current_crate", self.current_crate); diag.arg("add_info", self.add_info); - diag.arg("locator_triple", self.locator_triple.triple()); + diag.arg("locator_triple", self.locator_triple.tuple()); diag.code(E0463); diag.span(self.span); if self.crate_name == sym::std || self.crate_name == sym::core { diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index f924ed48b6f..ddd97fc66f6 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -231,7 +231,7 @@ use rustc_session::utils::CanonicalizedPath; use rustc_span::Span; use rustc_span::symbol::Symbol; -use rustc_target::spec::{Target, TargetTriple}; +use rustc_target::spec::{Target, TargetTuple}; use tracing::{debug, info}; use crate::creader::{Library, MetadataLoader}; @@ -252,7 +252,7 @@ pub(crate) struct CrateLocator<'a> { pub hash: Option, extra_filename: Option<&'a str>, pub target: &'a Target, - pub triple: TargetTriple, + pub tuple: TargetTuple, pub filesearch: FileSearch<'a>, pub is_proc_macro: bool, @@ -338,7 +338,7 @@ pub(crate) fn new( hash, extra_filename, target: &sess.target, - triple: sess.opts.target_triple.clone(), + tuple: sess.opts.target_triple.clone(), filesearch: sess.target_filesearch(path_kind), is_proc_macro: false, crate_rejections: CrateRejections::default(), @@ -677,8 +677,8 @@ fn crate_matches(&mut self, metadata: &MetadataBlob, libpath: &Path) -> Option) -> CrateError { CrateError::LocatorCombined(Box::new(CombinedLocatorError { crate_name: self.crate_name, root, - triple: self.triple, + triple: self.tuple, dll_prefix: self.target.dll_prefix.to_string(), dll_suffix: self.target.dll_suffix.to_string(), crate_rejections: self.crate_rejections, @@ -909,7 +909,7 @@ struct CrateRejections { pub(crate) struct CombinedLocatorError { crate_name: Symbol, root: Option, - triple: TargetTriple, + triple: TargetTuple, dll_prefix: String, dll_suffix: String, crate_rejections: CrateRejections, @@ -1034,7 +1034,7 @@ pub(crate) fn report(self, sess: &Session, span: Span, missing_core: bool) { dcx.emit_err(errors::NoCrateWithTriple { span, crate_name, - locator_triple: locator.triple.triple(), + locator_triple: locator.triple.tuple(), add_info, found_crates, }); diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index ebfd3c09fc1..87357b74c41 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -770,7 +770,7 @@ pub(crate) fn list_crate_metadata( root.stable_crate_id )?; writeln!(out, "proc_macro {:?}", root.proc_macro_data.is_some())?; - writeln!(out, "triple {}", root.header.triple.triple())?; + writeln!(out, "triple {}", root.header.triple.tuple())?; writeln!(out, "edition {}", root.edition)?; writeln!(out, "symbol_mangling_version {:?}", root.symbol_mangling_version)?; writeln!( diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index ab878760c00..949e26f5f60 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -38,7 +38,7 @@ use rustc_span::hygiene::{ExpnIndex, MacroKind, SyntaxContextData}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span}; -use rustc_target::spec::{PanicStrategy, TargetTriple}; +use rustc_target::spec::{PanicStrategy, TargetTuple}; use table::TableBuilder; use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; @@ -213,7 +213,7 @@ pub(crate) struct ProcMacroData { /// If you do modify this struct, also bump the [`METADATA_VERSION`] constant. #[derive(MetadataEncodable, MetadataDecodable)] pub(crate) struct CrateHeader { - pub(crate) triple: TargetTriple, + pub(crate) triple: TargetTuple, pub(crate) hash: Svh, pub(crate) name: Symbol, /// Whether this is the header for a proc-macro crate. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 5ee3b4015eb..3ac6e7423ac 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -26,7 +26,7 @@ FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm, Symbol, sym, }; use rustc_target::spec::{ - FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTriple, + FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTuple, }; use tracing::debug; @@ -1116,7 +1116,7 @@ pub struct RemapPathScopeComponents: u8 { } } -pub fn host_triple() -> &'static str { +pub fn host_tuple() -> &'static str { // Get the host triple out of the build environment. This ensures that our // idea of the host triple is the same as for the set of libraries we've // actually built. We can't just take LLVM's host triple because they @@ -1158,7 +1158,7 @@ fn default() -> Options { output_types: OutputTypes(BTreeMap::new()), search_paths: vec![], maybe_sysroot: None, - target_triple: TargetTriple::from_triple(host_triple()), + target_triple: TargetTuple::from_tuple(host_tuple()), test: false, incremental: None, untracked_state_hash: Default::default(), @@ -1354,7 +1354,7 @@ pub fn build_target_config(early_dcx: &EarlyDiagCtxt, opts: &Options, sysroot: & // rust-lang/compiler-team#695. Warn unconditionally on usage to // raise awareness of the renaming. This code will be deleted in // October 2024. - if opts.target_triple.triple() == "wasm32-wasi" { + if opts.target_triple.tuple() == "wasm32-wasi" { early_dcx.early_warn( "the `wasm32-wasi` target is being renamed to \ `wasm32-wasip1` and the `wasm32-wasi` target will be \ @@ -2030,16 +2030,16 @@ fn collect_print_requests( prints } -pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTriple { +pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTuple { match matches.opt_str("target") { Some(target) if target.ends_with(".json") => { let path = Path::new(&target); - TargetTriple::from_path(path).unwrap_or_else(|_| { + TargetTuple::from_path(path).unwrap_or_else(|_| { early_dcx.early_fatal(format!("target file {path:?} does not exist")) }) } - Some(target) => TargetTriple::TargetTriple(target), - _ => TargetTriple::from_triple(host_triple()), + Some(target) => TargetTuple::TargetTuple(target), + _ => TargetTuple::from_tuple(host_tuple()), } } @@ -3005,7 +3005,7 @@ pub(crate) mod dep_tracking { use rustc_span::edition::Edition; use rustc_target::spec::{ CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, - RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTriple, + RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTuple, TlsModel, WasmCAbi, }; @@ -3090,7 +3090,7 @@ fn hash( SanitizerSet, CFGuard, CFProtection, - TargetTriple, + TargetTuple, Edition, LinkerPluginLto, ResolveDocLinks, diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 31ef2bda4f1..347d298bacc 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -29,7 +29,7 @@ use rustc_lint_defs::BuiltinLintDiag; use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS; use rustc_span::symbol::{Symbol, sym}; -use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, TARGETS, Target, TargetTriple}; +use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, TARGETS, Target, TargetTuple}; use crate::Session; use crate::config::{CrateType, FmtDebug}; @@ -417,7 +417,7 @@ macro_rules! ins { for target in TARGETS .iter() - .map(|target| Target::expect_builtin(&TargetTriple::from_triple(target))) + .map(|target| Target::expect_builtin(&TargetTuple::from_tuple(target))) .chain(iter::once(current_target.clone())) { values_target_abi.insert(Symbol::intern(&target.options.abi)); diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 20e8fb38b88..33f84f10447 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -9,7 +9,7 @@ }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; -use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple}; +use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTuple}; use crate::config::CrateType; use crate::parse::ParseSess; @@ -179,13 +179,13 @@ pub(crate) struct EmbedSourceInsufficientDwarfVersion { #[diag(session_target_stack_protector_not_supported)] pub(crate) struct StackProtectorNotSupportedForTarget<'a> { pub(crate) stack_protector: StackProtector, - pub(crate) target_triple: &'a TargetTriple, + pub(crate) target_triple: &'a TargetTuple, } #[derive(Diagnostic)] #[diag(session_target_small_data_threshold_not_supported)] pub(crate) struct SmallDataThresholdNotSupportedForTarget<'a> { - pub(crate) target_triple: &'a TargetTriple, + pub(crate) target_triple: &'a TargetTuple, } #[derive(Diagnostic)] @@ -383,7 +383,7 @@ struct BinaryFloatLiteralNotSupported { #[diag(session_unsupported_crate_type_for_target)] pub(crate) struct UnsupportedCrateTypeForTarget<'a> { pub(crate) crate_type: CrateType, - pub(crate) target_triple: &'a TargetTriple, + pub(crate) target_triple: &'a TargetTuple, } pub fn report_lit_error( diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index b3e3381d986..213a94ab880 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -152,7 +152,7 @@ fn current_dll_path() -> Result { } pub fn sysroot_candidates() -> SmallVec<[PathBuf; 2]> { - let target = crate::config::host_triple(); + let target = crate::config::host_tuple(); let mut sysroot_candidates: SmallVec<[PathBuf; 2]> = smallvec![get_or_default_sysroot().expect("Failed finding sysroot")]; let path = current_dll_path().and_then(|s| try_canonicalize(s).map_err(|e| e.to_string())); @@ -218,7 +218,7 @@ fn default_from_rustc_driver_dll() -> Result { ))?; // if `dir` points target's dir, move up to the sysroot - let mut sysroot_dir = if dir.ends_with(crate::config::host_triple()) { + let mut sysroot_dir = if dir.ends_with(crate::config::host_tuple()) { dir.parent() // chop off `$target` .and_then(|p| p.parent()) // chop off `rustlib` .and_then(|p| p.parent()) // chop off `lib` diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 2b158627751..5a2a6ab0031 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -14,7 +14,7 @@ use rustc_target::spec::{ CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, - TargetTriple, TlsModel, WasmCAbi, + TargetTuple, TlsModel, WasmCAbi, }; use crate::config::*; @@ -146,7 +146,7 @@ pub struct Options { libs: Vec [TRACKED], maybe_sysroot: Option [UNTRACKED], - target_triple: TargetTriple [TRACKED], + target_triple: TargetTuple [TRACKED], /// Effective logical environment used by `env!`/`option_env!` macros logical_env: FxIndexMap [TRACKED], diff --git a/compiler/rustc_session/src/search_paths.rs b/compiler/rustc_session/src/search_paths.rs index ac0d8661115..c148b09c718 100644 --- a/compiler/rustc_session/src/search_paths.rs +++ b/compiler/rustc_session/src/search_paths.rs @@ -1,7 +1,7 @@ use std::path::{Path, PathBuf}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use rustc_target::spec::TargetTriple; +use rustc_target::spec::TargetTuple; use crate::EarlyDiagCtxt; use crate::filesearch::make_target_lib_path; @@ -52,7 +52,7 @@ pub fn matches(&self, kind: PathKind) -> bool { impl SearchPath { pub fn from_cli_opt( sysroot: &Path, - triple: &TargetTriple, + triple: &TargetTuple, early_dcx: &EarlyDiagCtxt, path: &str, is_unstable_enabled: bool, @@ -80,7 +80,7 @@ pub fn from_cli_opt( ); } - make_target_lib_path(sysroot, triple.triple()).join("builtin").join(stripped) + make_target_lib_path(sysroot, triple.tuple()).join("builtin").join(stripped) } None => PathBuf::from(path), }; diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 45434534c75..470e372ee48 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -32,7 +32,7 @@ use rustc_target::spec::{ CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SmallDataThresholdSupport, SplitDebuginfo, StackProtector, SymbolVisibility, Target, - TargetTriple, TlsModel, + TargetTuple, TlsModel, }; use crate::code_stats::CodeStats; @@ -451,12 +451,12 @@ pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { /// directories are also returned, for example if `--sysroot` is used but tools are missing /// (#125246): we also add the bin directories to the sysroot where rustc is located. pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec { - let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_triple()); + let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_tuple()); let fallback_sysroot_paths = filesearch::sysroot_candidates() .into_iter() // Ignore sysroot candidate if it was the same as the sysroot path we just used. .filter(|sysroot| *sysroot != self.sysroot) - .map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_triple())); + .map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_tuple())); let search_paths = std::iter::once(bin_path).chain(fallback_sysroot_paths); if self_contained { @@ -1023,7 +1023,7 @@ pub fn build_session( let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow); let can_emit_warnings = !(warnings_allow || cap_lints_allow); - let host_triple = TargetTriple::from_triple(config::host_triple()); + let host_triple = TargetTuple::from_tuple(config::host_tuple()); let (host, target_warnings) = Target::search(&host_triple, &sysroot).unwrap_or_else(|e| { early_dcx.early_fatal(format!("Error loading host specification: {e}")) }); @@ -1074,8 +1074,8 @@ pub fn build_session( let mut psess = ParseSess::with_dcx(dcx, source_map); psess.assume_incomplete_release = sopts.unstable_opts.assume_incomplete_release; - let host_triple = config::host_triple(); - let target_triple = sopts.target_triple.triple(); + let host_triple = config::host_tuple(); + let target_triple = sopts.target_triple.tuple(); let host_tlib_path = Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, host_triple)); let target_tlib_path = if host_triple == target_triple { // Use the same `SearchPath` if host and target triple are identical to avoid unnecessary diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d518ed60469..06408e0b210 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1,21 +1,21 @@ //! [Flexible target specification.](https://github.com/rust-lang/rfcs/pull/131) //! //! Rust targets a wide variety of usecases, and in the interest of flexibility, -//! allows new target triples to be defined in configuration files. Most users +//! allows new target tuples to be defined in configuration files. Most users //! will not need to care about these, but this is invaluable when porting Rust //! to a new platform, and allows for an unprecedented level of control over how //! the compiler works. //! //! # Using custom targets //! -//! A target triple, as passed via `rustc --target=TRIPLE`, will first be +//! A target tuple, as passed via `rustc --target=TUPLE`, will first be //! compared against the list of built-in targets. This is to ease distributing //! rustc (no need for configuration files) and also to hold these built-in -//! targets as immutable and sacred. If `TRIPLE` is not one of the built-in -//! targets, rustc will check if a file named `TRIPLE` exists. If it does, it +//! targets as immutable and sacred. If `TUPLE` is not one of the built-in +//! targets, rustc will check if a file named `TUPLE` exists. If it does, it //! will be loaded as the target configuration. If the file does not exist, //! rustc will search each directory in the environment variable -//! `RUST_TARGET_PATH` for a file named `TRIPLE.json`. The first one found will +//! `RUST_TARGET_PATH` for a file named `TUPLE.json`. The first one found will //! be loaded. If no file is found in any of those directories, a fatal error //! will be given. //! @@ -1586,17 +1586,17 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } macro_rules! supported_targets { - ( $(($triple:literal, $module:ident),)+ ) => { + ( $(($tuple:literal, $module:ident),)+ ) => { mod targets { $(pub(crate) mod $module;)+ } /// List of supported targets - pub const TARGETS: &[&str] = &[$($triple),+]; + pub const TARGETS: &[&str] = &[$($tuple),+]; fn load_builtin(target: &str) -> Option { let mut t = match target { - $( $triple => targets::$module::target(), )+ + $( $tuple => targets::$module::target(), )+ _ => return None, }; t.is_builtin = true; @@ -2005,9 +2005,9 @@ pub fn warning_messages(&self) -> Vec { /// Every field here must be specified, and has no default value. #[derive(PartialEq, Clone, Debug)] pub struct Target { - /// Unversioned target triple to pass to LLVM. + /// Unversioned target tuple to pass to LLVM. /// - /// Target triples can optionally contain an OS version (notably Apple targets), which rustc + /// Target tuples can optionally contain an OS version (notably Apple targets), which rustc /// cannot know without querying the environment. /// /// Use `rustc_codegen_ssa::back::versioned_llvm_target` if you need the full LLVM target. @@ -3477,28 +3477,28 @@ macro_rules! key { } /// Load a built-in target - pub fn expect_builtin(target_triple: &TargetTriple) -> Target { - match *target_triple { - TargetTriple::TargetTriple(ref target_triple) => { - load_builtin(target_triple).expect("built-in target") + pub fn expect_builtin(target_tuple: &TargetTuple) -> Target { + match *target_tuple { + TargetTuple::TargetTuple(ref target_tuple) => { + load_builtin(target_tuple).expect("built-in target") } - TargetTriple::TargetJson { .. } => { + TargetTuple::TargetJson { .. } => { panic!("built-in targets doesn't support target-paths") } } } - /// Search for a JSON file specifying the given target triple. + /// Search for a JSON file specifying the given target tuple. /// /// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the - /// sysroot under the target-triple's `rustlib` directory. Note that it could also just be a + /// sysroot under the target-tuple's `rustlib` directory. Note that it could also just be a /// bare filename already, so also check for that. If one of the hardcoded targets we know /// about, just return it directly. /// /// The error string could come from any of the APIs called, including filesystem access and /// JSON decoding. pub fn search( - target_triple: &TargetTriple, + target_tuple: &TargetTuple, sysroot: &Path, ) -> Result<(Target, TargetWarnings), String> { use std::{env, fs}; @@ -3509,16 +3509,16 @@ fn load_file(path: &Path) -> Result<(Target, TargetWarnings), String> { Target::from_json(obj) } - match *target_triple { - TargetTriple::TargetTriple(ref target_triple) => { - // check if triple is in list of built-in targets - if let Some(t) = load_builtin(target_triple) { + match *target_tuple { + TargetTuple::TargetTuple(ref target_tuple) => { + // check if tuple is in list of built-in targets + if let Some(t) = load_builtin(target_tuple) { return Ok((t, TargetWarnings::empty())); } - // search for a file named `target_triple`.json in RUST_TARGET_PATH + // search for a file named `target_tuple`.json in RUST_TARGET_PATH let path = { - let mut target = target_triple.to_string(); + let mut target = target_tuple.to_string(); target.push_str(".json"); PathBuf::from(target) }; @@ -3532,9 +3532,9 @@ fn load_file(path: &Path) -> Result<(Target, TargetWarnings), String> { } } - // Additionally look in the sysroot under `lib/rustlib//target.json` + // Additionally look in the sysroot under `lib/rustlib//target.json` // as a fallback. - let rustlib_path = crate::relative_target_rustlib_path(sysroot, target_triple); + let rustlib_path = crate::relative_target_rustlib_path(sysroot, target_tuple); let p = PathBuf::from_iter([ Path::new(sysroot), Path::new(&rustlib_path), @@ -3544,9 +3544,9 @@ fn load_file(path: &Path) -> Result<(Target, TargetWarnings), String> { return load_file(&p); } - Err(format!("Could not find specification for target {target_triple:?}")) + Err(format!("Could not find specification for target {target_tuple:?}")) } - TargetTriple::TargetJson { ref contents, .. } => { + TargetTuple::TargetJson { ref contents, .. } => { let obj = serde_json::from_str(contents).map_err(|e| e.to_string())?; Target::from_json(obj) } @@ -3751,44 +3751,44 @@ macro_rules! target_option_val { } } -/// Either a target triple string or a path to a JSON file. +/// Either a target tuple string or a path to a JSON file. #[derive(Clone, Debug)] -pub enum TargetTriple { - TargetTriple(String), +pub enum TargetTuple { + TargetTuple(String), TargetJson { /// Warning: This field may only be used by rustdoc. Using it anywhere else will lead to /// inconsistencies as it is discarded during serialization. path_for_rustdoc: PathBuf, - triple: String, + tuple: String, contents: String, }, } // Use a manual implementation to ignore the path field -impl PartialEq for TargetTriple { +impl PartialEq for TargetTuple { fn eq(&self, other: &Self) -> bool { match (self, other) { - (Self::TargetTriple(l0), Self::TargetTriple(r0)) => l0 == r0, + (Self::TargetTuple(l0), Self::TargetTuple(r0)) => l0 == r0, ( - Self::TargetJson { path_for_rustdoc: _, triple: l_triple, contents: l_contents }, - Self::TargetJson { path_for_rustdoc: _, triple: r_triple, contents: r_contents }, - ) => l_triple == r_triple && l_contents == r_contents, + Self::TargetJson { path_for_rustdoc: _, tuple: l_tuple, contents: l_contents }, + Self::TargetJson { path_for_rustdoc: _, tuple: r_tuple, contents: r_contents }, + ) => l_tuple == r_tuple && l_contents == r_contents, _ => false, } } } // Use a manual implementation to ignore the path field -impl Hash for TargetTriple { +impl Hash for TargetTuple { fn hash(&self, state: &mut H) -> () { match self { - TargetTriple::TargetTriple(triple) => { + TargetTuple::TargetTuple(tuple) => { 0u8.hash(state); - triple.hash(state) + tuple.hash(state) } - TargetTriple::TargetJson { path_for_rustdoc: _, triple, contents } => { + TargetTuple::TargetJson { path_for_rustdoc: _, tuple, contents } => { 1u8.hash(state); - triple.hash(state); + tuple.hash(state); contents.hash(state) } } @@ -3796,45 +3796,45 @@ fn hash(&self, state: &mut H) -> () { } // Use a manual implementation to prevent encoding the target json file path in the crate metadata -impl Encodable for TargetTriple { +impl Encodable for TargetTuple { fn encode(&self, s: &mut S) { match self { - TargetTriple::TargetTriple(triple) => { + TargetTuple::TargetTuple(tuple) => { s.emit_u8(0); - s.emit_str(triple); + s.emit_str(tuple); } - TargetTriple::TargetJson { path_for_rustdoc: _, triple, contents } => { + TargetTuple::TargetJson { path_for_rustdoc: _, tuple, contents } => { s.emit_u8(1); - s.emit_str(triple); + s.emit_str(tuple); s.emit_str(contents); } } } } -impl Decodable for TargetTriple { +impl Decodable for TargetTuple { fn decode(d: &mut D) -> Self { match d.read_u8() { - 0 => TargetTriple::TargetTriple(d.read_str().to_owned()), - 1 => TargetTriple::TargetJson { + 0 => TargetTuple::TargetTuple(d.read_str().to_owned()), + 1 => TargetTuple::TargetJson { path_for_rustdoc: PathBuf::new(), - triple: d.read_str().to_owned(), + tuple: d.read_str().to_owned(), contents: d.read_str().to_owned(), }, _ => { - panic!("invalid enum variant tag while decoding `TargetTriple`, expected 0..2"); + panic!("invalid enum variant tag while decoding `TargetTuple`, expected 0..2"); } } } } -impl TargetTriple { - /// Creates a target triple from the passed target triple string. - pub fn from_triple(triple: &str) -> Self { - TargetTriple::TargetTriple(triple.into()) +impl TargetTuple { + /// Creates a target tuple from the passed target tuple string. + pub fn from_tuple(tuple: &str) -> Self { + TargetTuple::TargetTuple(tuple.into()) } - /// Creates a target triple from the passed target path. + /// Creates a target tuple from the passed target path. pub fn from_path(path: &Path) -> Result { let canonicalized_path = try_canonicalize(path)?; let contents = std::fs::read_to_string(&canonicalized_path).map_err(|err| { @@ -3843,46 +3843,47 @@ pub fn from_path(path: &Path) -> Result { format!("target path {canonicalized_path:?} is not a valid file: {err}"), ) })?; - let triple = canonicalized_path + let tuple = canonicalized_path .file_stem() .expect("target path must not be empty") .to_str() .expect("target path must be valid unicode") .to_owned(); - Ok(TargetTriple::TargetJson { path_for_rustdoc: canonicalized_path, triple, contents }) + Ok(TargetTuple::TargetJson { path_for_rustdoc: canonicalized_path, tuple, contents }) } - /// Returns a string triple for this target. + /// Returns a string tuple for this target. /// /// If this target is a path, the file name (without extension) is returned. - pub fn triple(&self) -> &str { + pub fn tuple(&self) -> &str { match *self { - TargetTriple::TargetTriple(ref triple) - | TargetTriple::TargetJson { ref triple, .. } => triple, + TargetTuple::TargetTuple(ref tuple) | TargetTuple::TargetJson { ref tuple, .. } => { + tuple + } } } - /// Returns an extended string triple for this target. + /// Returns an extended string tuple for this target. /// - /// If this target is a path, a hash of the path is appended to the triple returned - /// by `triple()`. - pub fn debug_triple(&self) -> String { + /// If this target is a path, a hash of the path is appended to the tuple returned + /// by `tuple()`. + pub fn debug_tuple(&self) -> String { use std::hash::DefaultHasher; match self { - TargetTriple::TargetTriple(triple) => triple.to_owned(), - TargetTriple::TargetJson { path_for_rustdoc: _, triple, contents: content } => { + TargetTuple::TargetTuple(tuple) => tuple.to_owned(), + TargetTuple::TargetJson { path_for_rustdoc: _, tuple, contents: content } => { let mut hasher = DefaultHasher::new(); content.hash(&mut hasher); let hash = hasher.finish(); - format!("{triple}-{hash}") + format!("{tuple}-{hash}") } } } } -impl fmt::Display for TargetTriple { +impl fmt::Display for TargetTuple { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.debug_triple()) + write!(f, "{}", self.debug_tuple()) } } diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 3e104bdb470..f8fb5284472 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -52,7 +52,7 @@ rustdoc 1.17.0 (56124baa9 2017-04-24) binary: rustdoc commit-hash: hash commit-date: date -host: host-triple +host: host-tuple release: 1.17.0 LLVM version: 3.9 ``` diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 2cd69474b1c..5071ed1c47f 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -17,7 +17,7 @@ use rustc_session::{EarlyDiagCtxt, getopts}; use rustc_span::FileName; use rustc_span::edition::Edition; -use rustc_target::spec::TargetTriple; +use rustc_target::spec::TargetTuple; use crate::core::new_dcx; use crate::externalfiles::ExternalHtml; @@ -96,7 +96,7 @@ pub(crate) struct Options { /// Unstable (`-Z`) options strings to pass to the compiler. pub(crate) unstable_opts_strs: Vec, /// The target used to compile the crate against. - pub(crate) target: TargetTriple, + pub(crate) target: TargetTuple, /// Edition used when reading the crate. Defaults to "2015". Also used by default when /// compiling doctests from the crate. pub(crate) edition: Edition, diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 7b2a5eb3d63..11d8f1947d6 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -24,7 +24,7 @@ use rustc_span::FileName; use rustc_span::edition::Edition; use rustc_span::symbol::sym; -use rustc_target::spec::{Target, TargetTriple}; +use rustc_target::spec::{Target, TargetTuple}; use tempfile::{Builder as TempFileBuilder, TempDir}; use tracing::debug; @@ -414,10 +414,10 @@ pub(crate) struct UnusedExterns { unused_extern_names: Vec, } -fn add_exe_suffix(input: String, target: &TargetTriple) -> String { +fn add_exe_suffix(input: String, target: &TargetTuple) -> String { let exe_suffix = match target { - TargetTriple::TargetTriple(_) => Target::expect_builtin(target).options.exe_suffix, - TargetTriple::TargetJson { contents, .. } => { + TargetTuple::TargetTuple(_) => Target::expect_builtin(target).options.exe_suffix, + TargetTuple::TargetJson { contents, .. } => { Target::from_json(contents.parse().unwrap()).unwrap().0.options.exe_suffix } }; @@ -513,8 +513,8 @@ fn run_test( compiler.arg("--emit=metadata"); } compiler.arg("--target").arg(match &rustdoc_options.target { - TargetTriple::TargetTriple(s) => s, - TargetTriple::TargetJson { path_for_rustdoc, .. } => { + TargetTuple::TargetTuple(s) => s, + TargetTuple::TargetJson { path_for_rustdoc, .. } => { path_for_rustdoc.to_str().expect("target path must be valid unicode") } }); diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index e4f2f95a91b..ecb8343fba3 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -761,7 +761,7 @@ pub fn expected_output_path( /// Absolute path to the directory where all output for all tests in the given /// `relative_dir` group should reside. Example: -/// /path/to/build/host-triple/test/ui/relative/ +/// /path/to/build/host-tuple/test/ui/relative/ /// This is created early when tests are collected to avoid race conditions. pub fn output_relative_path(config: &Config, relative_dir: &Path) -> PathBuf { config.build_base.join(relative_dir) @@ -784,7 +784,7 @@ pub fn output_testname_unique( /// Absolute path to the directory where all output for the given /// test/revision should reside. Example: -/// /path/to/build/host-triple/test/ui/relative/testname.revision.mode/ +/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/ pub fn output_base_dir(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> PathBuf { output_relative_path(config, &testpaths.relative_dir) .join(output_testname_unique(config, testpaths, revision)) @@ -792,13 +792,13 @@ pub fn output_base_dir(config: &Config, testpaths: &TestPaths, revision: Option< /// Absolute path to the base filename used as output for the given /// test/revision. Example: -/// /path/to/build/host-triple/test/ui/relative/testname.revision.mode/testname +/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/testname pub fn output_base_name(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> PathBuf { output_base_dir(config, testpaths, revision).join(testpaths.file.file_stem().unwrap()) } /// Absolute path to the directory to use for incremental compilation. Example: -/// /path/to/build/host-triple/test/ui/relative/testname.mode/testname.inc +/// /path/to/build/host-tuple/test/ui/relative/testname.mode/testname.inc pub fn incremental_dir(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> PathBuf { output_base_name(config, testpaths, revision).with_extension("inc") } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index b337458f943..bc80c8246ad 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1825,7 +1825,7 @@ fn safe_revision(&self) -> Option<&str> { /// Gets the absolute path to the directory where all output for the given /// test/revision should reside. - /// E.g., `/path/to/build/host-triple/test/ui/relative/testname.revision.mode/`. + /// E.g., `/path/to/build/host-tuple/test/ui/relative/testname.revision.mode/`. fn output_base_dir(&self) -> PathBuf { output_base_dir(self.config, self.testpaths, self.safe_revision()) } diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 60d096b92f2..50d3af8cec8 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -692,7 +692,7 @@ pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx>) -> Self { clock: Clock::new(config.isolated_op == IsolatedOp::Allow), #[cfg(unix)] native_lib: config.native_lib.as_ref().map(|lib_file_path| { - let target_triple = tcx.sess.opts.target_triple.triple(); + let target_triple = tcx.sess.opts.target_triple.tuple(); // Check if host target == the session target. if env!("TARGET") != target_triple { panic!( diff --git a/src/tools/opt-dist/src/environment.rs b/src/tools/opt-dist/src/environment.rs index bc01b7fb8a3..90d0ca717b2 100644 --- a/src/tools/opt-dist/src/environment.rs +++ b/src/tools/opt-dist/src/environment.rs @@ -3,7 +3,7 @@ #[derive(Builder)] pub struct Environment { - host_triple: String, + host_tuple: String, python_binary: String, /// The rustc checkout, where the compiler source is located. checkout_dir: Utf8PathBuf, @@ -28,8 +28,8 @@ pub struct Environment { } impl Environment { - pub fn host_triple(&self) -> &str { - &self.host_triple + pub fn host_tuple(&self) -> &str { + &self.host_tuple } pub fn python_binary(&self) -> &str { @@ -45,7 +45,7 @@ pub fn build_root(&self) -> Utf8PathBuf { } pub fn build_artifacts(&self) -> Utf8PathBuf { - self.build_root().join("build").join(&self.host_triple) + self.build_root().join("build").join(&self.host_tuple) } pub fn artifact_dir(&self) -> Utf8PathBuf { diff --git a/src/tools/opt-dist/src/exec.rs b/src/tools/opt-dist/src/exec.rs index e50f2600e85..deff69a7f9c 100644 --- a/src/tools/opt-dist/src/exec.rs +++ b/src/tools/opt-dist/src/exec.rs @@ -105,9 +105,9 @@ pub fn build(env: &Environment) -> Self { env.checkout_path().join("x.py").as_str(), "build", "--target", - &env.host_triple(), + &env.host_tuple(), "--host", - &env.host_triple(), + &env.host_tuple(), "--stage", "2", "library/std", diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 6211b5670aa..c871200f3cf 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -127,7 +127,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec)> shared, } => { let env = EnvironmentBuilder::default() - .host_triple(target_triple) + .host_tuple(target_triple) .python_binary(python) .checkout_dir(checkout_dir.clone()) .host_llvm_dir(llvm_dir) @@ -148,7 +148,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec)> let checkout_dir = Utf8PathBuf::from("/checkout"); let env = EnvironmentBuilder::default() - .host_triple(target_triple) + .host_tuple(target_triple) .python_binary("python3".to_string()) .checkout_dir(checkout_dir.clone()) .host_llvm_dir(Utf8PathBuf::from("/rustroot")) @@ -170,7 +170,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec)> let checkout_dir: Utf8PathBuf = std::env::current_dir()?.try_into()?; let env = EnvironmentBuilder::default() - .host_triple(target_triple) + .host_tuple(target_triple) .python_binary("python".to_string()) .checkout_dir(checkout_dir.clone()) .host_llvm_dir(checkout_dir.join("citools").join("clang-rust")) diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index e401554640c..887055798e0 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -22,7 +22,7 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> { assert!(extracted_path.is_dir()); Ok(extracted_path) }; - let host_triple = env.host_triple(); + let host_triple = env.host_tuple(); let version = find_dist_version(&dist_dir)?; // Extract rustc, libstd, cargo and src archives to create the optimized sysroot @@ -87,7 +87,7 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> { x_py.as_str(), "test", "--build", - env.host_triple(), + env.host_tuple(), "--stage", "0", "tests/assembly",