rustcross-compilingtriplet

How can I query rustc for the host triple?


When working with gcc, I can get what gcc thinks is my host's triplet by running gcc -dumpmachine. On my current system, this gives me x86_64-linux-gnu.

How can I get stable rustc to print my host triple? (x86_64-unknown-linux-gnu in this case)

rustc's documentation doesn't seem to contain anything relevant besides the --print and --version. Neither seem to produce the host target triple.

Clarification: with two answers being given about nightly so far, I want to stress that this question is specifically about stable rustc compilers.


Solution

  • rustc --version --verbose
    

    Will give you some output like:

    rustc 1.35.0-nightly (474e7a648 2019-04-07)
    binary: rustc
    commit-hash: 474e7a6486758ea6fc761893b1a49cd9076fb0ab
    commit-date: 2019-04-07
    host: x86_64-unknown-linux-gnu
    release: 1.35.0-nightly
    LLVM version: 8.0
    

    Where host is your target triple.