mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Auto merge of #125579 - Noratrieb:print-host, r=davidtwco
Add `--print host-tuple` to print host target tuple People often parse `-vV` output to get to the host tuple, which is annoying to do. It's easier to just get it directly. I called it "host-tuple" instead of "host" because it's clearer that it's just the target name. I'm open to different names, but I think this one is fine. a quick GitHub search for `'^host` reveals many instances of people doing the parsing, for example:68e0ca57cd/README.md (L369)
0e38473b0c/main.sh (L96)
8a3553b865/README.md (L625)
43f3ec3970/do.sh (L35)
needs a compiler FCP. I could also do an MCP but I think just an FCP here makes the most sense.
This commit is contained in:
commit
8ccb78e0d5
@ -118,8 +118,8 @@ impl GlobalAsmConfig {
|
||||
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()
|
||||
}
|
||||
},
|
||||
|
@ -146,7 +146,7 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
|
||||
|
||||
// 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!();
|
||||
}
|
||||
|
@ -946,7 +946,7 @@ fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data:
|
||||
}
|
||||
|
||||
fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> 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<LlvmCodegenBackend>) -> bool {
|
||||
}
|
||||
|
||||
fn target_is_aix(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
|
||||
cgcx.opts.target_triple.triple().contains("-aix")
|
||||
cgcx.opts.target_triple.tuple().contains("-aix")
|
||||
}
|
||||
|
||||
pub(crate) fn bitcode_section_name(cgcx: &CodegenContext<LlvmCodegenBackend>) -> &'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(
|
||||
|
@ -997,7 +997,7 @@ fn link_natively(
|
||||
{
|
||||
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 link_sanitizer_runtime(
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ pub(crate) fn get_linker<'a>(
|
||||
self_contained: bool,
|
||||
target_cpu: &'a str,
|
||||
) -> Box<dyn Linker + 'a> {
|
||||
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
|
||||
|
@ -62,7 +62,7 @@ use rustc_session::{EarlyDiagCtxt, Session, config, filesearch};
|
||||
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;
|
||||
|
||||
@ -731,6 +731,7 @@ fn print_crate_info(
|
||||
targets.sort_unstable();
|
||||
println_info!("{}", targets.join("\n"));
|
||||
}
|
||||
HostTuple => println_info!("{}", rustc_session::config::host_tuple()),
|
||||
Sysroot => println_info!("{}", sess.sysroot.display()),
|
||||
TargetLibdir => println_info!("{}", sess.target_tlib_path.dir.display()),
|
||||
TargetSpec => {
|
||||
@ -739,7 +740,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 +919,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 +1496,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 +1506,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 +1519,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
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rustc_macros::Subdiagnostic;
|
||||
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 @@ into_diag_arg_using_display!(
|
||||
MacroRulesNormalizedIdent,
|
||||
ParseIntError,
|
||||
StackProtector,
|
||||
&TargetTriple,
|
||||
&TargetTuple,
|
||||
SplitDebuginfo,
|
||||
ExitStatus,
|
||||
ErrCode,
|
||||
|
@ -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 {
|
||||
|
@ -11,7 +11,7 @@ use rustc_data_structures::sync;
|
||||
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)
|
||||
|
@ -30,7 +30,7 @@ use rustc_session::search_paths::PathKind;
|
||||
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 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||
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 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||
// 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() {
|
||||
|
@ -5,7 +5,7 @@ use rustc_errors::codes::*;
|
||||
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 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for CannotFindCrate {
|
||||
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 {
|
||||
|
@ -231,7 +231,7 @@ use rustc_session::search_paths::PathKind;
|
||||
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<Svh>,
|
||||
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 @@ impl<'a> CrateLocator<'a> {
|
||||
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 @@ impl<'a> CrateLocator<'a> {
|
||||
return None;
|
||||
}
|
||||
|
||||
if header.triple != self.triple {
|
||||
info!("Rejecting via crate triple: expected {} got {}", self.triple, header.triple);
|
||||
if header.triple != self.tuple {
|
||||
info!("Rejecting via crate triple: expected {} got {}", self.tuple, header.triple);
|
||||
self.crate_rejections.via_triple.push(CrateMismatch {
|
||||
path: libpath.to_path_buf(),
|
||||
got: header.triple.to_string(),
|
||||
@ -766,7 +766,7 @@ impl<'a> CrateLocator<'a> {
|
||||
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<CratePaths>,
|
||||
triple: TargetTriple,
|
||||
triple: TargetTuple,
|
||||
dll_prefix: String,
|
||||
dll_suffix: String,
|
||||
crate_rejections: CrateRejections,
|
||||
@ -1034,7 +1034,7 @@ impl CrateError {
|
||||
dcx.emit_err(errors::NoCrateWithTriple {
|
||||
span,
|
||||
crate_name,
|
||||
locator_triple: locator.triple.triple(),
|
||||
locator_triple: locator.triple.tuple(),
|
||||
add_info,
|
||||
found_crates,
|
||||
});
|
||||
|
@ -770,7 +770,7 @@ impl MetadataBlob {
|
||||
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!(
|
||||
|
@ -38,7 +38,7 @@ use rustc_span::edition::Edition;
|
||||
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.
|
||||
|
@ -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;
|
||||
|
||||
@ -813,6 +813,7 @@ pub struct PrintRequest {
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum PrintKind {
|
||||
FileNames,
|
||||
HostTuple,
|
||||
Sysroot,
|
||||
TargetLibdir,
|
||||
CrateName,
|
||||
@ -1116,7 +1117,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 +1159,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 +1355,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 \
|
||||
@ -1945,6 +1946,7 @@ fn collect_print_requests(
|
||||
("crate-name", PrintKind::CrateName),
|
||||
("deployment-target", PrintKind::DeploymentTarget),
|
||||
("file-names", PrintKind::FileNames),
|
||||
("host-tuple", PrintKind::HostTuple),
|
||||
("link-args", PrintKind::LinkArgs),
|
||||
("native-static-libs", PrintKind::NativeStaticLibs),
|
||||
("relocation-models", PrintKind::RelocationModels),
|
||||
@ -2030,16 +2032,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 +3007,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 +3092,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
|
||||
|
@ -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 @@ impl fmt::Display for StackProtector {
|
||||
}
|
||||
|
||||
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<Target> {
|
||||
let mut t = match target {
|
||||
$( $triple => targets::$module::target(), )+
|
||||
$( $tuple => targets::$module::target(), )+
|
||||
_ => return None,
|
||||
};
|
||||
t.is_builtin = true;
|
||||
@ -2005,9 +2005,9 @@ impl TargetWarnings {
|
||||
/// 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 @@ impl Target {
|
||||
}
|
||||
|
||||
/// 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 @@ impl Target {
|
||||
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 @@ impl Target {
|
||||
}
|
||||
}
|
||||
|
||||
// Additionally look in the sysroot under `lib/rustlib/<triple>/target.json`
|
||||
// Additionally look in the sysroot under `lib/rustlib/<tuple>/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 @@ impl Target {
|
||||
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 @@ impl ToJson for Target {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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<H: Hasher>(&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 @@ impl Hash for TargetTriple {
|
||||
}
|
||||
|
||||
// Use a manual implementation to prevent encoding the target json file path in the crate metadata
|
||||
impl<S: Encoder> Encodable<S> for TargetTriple {
|
||||
impl<S: Encoder> Encodable<S> 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<D: Decoder> Decodable<D> for TargetTriple {
|
||||
impl<D: Decoder> Decodable<D> 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<Self, io::Error> {
|
||||
let canonicalized_path = try_canonicalize(path)?;
|
||||
let contents = std::fs::read_to_string(&canonicalized_path).map_err(|err| {
|
||||
@ -3843,46 +3843,47 @@ impl TargetTriple {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,8 @@ The valid types of print values are:
|
||||
- `crate-name` — The name of the crate.
|
||||
- `file-names` — The names of the files created by the `link` emit kind.
|
||||
- `sysroot` — Path to the sysroot.
|
||||
- `target-libdir` - Path to the target libdir.
|
||||
- `target-libdir` — Path to the target libdir.
|
||||
- `host-tuple` — The target-tuple string of the host compiler (e.g. `x86_64-unknown-linux-gnu`)
|
||||
- `cfg` — List of cfg values. See [conditional compilation] for more
|
||||
information about cfg values.
|
||||
- `target-list` — List of known targets. The target may be selected with the
|
||||
@ -286,7 +287,7 @@ The valid types of print values are:
|
||||
exact format of this debugging output is not a stable guarantee, other than
|
||||
that it will include the linker executable and the text of each command-line
|
||||
argument passed to the linker.
|
||||
- `deployment-target` - The currently selected [deployment target] (or minimum OS version)
|
||||
- `deployment-target` — The currently selected [deployment target] (or minimum OS version)
|
||||
for the selected Apple platform target. This value can be used or passed along to other
|
||||
components alongside a Rust build that need this information, such as C compilers.
|
||||
This returns rustc's minimum supported deployment target if no `*_DEPLOYMENT_TARGET` variable
|
||||
|
@ -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
|
||||
```
|
||||
|
@ -17,7 +17,7 @@ use rustc_session::search_paths::SearchPath;
|
||||
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<String>,
|
||||
/// 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,
|
||||
|
@ -24,7 +24,7 @@ use rustc_session::lint;
|
||||
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<String>,
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
});
|
||||
|
@ -761,7 +761,7 @@ pub const UI_COVERAGE_MAP: &str = "cov-map";
|
||||
|
||||
/// 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")
|
||||
}
|
||||
|
@ -1825,7 +1825,7 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
/// 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())
|
||||
}
|
||||
|
@ -691,7 +691,7 @@ impl<'tcx> MiriMachine<'tcx> {
|
||||
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!(
|
||||
|
@ -3,7 +3,7 @@ use derive_builder::Builder;
|
||||
|
||||
#[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 @@ impl Environment {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -105,9 +105,9 @@ impl Bootstrap {
|
||||
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",
|
||||
|
@ -127,7 +127,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
|
||||
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<String>)>
|
||||
|
||||
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<String>)>
|
||||
|
||||
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"))
|
||||
|
@ -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 @@ llvm-config = "{llvm_config}"
|
||||
x_py.as_str(),
|
||||
"test",
|
||||
"--build",
|
||||
env.host_triple(),
|
||||
env.host_tuple(),
|
||||
"--stage",
|
||||
"0",
|
||||
"tests/assembly",
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: unknown print request: `yyyy`
|
||||
|
|
||||
= help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models`
|
||||
= help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models`
|
||||
|
||||
|
5
tests/ui/print-request/host.rs
Normal file
5
tests/ui/print-request/host.rs
Normal file
@ -0,0 +1,5 @@
|
||||
//@ only-x86_64-unknown-linux-gnu
|
||||
//@ compile-flags: --print host-tuple
|
||||
//@ check-pass
|
||||
|
||||
fn main() {}
|
1
tests/ui/print-request/host.stdout
Normal file
1
tests/ui/print-request/host.stdout
Normal file
@ -0,0 +1 @@
|
||||
x86_64-unknown-linux-gnu
|
Loading…
Reference in New Issue
Block a user