Skip to content

Conversation

@tamird
Copy link
Contributor

@tamird tamird commented Nov 5, 2025

Improve type safety by using an enum rather than strings.

I'm not really sure this is better since only a few vendors have special semantics. r? @nnethercote

@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2025

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

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

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in cfg and check-cfg configuration

cc @Urgau

The Miri subtree was changed

cc @rust-lang/miri

@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 Nov 5, 2025
@RalfJung
Copy link
Member

RalfJung commented Nov 5, 2025

FWIW for a related change recently we had quite a bit of discussion: rust-lang/compiler-team#926.

@tamird tamird force-pushed the vendor-enum branch 2 times, most recently from e47f7c3 to 013077b Compare November 6, 2025 03:08
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Nov 6, 2025
@rustbot

This comment has been minimized.

@tamird tamird changed the title rustc_target: introduce Vendor rustc_target: introduce Vendor, Abi, Env, Os Nov 6, 2025
@tamird tamird changed the title rustc_target: introduce Vendor, Abi, Env, Os rustc_target: introduce Vendor, ABI, Env, OS Nov 6, 2025
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

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

I have a bunch of nits but this generally looks good. Linker is another candidate for enum-ification, if you aren't yet bored of this stuff :)

View changes since this review

Unikraft = "unikraft",
Uwp = "uwp",
Vex = "vex",
Win7 = "win7",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea what "win7" is? Makes me think of Windows 7, which is a weird name for a vendor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dates back to #118150 which explains:

I went with naming the target x86_64-win7-windows-msvc, inserting the win7 in the vendor field (usually set to to pc). This is done to avoid ecosystem churn, as quite a few crates have cfg(target_os = "windows") or cfg(target_env = "msvc"), but nearly no cfg(target_vendor = "pc"). Since my goal is to be able to seamlessly swap to the win7 target, I figured it'd be easier this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, ok. Thanks for the info!

@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 Nov 7, 2025
@nnethercote
Copy link
Contributor

FWIW for a related change recently we had quite a bit of discussion: rust-lang/compiler-team#926.

IMO these changes are so similar to the change in that MCP that additional discussion isn't needed.

Copy link
Contributor Author

@tamird tamird left a comment

Choose a reason for hiding this comment

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

Addressed all but one comment and left things unsquashed to (somewhat) ease review. I do plan to squash once you're happy with it.

View changes since this review

Unikraft = "unikraft",
Uwp = "uwp",
Vex = "vex",
Win7 = "win7",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dates back to #118150 which explains:

I went with naming the target x86_64-win7-windows-msvc, inserting the win7 in the vendor field (usually set to to pc). This is done to avoid ecosystem churn, as quite a few crates have cfg(target_os = "windows") or cfg(target_env = "msvc"), but nearly no cfg(target_vendor = "pc"). Since my goal is to be able to seamlessly swap to the win7 target, I figured it'd be easier this way.

@tamird tamird changed the title rustc_target: introduce Vendor, ABI, Env, OS rustc_target: introduce Vendor, Abi, Env, Os Nov 7, 2025
@nnethercote
Copy link
Contributor

r=me with the commits squashed, thanks!

@bors delegate=tamird

@bors
Copy link
Collaborator

bors commented Nov 7, 2025

✌️ @tamird, you can now approve this pull request!

If @nnethercote told you to "r=me" after making some further change, please make that change, then do @bors r=@nnethercote

@rustbot

This comment has been minimized.

@tamird
Copy link
Contributor Author

tamird commented Nov 7, 2025

range-diff is ~empty, which is what I expected!

@bors r=@nnethercote

@bors
Copy link
Collaborator

bors commented Nov 7, 2025

📌 Commit cd47df7 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 7, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 8, 2025
rustc_target: introduce Vendor, Abi, Env, Os

Improve type safety by using an enum rather than strings.

I'm not really sure this is better since only a few vendors have special semantics. r? `@nnethercote`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 8, 2025
rustc_target: introduce Vendor, Abi, Env, Os

Improve type safety by using an enum rather than strings.

I'm not really sure this is better since only a few vendors have special semantics. r? ``@nnethercote``
@bors
Copy link
Collaborator

bors commented Nov 8, 2025

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

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 8, 2025
Avoid duplicating this comment in preparation for adding more enums.
Prepare for additional enums like Vendor and Os which have true
`Unknown` variants. We want to use the same name for the escape hatch
for all of these, thus rename this one.
Improve type safety by using an enum rather than strings.
Improve type safety by using an enum rather than strings.
Improve type safety by using an enum rather than strings.
Improve type safety by using an enum rather than strings.
@rustbot
Copy link
Collaborator

rustbot commented Nov 8, 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.

@tamird
Copy link
Contributor Author

tamird commented Nov 8, 2025

@bors r=@nnethercote

@bors
Copy link
Collaborator

bors commented Nov 8, 2025

📌 Commit 8f6aaa2 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2025
@bors
Copy link
Collaborator

bors commented Nov 8, 2025

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

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

6 participants