Skip to content

Commit 638515e

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 638515e

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

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

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

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() {}

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)