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.
This commit is contained in:
Noratrieb 2024-10-17 19:03:06 +02:00
parent a26450cf81
commit ba481518da
6 changed files with 13 additions and 3 deletions

View File

@ -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 => {

View File

@ -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),

View File

@ -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

View File

@ -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`

View File

@ -0,0 +1,5 @@
//@ only-x86_64-unknown-linux-gnu
//@ compile-flags: --print host-tuple
//@ check-pass
fn main() {}

View File

@ -0,0 +1 @@
x86_64-unknown-linux-gnu