Skip to content

rustc_target: Begin unifying Arch enum #142775

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

workingjubilee
Copy link
Member

@workingjubilee workingjubilee commented Jun 20, 2025

There are a few different instances of this Arch enum in rustc_target. I would like to unify them so that we use shared code in more cases, as part of an incremental step towards turning Target into a proper builder with type-level correctness instead of its current constructor. However, it's definitely true the immediate changes look somewhat jank and have the disadvantage of in some cases handling some code less exhaustively, so I'm going to ask some maintainers if it's okay.

This PR currently starts with lifting from the Apple code, so

r? @madsmtm

@rustbot rustbot added O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

@workingjubilee
Copy link
Member Author

workingjubilee commented Jun 23, 2025

also cc @thomcc

I intend to make the QNX targets part of this PR too, and also reuse this code elsewhere in spec, but I believe this will affect maintaining the code for the Apple targets more in practice.

@bors
Copy link
Collaborator

bors commented Aug 9, 2025

☔ The latest upstream changes (presumably #145126) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in reviewing this! Generally on-board with having a unified Arch enum.

@rustbot author

Comment on lines +3659 to +3664
pub(crate) enum Arch {
Arm(ArmVer),
Aarch64(Aarch64Ver),
X86_32(Ix86),
X86_64(X86_64Ver),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I get why you'd want to simplify things in this manner (arch enum with subarch enums), but I'm not sure that's actually a good idea?

I particularly don't like the Arch::Arm64 to Aarch64Ver::V8A.into() change, it makes it harder to understand what's going on (are we specifying the arch or subarch here?), and it becomes incorrect as soon as you pass -Ctarget-cpu=apple-a10.

I'd prefer a single-level Arch enum, and rather have helpers like .is_aarch64() or .is_arm() (if those are even useful in the face of things like ARM64EC).

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
@workingjubilee
Copy link
Member Author

workingjubilee commented Aug 14, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants