-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add target triplet next to host in rustc -vV
output
#105588
Comments
How would this work with non-LLVM backends? Those can have their own names for targets entirely separate from what LLVM calls them. Also in the case of that stackoverflow question the user did actually want the rust triple which is already printed by
What do you need the LLVM triple for? Passing it to rustc as |
While it's true the format of "target triplet" is not precisely documented, most backends will have some sensible variant of it. For example, for GCC:
I believe there are two different dichotomies here: the exact target triplet format, as in "Rust triplet" vs "LLVM triplet" (vs, I guess, "GNU triplet", as printed by I am not too attached to the exact format of the target triplet that would be printed by
While #38338 has more background on my use-case, in a nutshell, a build system that I am working on needs to know which platform is being targeted by |
It identifies the default target which is always the same as the host triple: rust/compiler/rustc_session/src/config.rs Lines 1845 to 1859 in 2176e3a
--target to tell it to use a different triple as target.
For the first one cargo uses
For the second one, asking the user to specify it is the only accurate way. While rust triples often look like gcc or llvm ones, this is not always the case. i686-apple-darwin is i386-apple-darwin according to gcc. aarch64-apple-ios-sim is aarch64-apple-ios7.0-simulator according to clang (or other versions depending on IPHONEOS_DEPLOYMENT_TARGET). Take a look at the cc crate for more examples of arbitrary mappings: https://github.com/rust-lang/cc-rs/blob/main/src/lib.rs Many of them don't match either the rust triple or the triple passed to llvm by rustc so getting access to both is not as useful as you may think. |
Yes, I think you are right. I was under the impression that one can change the default target with While I believe there is still some value in my proposal (i.e., one doesn't have to analyze the command line manually), it is quite diminished and I would understand if it's not viewed as worthy of the trouble. |
While I'm sympathetic to "make it clearer," the expectation for a target triple comes from the gcc-ism of cross compilers being an exception rather than the norm. rustc is fundamentally a cross compiler, so there is no target configuration to rustc other than what host architecture it's built for. |
I'm going to close this; the only way to compile to a target other than the host is to pass --target, at which point the user already knows which target they're compiling to. |
I would like to propose adding the comiler's target triplet next to the host triplet in the
rustc -vV
output. Specifically, currently (as of 1.62) the output looks like this:I propose to change this to print:
The value for the
target
line will be the same asllvm-target
in the--print target-spec-json
output.Here is the motivation for this addition:
Currently, AFAIK, the only way to get this information is with the
--print target-spec-json
option which is unstable. This means one can only use it on the nightly compiler (or resort to theRUSTC_BOOTSTRAP=1
hacks). While there is desire to stabilize this option (see Tracking issue to stabilize --print target-spec-json #38338), the progress has been slow and it's currently blocked on design concerns.Even if/when
--print target-spec-json
is stabilized, it would still be beneficial to provide the target triplet as part of the-vV
output because that would allow getting the commonly needed information (compiler version and target) with a single compiler invocation. As it is currently, in the build system I work on (build2
), we have to make two compiler invocations to get this information.It appears that some users are confusing the host triplet (as printed in
-vV
) for target. For example, see answers to this StackOverflow question. By printing both we will hopefully make people pause and contemplate the difference.If this sounds like a good idea, I can try to come up with a PR.
The text was updated successfully, but these errors were encountered: