Skip to content

Conversation

kornelski
Copy link
Contributor

@kornelski kornelski commented Sep 7, 2025

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.

@rustbot
Copy link
Collaborator

rustbot commented Sep 7, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 7, 2025
#[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
Copy link
Contributor

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 ...

Copy link
Contributor Author

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"

Copy link
Contributor

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

Suggested change
/// 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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

@kornelski kornelski Sep 23, 2025

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.

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a 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.

View changes since this review

#[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
Copy link
Member

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.

@rustbot

This comment has been minimized.

@tgross35 tgross35 added the needs-acp This change is blocked on the author creating an ACP. label Sep 7, 2025
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 23, 2025

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.

@tgross35
Copy link
Contributor

I took a look but there doesn't seem to be an ACP for this yet,
@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 30, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@tgross35 tgross35 removed the S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. label Sep 30, 2025
@kornelski
Copy link
Contributor Author

ACP rust-lang/libs-team#664

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 30, 2025
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. needs-acp This change is blocked on the author creating an ACP. labels Sep 30, 2025
/// * `"loongarch64-unknown-none-softfloat"`
/// * `"mipsel-sony-psx"`
/// * `"nvptx64-nvidia-cuda"`
/// * `"powerpc64le-unknown-freebsd"`
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants