Skip to content
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

Tracking issue to stabilize --print target-spec-json #38338

Open
cardoe opened this issue Dec 13, 2016 · 9 comments
Open

Tracking issue to stabilize --print target-spec-json #38338

cardoe opened this issue Dec 13, 2016 · 9 comments
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. S-tracking-design-concerns Status: There are blocking ❌ design concerns. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cardoe
Copy link
Contributor

cardoe commented Dec 13, 2016

This issue is meant to track the stabilization of the rustc flag --print target-spec-json which will output the currently selected target as a valid target spec that can be loaded with --target for only the same version of the compiler that generated it. This explicitly avoids saying that target specs are stable but instead intends to assist target spec users to know that their configuration will work with the current version of the compiler.

ref #38061

@sfackler sfackler added B-unstable Blocker: Implemented in the nightly compiler and unstable. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 13, 2016
@alexcrichton alexcrichton added T-tools and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 13, 2016
@Mark-Simulacrum
Copy link
Member

We currently don't even seem to know about this unless -Zunstable-options is passed, which make it incredibly hard to discover. I think there's a note somewhere about that, but I don't know quite where. Just noting here.

@Mark-Simulacrum Mark-Simulacrum added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Jul 22, 2017
@zackmdavis
Copy link
Member

don't even seem to know about this unless -Zunstable-options is passed, which make it incredibly hard to discover

(probably bug #41683, fixed in #43260)

@cardoe
Copy link
Contributor Author

cardoe commented Aug 29, 2017

ping on possibly stabilizing this.

@nrc
Copy link
Member

nrc commented Sep 5, 2017

We discussed this at the dev-tools meeting today. The general feeling was that while this is a fine feature with no obvious problems, there is not a lot of pressure to stabilise, and that given that target specs are unstable, it is probably best not to rush into that.

@cardoe Is there motivation from your end to have this on stable, rather than nightly-only?

@cardoe
Copy link
Contributor Author

cardoe commented Sep 6, 2017

Well I'd use it to generate the specs for Yocto. I've discussed it on other tickets but I can't use the built in targets because of the need for custom sysroots (e.g. the linked Cargo issue) Yocto has a host environment, which is effectively built for the running OS and then the target environment that things are being built for. In some cases they can both be x86_64 machines but they target different libc's and optimizations (e.g. avx on the host but not on the embedded x86_64 target).

So I have to hand craft spec files and detect whenever something changes upstream and adjust them. But if I had this flag it could programmatically be done by making the necessary linker/compiler change to an existing target. It'd basically make it that I'd get newer Rust versions out to Yocto consumers quicker.

I'm not sure if others would use it but that's my personal motivation.

zackmdavis added a commit to zackmdavis/rust that referenced this issue Oct 12, 2017
The option is only made available on nightly builds, for the obvious
reason. While we're here, also prevent the unstable `target-spec-json`
(tracking issue rust-lang#38338) from showing up in the --help on stable builds
(although the way in which we accomplish this is slightly clumsy for
lifetime reasons, as noted in the FIXME).

We make REMOVED_FEATURES, ACCEPTED_FEATURES, &c. public for consistency,
even though the functionality at issue only needs ACTIVE_FEATURES.

The UI test will add a little bit of friction for future feature
developers, but it's better than under-testing.

Resolves rust-lang#38768.
@boris-kolpackov
Copy link

I would also like to see this stabilized. My use-case is support for Rust in a build system (build2) where I need to know the compiler's target. AFAIK, this option is the only way to obtain this information (but please correct me if I am wrong).

Could we perhaps stabilize the output as "subject to change" in a sense that new values can be added and existing values removed only guaranteeing that the meaning of an existing value does not change? I think most consumers of this output will be perfectly capable of dealing with this.

While at it, I would also suggest adding values printed with --version -v to this output. Currently, to obtain the compiler version one must parse the --version output which is likely to get localized in the future. As an additional benefit, this will allow getting both the version and the target with a single invocation.

@pnkfelix
Copy link
Member

pnkfelix commented Mar 4, 2022

We discussed this in today's T-compiler backlog bonanza meeting

The takeaways were:

  • We do have precedent for generating output from stable compilers that is subject to change, namely --emit mir and --emit llvm-ir.
  • We think there may be coupling between the decision on this issue and the decision on De-stabilize target spec JSON  #71009
  • We may want to discourage people from making tools that rely on this output. There was a specific suggestion that we add a header to the output of --print target-spec-json that makes it invalid JSON and warns people not to depend on the output format. (We also might want to rename the parameter itself to just target-spec as well.)

So, overall, it seems like there's motivation to stabilize something here, but we would need the above questions resolved before we could move forward on that.

@rustbot label +S-tracking-design-concerns

@rustbot rustbot added the S-tracking-design-concerns Status: There are blocking ❌ design concerns. label Mar 4, 2022
@jackh726 jackh726 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. labels Mar 4, 2022
@boris-kolpackov
Copy link

BTW, if anyone is banging their head against this (i.e., needing to know the compiler's target but only able to get it if using the nightly Rust compiler), there is the RUSTC_BOOTSTRAP=1 environment variable hack that would allow you to use this option even on the stable Rust compiler (I know the use of this variable is strongly discouraged, but you have to do what you have to do when there is no other option).

@boris-kolpackov
Copy link

In the meantime, perhaps we can consider adding the target triplet (which I believe is what the majority of use-cases are after) to the rustc -vV output, next to the host triplet? I've created an issue for this #105588.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. S-tracking-design-concerns Status: There are blocking ❌ design concerns. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants