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

compiler: Move rustc_target::spec::abi::Abi to rustc_abi::ExternAbi #132385

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

workingjubilee
Copy link
Member

@workingjubilee workingjubilee commented Oct 31, 2024

Lift enum Abi from its rather odd place in the middle of rustc_target, and make it available again from rustc_abi. You know, the crate where you would expect the enum that describes all the ABIs to be? The platform-neutral ones, at least. This will help further refactoring of how we handle ABIs in the near future1.

Rename Abi to ExternAbi because quite a lot of the compiler overloads the concept of "ABI" enough that the existing name is imprecise and it is often renamed anyway. Often this was to avoid conflicts with the other type formerly known as Abi (now named BackendRepr2), but sometimes it is just for clarity, and this name seems more self-explanatory. It does get reexported, though, using its old name, to reduce the odds of merge-conflicting over the entire tree.

All of ExternAbi's friends come along for the ride, which costs adding some optional dependencies to the rustc_abi crate. However, all of this also allows simply moving three crates entirely off rustc_target:

  • rustc_hir_pretty
  • rustc_lint_defs
  • rustc_mir_build

This odd selection is mostly to demonstrate a secondary motivation: The majority of the front-end of the compiler should be as target-agnostic as possible, and it is easier to assure this if they simply don't depend on the crate that describes targets. Note that I didn't migrate crates that don't benefit from it in this way yet, and I didn't survey every last crate.

Footnotes

  1. This is being undertaken as part of https://github.com/rust-lang/rust/issues/119183

  2. https://github.com/rust-lang/rust/pull/132246

@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2024

r? @pnkfelix

rustbot has assigned @pnkfelix.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 31, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2024

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred in match lowering

cc @Nadrieril

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

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

Completely abandon usage of rustc_target in these crates, as
they need no special knowledge of rustc's target tuples.
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Looks certainly saner to me. Will wait a bit in case anyone has some naming/terminology concerns, but otherwise LGTM.

@@ -7,9 +7,11 @@ use rustc_span::{Span, Symbol};
#[cfg(test)]
mod tests;

use ExternAbi as Abi;
Copy link
Member

Choose a reason for hiding this comment

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

are we gonna get rid of this too

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

👍 👍. No naming concerns from me.

pub mod crt_objects;

pub mod abi {
pub use rustc_abi::{
Copy link
Member

Choose a reason for hiding this comment

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

and this reexport as Abi would be nice to get rid of

Copy link
Member Author

Choose a reason for hiding this comment

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

I can make this PR my entry in the most-files-in-tree-diffed-in-2024 competition, sure.

@compiler-errors
Copy link
Member

Let's not do any more cleanups in this PR. I'm happy to review anything re: those comments I left above, possibly piecewise.

@bors r=jieyouxu,compiler-errors

@bors
Copy link
Contributor

bors commented Oct 31, 2024

📌 Commit 8a0e640 has been approved by jieyouxu,compiler-errors

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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 31, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 31, 2024
…bi, r=jieyouxu,compiler-errors

compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`

Lift `enum Abi` from its rather odd place in the middle of rustc_target, and make it available again from rustc_abi. You know, the crate where you would expect the enum that describes all the ABIs to be? The platform-neutral ones, at least. This will help further refactoring of how we handle ABIs in the near future[^0].

Rename `Abi` to `ExternAbi` because quite a lot of the compiler overloads the concept of "ABI" enough that the existing name is imprecise and it is often renamed _anyway_. Often this was to avoid conflicts with the *other* type formerly known as `Abi` (now named BackendRepr[^1]), but sometimes it is just for clarity, and this name seems more self-explanatory. It does get reexported, though, using its old name, to reduce the odds of merge-conflicting over the entire tree.

All of `ExternAbi`'s friends come along for the ride, which costs adding some optional dependencies to the rustc_abi crate. However, all of this also allows simply moving three crates entirely off rustc_target:
- rustc_hir_pretty
- rustc_lint_defs
- rustc_mir_build

This odd selection is mostly to demonstrate a secondary motivation: The majority of the front-end of the compiler should be as target-agnostic as possible, and it is easier to assure this if they simply don't depend on the crate that describes targets. Note that I didn't migrate crates that don't benefit from it in this way yet, and I didn't survey every last crate.

[^0]: This is being undertaken as part of rust-lang#119183
[^1]: rust-lang#132246
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 31, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#131168 (Fix `target_os` for `mipsel-sony-psx`)
 - rust-lang#132209 (Fix validation when lowering `?` trait bounds)
 - rust-lang#132357 (Improve missing_abi lint)
 - rust-lang#132385 (compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`)
 - rust-lang#132417 (macOS: Document the difference between Clang's `-darwin` and `-macosx` targets)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2024
…kingjubilee

Rollup of 9 pull requests

Successful merges:

 - rust-lang#131168 (Fix `target_os` for `mipsel-sony-psx`)
 - rust-lang#132209 (Fix validation when lowering `?` trait bounds)
 - rust-lang#132294 (Bump Fuchsia)
 - rust-lang#132357 (Improve missing_abi lint)
 - rust-lang#132385 (compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`)
 - rust-lang#132403 (continue `TypingMode` refactor)
 - rust-lang#132417 (macOS: Document the difference between Clang's `-darwin` and `-macosx` targets)
 - rust-lang#132421 (Remove `""` case from RISC-V `llvm_abiname` match statement)
 - rust-lang#132422 (llvm: Match new LLVM 128-bit integer alignment on sparc)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6da4221 into rust-lang:master Nov 1, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 1, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2024
Rollup merge of rust-lang#132385 - workingjubilee:move-abi-to-rustc-abi, r=jieyouxu,compiler-errors

compiler: Move `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`

Lift `enum Abi` from its rather odd place in the middle of rustc_target, and make it available again from rustc_abi. You know, the crate where you would expect the enum that describes all the ABIs to be? The platform-neutral ones, at least. This will help further refactoring of how we handle ABIs in the near future[^0].

Rename `Abi` to `ExternAbi` because quite a lot of the compiler overloads the concept of "ABI" enough that the existing name is imprecise and it is often renamed _anyway_. Often this was to avoid conflicts with the *other* type formerly known as `Abi` (now named BackendRepr[^1]), but sometimes it is just for clarity, and this name seems more self-explanatory. It does get reexported, though, using its old name, to reduce the odds of merge-conflicting over the entire tree.

All of `ExternAbi`'s friends come along for the ride, which costs adding some optional dependencies to the rustc_abi crate. However, all of this also allows simply moving three crates entirely off rustc_target:
- rustc_hir_pretty
- rustc_lint_defs
- rustc_mir_build

This odd selection is mostly to demonstrate a secondary motivation: The majority of the front-end of the compiler should be as target-agnostic as possible, and it is easier to assure this if they simply don't depend on the crate that describes targets. Note that I didn't migrate crates that don't benefit from it in this way yet, and I didn't survey every last crate.

[^0]: This is being undertaken as part of rust-lang#119183
[^1]: rust-lang#132246
@workingjubilee workingjubilee deleted the move-abi-to-rustc-abi branch November 2, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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