From df8c20d7a5ddb84eb1e5fd2c366f51d357306f34 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Wed, 30 Oct 2024 16:40:55 +0100 Subject: [PATCH 1/9] Add intra-doc link in str::xxx_prefix --- library/core/src/str/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 89addc4cb747e..4c2d43b9edec2 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -2169,7 +2169,7 @@ impl str { /// Returns a string slice with the prefix removed. /// /// If the string starts with the pattern `prefix`, returns the substring after the prefix, - /// wrapped in `Some`. Unlike `trim_start_matches`, this method removes the prefix exactly once. + /// wrapped in `Some`. Unlike [`trim_start_matches`], this method removes the prefix exactly once. /// /// If the string does not start with `prefix`, returns `None`. /// @@ -2178,6 +2178,7 @@ impl str { /// /// [`char`]: prim@char /// [pattern]: self::pattern + /// [`trim_start_matches`]: Self::trim_start_matches /// /// # Examples /// @@ -2196,7 +2197,7 @@ impl str { /// Returns a string slice with the suffix removed. /// /// If the string ends with the pattern `suffix`, returns the substring before the suffix, - /// wrapped in `Some`. Unlike `trim_end_matches`, this method removes the suffix exactly once. + /// wrapped in `Some`. Unlike [`trim_end_matches`], this method removes the suffix exactly once. /// /// If the string does not end with `suffix`, returns `None`. /// @@ -2205,6 +2206,7 @@ impl str { /// /// [`char`]: prim@char /// [pattern]: self::pattern + /// [`trim_end_matches`]: Self::trim_end_matches /// /// # Examples /// From df445264b3e97cb3e2845f6fbb9ae541225f86cf Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Wed, 30 Oct 2024 16:50:55 +0100 Subject: [PATCH 2/9] Add intra-doc link in str::xxx_char_boundary --- library/core/src/str/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 4c2d43b9edec2..208ad9e7e5fce 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -211,7 +211,7 @@ impl str { } } - /// Finds the closest `x` not exceeding `index` where `is_char_boundary(x)` is `true`. + /// Finds the closest `x` not exceeding `index` where [`is_char_boundary(x)`] is `true`. /// /// This method can help you truncate a string so that it's still valid UTF-8, but doesn't /// exceed a given number of bytes. Note that this is done purely at the character level @@ -219,6 +219,8 @@ impl str { /// split. For example, the emoji 🧑‍🔬 (scientist) could be split so that the string only /// includes 🧑 (person) instead. /// + /// [`is_char_boundary(x)`]: Self::is_char_boundary + /// /// # Examples /// /// ``` @@ -247,7 +249,7 @@ impl str { } } - /// Finds the closest `x` not below `index` where `is_char_boundary(x)` is `true`. + /// Finds the closest `x` not below `index` where [`is_char_boundary(x)`] is `true`. /// /// If `index` is greater than the length of the string, this returns the length of the string. /// @@ -255,7 +257,7 @@ impl str { /// for more details. /// /// [`floor_char_boundary`]: str::floor_char_boundary - /// + /// [`is_char_boundary(x)`]: Self::is_char_boundary /// /// # Examples /// From 57673dd6463856c8bad426dc7508c69fa3369122 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 1 Nov 2024 22:39:08 +0900 Subject: [PATCH 3/9] Remove needless #![feature(asm_experimental_arch)] from loongarch64 inline assembly test --- tests/assembly/asm/loongarch-type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/assembly/asm/loongarch-type.rs b/tests/assembly/asm/loongarch-type.rs index 1b097f4110501..c51d35876d92d 100644 --- a/tests/assembly/asm/loongarch-type.rs +++ b/tests/assembly/asm/loongarch-type.rs @@ -3,7 +3,7 @@ //@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: loongarch -#![feature(no_core, lang_items, rustc_attrs, asm_experimental_arch)] +#![feature(no_core, lang_items, rustc_attrs)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register, non_camel_case_types)] From 37db36594838d85f72e2282e73707071e80e31c0 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 1 Nov 2024 12:44:55 +0100 Subject: [PATCH 4/9] Also treat `impl` definition parent as transparent regarding modules --- compiler/rustc_lint/src/non_local_def.rs | 10 ++- .../convoluted-locals-132427.rs | 64 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 tests/ui/lint/non-local-defs/convoluted-locals-132427.rs diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs index 3c31b879bd6aa..3c33b2dd4789c 100644 --- a/compiler/rustc_lint/src/non_local_def.rs +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -151,9 +151,15 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { // }; // }; // ``` + // + // It isn't possible to mix a impl in a module with const-anon, but an item can + // be put inside a module and referenced by a impl so we also have to treat the + // item parent as transparent to module and for consistency we have to do the same + // for impl, otherwise the item-def and impl-def won't have the same parent. let outermost_impl_parent = peel_parent_while(cx.tcx, parent, |tcx, did| { - tcx.def_kind(did) == DefKind::Const - && tcx.opt_item_name(did) == Some(kw::Underscore) + tcx.def_kind(did) == DefKind::Mod + || (tcx.def_kind(did) == DefKind::Const + && tcx.opt_item_name(did) == Some(kw::Underscore)) }); // 2. We check if any of the paths reference a the `impl`-parent. diff --git a/tests/ui/lint/non-local-defs/convoluted-locals-132427.rs b/tests/ui/lint/non-local-defs/convoluted-locals-132427.rs new file mode 100644 index 0000000000000..5732e048ae38a --- /dev/null +++ b/tests/ui/lint/non-local-defs/convoluted-locals-132427.rs @@ -0,0 +1,64 @@ +// Regression tests for https://github.com/rust-lang/rust/issues/132427 + +//@ check-pass + +// original +mod auth { + const _: () = { + pub enum ArbitraryContext {} + + const _: () = { + impl ArbitraryContext {} + }; + }; +} + +mod z { + pub enum ArbitraryContext {} + + const _: () = { + const _: () = { + impl ArbitraryContext {} + }; + }; +} + +const _: () = { + mod auth { + const _: () = { + pub enum ArbitraryContext {} + + const _: () = { + impl ArbitraryContext {} + }; + }; + } +}; + +mod a { + mod b { + const _: () = { + pub enum ArbitraryContext {} + + const _: () = { + impl ArbitraryContext {} + }; + }; + } +} + +mod foo { + const _: () = { + mod auth { + const _: () = { + pub enum ArbitraryContext {} + + const _: () = { + impl ArbitraryContext {} + }; + }; + } + }; +} + +fn main() {} From e169483879e73141bec00004c3c68eaa9652423b Mon Sep 17 00:00:00 2001 From: ismailarilik Date: Fri, 1 Nov 2024 20:19:01 +0300 Subject: [PATCH 5/9] refactor(config): remove FIXME statement in comment of `omit-git-hash` It is already fixed. --- config.example.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config.example.toml b/config.example.toml index 9072a83551a7e..cd7ec6a05bc10 100644 --- a/config.example.toml +++ b/config.example.toml @@ -668,8 +668,6 @@ # Flag indicating whether git info will be retrieved from .git automatically. # Having the git information can cause a lot of rebuilds during development. -# -# FIXME(#76720): this can causes bugs if different compilers reuse the same metadata cache. #omit-git-hash = if rust.channel == "dev" { true } else { false } # Whether to create a source tarball by default when running `x dist`. From e4305f16570efc342529e35c7b0ec5b1ca50b954 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:10:36 +0100 Subject: [PATCH 6/9] Add a bunch of mailmap entries This adds a bunch of missing mailmap entries for many people. These are needed when using rust-lang/team information in rust-lang/thanks, as the emails there may differ. These are all the "easy" ones, where there was a mailmap entry already, making it clear which one is the preferred email address. --- .mailmap | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 56490ca5059b0..fdb62a9d77826 100644 --- a/.mailmap +++ b/.mailmap @@ -31,6 +31,7 @@ Alexis Beingessner Alfie John Alfie John Alona Enraght-Moony Alona Enraght-Moony +Alona Enraght-Moony Amanda Stjerna Amanda Stjerna Amos Onn @@ -75,6 +76,7 @@ Benjamin Jackman Benoît Cortier Bheesham Persaud Bheesham Persaud bjorn3 <17426603+bjorn3@users.noreply.github.com> +bjorn3 <17426603+bjorn3@users.noreply.github.com> Björn Steinbrink blake2-ppc blyxyas Alejandra González @@ -172,6 +174,7 @@ Dzmitry Malyshau E. Dunham edunham Ed Barnard Eduard-Mihai Burtescu +Eduard-Mihai Burtescu Eduardo Bautista <=> Eduardo Bautista Eduardo Broto @@ -186,6 +189,7 @@ Erick Tryzelaar Erik Desjardins Erik Jensen Erin Power +Erin Power Erin Power Erin Power Esteban Küber @@ -198,6 +202,7 @@ F001 Fabian Kössel Falco Hirschenberger Felix S. Klock II Felix S Klock II +Felix S. Klock II Félix Saparelli Flaper Fesp Florian Berger @@ -245,7 +250,7 @@ Irina Popa Ivan Ivaschenko ivan tkachenko J. J. Weber -Jack Huey +Jack Huey Jacob Jacob Greenfield Jacob Pratt @@ -292,6 +297,7 @@ John Clements John Hodge John Hodge John Hörnvall John Kåre Alsaker +John Kåre Alsaker John Talling John Van Enk Jonas Tepe @@ -368,6 +374,7 @@ Lukas Lueg Luke Metz Luqman Aden Luqman Aden +Luqman Aden Lzu Tao Maik Klein Malo Jaffré @@ -409,6 +416,7 @@ mental mibac138 <5672750+mibac138@users.noreply.github.com> Michael Williams Michael Woerister +Michael Woerister Michael Woerister Michael Woerister Michael Zhang @@ -422,6 +430,7 @@ Ms2ger msizanoen1 Mukilan Thiagarajan Nadrieril Feneanar +Nadrieril Feneanar NAKASHIMA, Makoto NAKASHIMA, Makoto Nathan Ringo @@ -442,6 +451,8 @@ Niclas Schwarzlose <15schnic@gmail.com> Nicolas Abram Nicole Mazzuca Noratrieb <48135649+Noratrieb@users.noreply.github.com> <48135649+Nilstrieb@users.noreply.github.com> +Noratrieb <48135649+Noratrieb@users.noreply.github.com> +Noratrieb <48135649+Noratrieb@users.noreply.github.com> Nif Ward Nika Layzell NODA Kai @@ -460,6 +471,7 @@ Oliver Scherer Oliver Scherer Oliver Scherer Oliver Scherer +Oliver Scherer Oliver Scherer Onur Özkan Onur Özkan @@ -496,6 +508,7 @@ Raphaël Huchet rChaser53 Rémy Rakic Rémy Rakic +Rémy Rakic Renato Riccieri Santos Zannon Richard Diamond Ricky Hosfelt @@ -525,6 +538,7 @@ Samuel Tardieu Santiago Pastorino Santiago Pastorino Scott McMurray +Scott McMurray Scott Olson Scott Olson Sean Gillespie swgillespie Seiichi Uchida @@ -536,6 +550,7 @@ Shyam Sundar B Simon Barber-Dueck Simon BD Simon Sapin Simonas Kazlauskas Simonas Kazlauskas +Simonas Kazlauskas Siva Prasad Smittyvb Srinivas Reddy Thatiparthy @@ -556,6 +571,8 @@ Tatsuyuki Ishi Tau Gärtli Tero Hänninen Tero Hänninen The8472 +The8472 +The8472 Theo Belaire Theo Belaire Theodore Luo Wang Thiago Pontes thiagopnts @@ -593,7 +610,8 @@ Waffle Lapkin Wesley Wiser whitequark William Ting -Wim Looman +Wim Looman +Wim Looman Without Boats Without Boats Xinye Tao From 177683afc0645c9ffdda462e30fb38cf4141b6eb Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 26 May 2024 20:50:30 +0200 Subject: [PATCH 7/9] move deployment-target tests to print-request --- .../{deployment-target => print-request}/invalid-target.rs | 0 .../invalid-target.stderr | 0 tests/ui/print-request/macos-target.rs | 7 +++++++ .../macos-target.stdout | 0 4 files changed, 7 insertions(+) rename tests/ui/{deployment-target => print-request}/invalid-target.rs (100%) rename tests/ui/{deployment-target => print-request}/invalid-target.stderr (100%) create mode 100644 tests/ui/print-request/macos-target.rs rename tests/ui/{deployment-target => print-request}/macos-target.stdout (100%) diff --git a/tests/ui/deployment-target/invalid-target.rs b/tests/ui/print-request/invalid-target.rs similarity index 100% rename from tests/ui/deployment-target/invalid-target.rs rename to tests/ui/print-request/invalid-target.rs diff --git a/tests/ui/deployment-target/invalid-target.stderr b/tests/ui/print-request/invalid-target.stderr similarity index 100% rename from tests/ui/deployment-target/invalid-target.stderr rename to tests/ui/print-request/invalid-target.stderr diff --git a/tests/ui/print-request/macos-target.rs b/tests/ui/print-request/macos-target.rs new file mode 100644 index 0000000000000..be2c32e28141b --- /dev/null +++ b/tests/ui/print-request/macos-target.rs @@ -0,0 +1,7 @@ +//@ only-macos +//@ compile-flags: --print deployment-target +//@ normalize-stdout-test: "\d+\." -> "$$CURRENT_MAJOR_VERSION." +//@ normalize-stdout-test: "\d+" -> "$$CURRENT_MINOR_VERSION" +//@ check-pass + +fn main() {} diff --git a/tests/ui/deployment-target/macos-target.stdout b/tests/ui/print-request/macos-target.stdout similarity index 100% rename from tests/ui/deployment-target/macos-target.stdout rename to tests/ui/print-request/macos-target.stdout From 21ce18618810991714fc919de880c4ccd9e74f8f 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 8/9] 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 | 143 +++++++++--------- 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 | 2 +- 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, 163 insertions(+), 164 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/global_asm.rs b/compiler/rustc_codegen_cranelift/src/global_asm.rs index 0c99a5ce12f6e..6f90d17920d61 100644 --- a/compiler/rustc_codegen_cranelift/src/global_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/global_asm.rs @@ -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() } }, diff --git a/compiler/rustc_codegen_gcc/src/consts.rs b/compiler/rustc_codegen_gcc/src/consts.rs index 3029b9341795a..660badb6a5018 100644 --- a/compiler/rustc_codegen_gcc/src/consts.rs +++ b/compiler/rustc_codegen_gcc/src/consts.rs @@ -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!(); } diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index bfa9e8b82a033..819c15f6b0e62 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 34dc599e4fddd..1b5a34053d1a7 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -996,7 +996,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(); @@ -1322,10 +1322,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 } } diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index c4bb82d0dd7b1..3b4429535d434 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 e2585c023883a..3ea8347f8933c 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -61,7 +61,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; @@ -738,7 +738,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 09a608dda7ba2..798668b8bc1f0 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -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, diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 85e11ff674500..d8b63eef577af 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 71e8accf5a328..b5bddc4b21aef 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -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) diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 16623915c4019..be7b2383a454e 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -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() { diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 6587125ec677f..16684ae6f263a 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -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 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 { diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index f924ed48b6f0f..ddd97fc66f66e 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -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, 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, - 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, }); diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index ebfd3c09fc1a2..87357b74c411e 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -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!( diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index ab878760c00b0..949e26f5f609b 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -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. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d733e32f209db..2f6deb7c1c399 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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()), } } @@ -3017,7 +3017,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, }; @@ -3102,7 +3102,7 @@ pub(crate) mod dep_tracking { 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 31ef2bda4f1e5..347d298bacc66 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -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)); diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 20e8fb38b88ce..33f84f104474d 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -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( diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index b3e3381d986b7..213a94ab88091 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 @@ pub fn get_or_default_sysroot() -> 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 54a4621db2462..34b50caf243c1 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -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 [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 ac0d8661115d1..c148b09c718a0 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 @@ 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), }; diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 45434534c75ea..470e372ee48e1 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -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 { - 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 3e7b42d3d1c13..5d80b09e6428a 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. //! @@ -1590,17 +1590,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 { let mut t = match target { - $( $triple => targets::$module::target(), )+ + $( $tuple => targets::$module::target(), )+ _ => return None, }; t.is_builtin = true; @@ -2009,7 +2009,7 @@ impl TargetWarnings { /// Every field here must be specified, and has no default value. #[derive(PartialEq, Clone, Debug)] pub struct Target { - /// Target triple to pass to LLVM. + /// Target tuple to pass to LLVM. pub llvm_target: StaticCow, /// Metadata about a target, for example the description or tier. /// Used for generating target documentation. @@ -3476,28 +3476,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}; @@ -3508,16 +3508,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) }; @@ -3531,9 +3531,9 @@ impl Target { } } - // 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), @@ -3543,9 +3543,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) } @@ -3750,44 +3750,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(&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) } } @@ -3795,45 +3795,45 @@ impl Hash for TargetTriple { } // 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| { @@ -3842,46 +3842,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()) } } diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 3e104bdb470fd..f8fb528447270 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 2cd69474b1cf0..5071ed1c47faa 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -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, /// 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 7b2a5eb3d637a..11d8f1947d6ef 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -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, } -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 e4f2f95a91b5d..ecb8343fba353 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -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") } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index b337458f94359..bc80c8246ad0f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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()) } diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 60d096b92f2d3..50d3af8cec817 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -692,7 +692,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!( diff --git a/src/tools/opt-dist/src/environment.rs b/src/tools/opt-dist/src/environment.rs index bc01b7fb8a37d..524becb43246f 100644 --- a/src/tools/opt-dist/src/environment.rs +++ b/src/tools/opt-dist/src/environment.rs @@ -28,7 +28,7 @@ pub struct Environment { } impl Environment { - pub fn host_triple(&self) -> &str { + pub fn host_tuple(&self) -> &str { &self.host_triple } diff --git a/src/tools/opt-dist/src/exec.rs b/src/tools/opt-dist/src/exec.rs index e50f2600e850a..deff69a7f9c00 100644 --- a/src/tools/opt-dist/src/exec.rs +++ b/src/tools/opt-dist/src/exec.rs @@ -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", diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 6211b5670aa69..c871200f3cfcb 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 e401554640c49..887055798e00a 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 @@ llvm-config = "{llvm_config}" x_py.as_str(), "test", "--build", - env.host_triple(), + env.host_tuple(), "--stage", "0", "tests/assembly", From 0b79d609985aedee6ce5e2952630143c483938fd Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Thu, 17 Oct 2024 19:03:06 +0200 Subject: [PATCH 9/9] Add `--print host-triple` People often parse `-vV` output to get to the host triple, which is annoying to do. It's easier to just get it directly. --- compiler/rustc_driver_impl/src/lib.rs | 1 + compiler/rustc_session/src/config.rs | 2 ++ src/doc/rustc/src/command-line-arguments.md | 5 +++-- tests/ui/invalid-compile-flags/print.stderr | 2 +- tests/ui/print-request/host.rs | 5 +++++ tests/ui/print-request/host.stdout | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 tests/ui/print-request/host.rs create mode 100644 tests/ui/print-request/host.stdout diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 3ea8347f8933c..8a7a1f8620d05 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -730,6 +730,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 => { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 2f6deb7c1c399..4f338fb23cffc 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -813,6 +813,7 @@ pub struct PrintRequest { #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum PrintKind { FileNames, + HostTuple, Sysroot, TargetLibdir, CrateName, @@ -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), diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index e5631ba42741a..f38d34fccd492 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -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 diff --git a/tests/ui/invalid-compile-flags/print.stderr b/tests/ui/invalid-compile-flags/print.stderr index 70b4a394dd022..df0c3977dc8f6 100644 --- a/tests/ui/invalid-compile-flags/print.stderr +++ b/tests/ui/invalid-compile-flags/print.stderr @@ -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` diff --git a/tests/ui/print-request/host.rs b/tests/ui/print-request/host.rs new file mode 100644 index 0000000000000..d54da9b35d09f --- /dev/null +++ b/tests/ui/print-request/host.rs @@ -0,0 +1,5 @@ +//@ only-x86_64-unknown-linux-gnu +//@ compile-flags: --print host-tuple +//@ check-pass + +fn main() {} diff --git a/tests/ui/print-request/host.stdout b/tests/ui/print-request/host.stdout new file mode 100644 index 0000000000000..21696ec3a0c4f --- /dev/null +++ b/tests/ui/print-request/host.stdout @@ -0,0 +1 @@ +x86_64-unknown-linux-gnu