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.
This commit is contained in:
parent
77d0b4ddfb
commit
a26450cf81
32 changed files with 167 additions and 168 deletions
|
@ -26,7 +26,7 @@ use rustc_span::{
|
|||
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 @@ bitflags::bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ impl Default for 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 @@ pub(crate) mod dep_tracking {
|
|||
SanitizerSet,
|
||||
CFGuard,
|
||||
CFProtection,
|
||||
TargetTriple,
|
||||
TargetTuple,
|
||||
Edition,
|
||||
LinkerPluginLto,
|
||||
ResolveDocLinks,
|
||||
|
|
|
@ -29,7 +29,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
|||
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 @@ impl CheckCfg {
|
|||
|
||||
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));
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc_errors::{
|
|||
};
|
||||
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 EmbedSourceRequiresDebugInfo;
|
|||
#[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(
|
||||
|
|
|
@ -152,7 +152,7 @@ fn current_dll_path() -> Result<PathBuf, String> {
|
|||
}
|
||||
|
||||
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 @@ pub fn get_or_default_sysroot() -> Result<PathBuf, String> {
|
|||
))?;
|
||||
|
||||
// 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`
|
||||
|
|
|
@ -14,7 +14,7 @@ use rustc_span::{RealFileName, SourceFileHashAlgorithm};
|
|||
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 @@ top_level_options!(
|
|||
libs: Vec<NativeLib> [TRACKED],
|
||||
maybe_sysroot: Option<PathBuf> [UNTRACKED],
|
||||
|
||||
target_triple: TargetTriple [TRACKED],
|
||||
target_triple: TargetTuple [TRACKED],
|
||||
|
||||
/// Effective logical environment used by `env!`/`option_env!` macros
|
||||
logical_env: FxIndexMap<String, String> [TRACKED],
|
||||
|
|
|
@ -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 @@ impl PathKind {
|
|||
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 @@ impl SearchPath {
|
|||
);
|
||||
}
|
||||
|
||||
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),
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ use rustc_target::asm::InlineAsmArch;
|
|||
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 @@ impl Session {
|
|||
/// 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<PathBuf> {
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue