Skip to content

Commit f00efe3

Browse files
committed
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. I called it "host-triple" instead of "host" because it's clearer that it's just the target name.
1 parent 30f6bb6 commit f00efe3

File tree

5 files changed

+10
-1
lines changed

5 files changed

+10
-1
lines changed

Diff for: compiler/rustc_driver_impl/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ fn print_crate_info(
734734
targets.sort_unstable();
735735
println_info!("{}", targets.join("\n"));
736736
}
737+
HostTriple => println_info!("{}", rustc_session::config::host_triple()),
737738
Sysroot => println_info!("{}", sess.sysroot.display()),
738739
TargetLibdir => println_info!("{}", sess.target_tlib_path.dir.display()),
739740
TargetSpec => {

Diff for: compiler/rustc_session/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ pub struct PrintRequest {
769769
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
770770
pub enum PrintKind {
771771
FileNames,
772+
HostTriple,
772773
Sysroot,
773774
TargetLibdir,
774775
CrateName,
@@ -1863,6 +1864,7 @@ fn collect_print_requests(
18631864
("crate-name", PrintKind::CrateName),
18641865
("deployment-target", PrintKind::DeploymentTarget),
18651866
("file-names", PrintKind::FileNames),
1867+
("host-triple", PrintKind::HostTriple),
18661868
("link-args", PrintKind::LinkArgs),
18671869
("native-static-libs", PrintKind::NativeStaticLibs),
18681870
("relocation-models", PrintKind::RelocationModels),

Diff for: tests/ui/invalid-compile-flags/print.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
error: unknown print request: `yyyy`
22
|
3-
= help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `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`
3+
= help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `host-triple`, `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`
44

Diff for: tests/ui/print-request/host.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ only-x86_64-unknown-linux-gnu
2+
//@ compile-flags: --print host-triple
3+
//@ check-pass
4+
5+
fn main() {}

Diff for: tests/ui/print-request/host.stdout

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x86_64-unknown-linux-gnu

0 commit comments

Comments
 (0)