-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Current platform's target tuple in std::env::consts #146296
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
library/std/src/env.rs
Outdated
#[stable(feature = "env", since = "1.0.0")] | ||
pub const ARCH: &str = env!("STD_ENV_ARCH"); | ||
|
||
/// An identifier used to select the platform for which the standard library was built |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constant isn't used to select anything, right? I think the text here should resemble the docs for pub const ARCH
above, so something like:
A string describing ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've meant it in the sense of "std has been compiled with --target=this-string"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, then I think this is clearer
/// An identifier used to select the platform for which the standard library was built | |
/// A string describing the platform for which the standard library was built |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "--target
argument passed to rustc for this compilation"? That seems like it ought to match 1:1 to what we're returning.
I'm not sure I'm convinced that this should have HOST in its name -- we don't have that for any of the other constants in this file, and they're all derived from the same source. For a rustc --print
argument it makes more sense to differentiate, but here I'm not convinced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TUPLE
alone would be weird, since without the context it's ambiguous with the tuple types.
it could be a PLATFORM
, but that becomes completely disconnected from the --print host-tuple
and Cargo's HOST
env var.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::env::consts::TUPLE
doesn't feel easily confusable with the tuple types -- and any such confusion should clear up quickly when actually seeing it's a const with a str value.
I'd personally argue "TARGET" or "HOST" is also not unreasonable naming, given the rest of the constants in that module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to HOST
, and added explanation when it may not match --target
or TARGET
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have an accepted libs-api ACP? Otherwise it'll need to gate on that.
library/std/src/env.rs
Outdated
#[stable(feature = "env", since = "1.0.0")] | ||
pub const ARCH: &str = env!("STD_ENV_ARCH"); | ||
|
||
/// An identifier used to select the platform for which the standard library was built |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "--target
argument passed to rustc for this compilation"? That seems like it ought to match 1:1 to what we're returning.
I'm not sure I'm convinced that this should have HOST in its name -- we don't have that for any of the other constants in this file, and they're all derived from the same source. For a rustc --print
argument it makes more sense to differentiate, but here I'm not convinced.
1db8bf1
to
1c15f98
Compare
This comment has been minimized.
This comment has been minimized.
1c15f98
to
b5d0ecc
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
b5d0ecc
to
b5befe3
Compare
I took a look but there doesn't seem to be an ACP for this yet, |
Reminder, once the PR becomes ready for a review, use |
@rustbot ready |
/// * `"loongarch64-unknown-none-softfloat"` | ||
/// * `"mipsel-sony-psx"` | ||
/// * `"nvptx64-nvidia-cuda"` | ||
/// * `"powerpc64le-unknown-freebsd"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add powerpc64le-...
and powerpc64-...
, since those can't easily be reconstructed from their parts (unfortunately RustSec decided to delete the upstream repo, making its history very hard to find, here's the corresponding PR)
Implementation for #146295
The terminology follows #125579
I wasn't sure if it's appropriate to refer users to
rustc --print target-list
in the doc. I haven't seen any other references to compiler flags in std.I've added a doc alias for
TARGET
, because that's unfortunately the name users may be more familiar with.I've picked weird platform examples in the doc to discourage users from trying to parse it.