Skip to content

Replace ad-hoc ABI "adjustments" with an AbiMap to CanonAbi #141569

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

Merged
merged 11 commits into from
Jun 4, 2025

Conversation

workingjubilee
Copy link
Member

@workingjubilee workingjubilee commented May 26, 2025

Our conv_from_spec_abi, adjust_abi, and is_abi_supported combine to give us a very confusing way of reasoning about what actual calling convention we want to lower our code to and whether we want to compile the resulting code at all. Instead of leaving this code as a miniature adventure game in which someone tries to combine stateful mutations into a Rube Goldberg machine that will let them escape the maze and arrive at the promised land of codegen, we let AbiMap devour this complexity. Once you have an AbiMap, you can answer which ExternAbis will lower to what CanonAbis (and whether they will lower at all).

Removed:

  • conv_from_spec_abi replaced by AbiMap::canonize_abi
  • adjust_abi replaced by same
  • Conv::PreserveAll as unused
  • Conv::Cold as unused
  • enum Conv replaced by enum CanonAbi

target-spec.json changes:

  • If you have a target-spec.json then now your "entry-abi" key will be specified in terms of one of the "{abi}" strings Rust recognizes, e.g.
    "entry-abi": "C",
    "entry-abi": "win64",
    "entry-abi": "aapcs",

@rustbot rustbot added O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) PG-exploit-mitigations Project group: Exploit mitigations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 26, 2025
@workingjubilee
Copy link
Member Author

I'd like to see you
@bors try

bors added a commit that referenced this pull request May 26, 2025
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

I am having second thoughts about some of my design choices, here, but I think it's useless to _internally_ debate them further.

r? `@ghost`

try-job: test-various
try-job: aarch64-apple
try-job: aarch64-gnu
try-job: armhf-gnu
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
try-job: i686-msvc-1
try-job: i686-msvc-2
@bors

This comment was marked as outdated.

@workingjubilee

This comment was marked as resolved.

@workingjubilee

This comment was marked as resolved.

@workingjubilee

This comment was marked as resolved.

bors added a commit that referenced this pull request May 26, 2025
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

I am having second thoughts about some of my design choices, here, but I think it's useless to _internally_ debate them further.

r? `@ghost`

try-job: test-various
try-job: aarch64-apple
try-job: aarch64-gnu
try-job: armhf-gnu
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
try-job: i686-msvc-1
try-job: i686-msvc-2
@bors

This comment was marked as outdated.

@workingjubilee
Copy link
Member Author

I am foolish and impatient.
@bors try-
@bors try

@bors
Copy link
Collaborator

bors commented May 26, 2025

⌛ Trying commit e9817cc with merge 9938b8a...

bors added a commit that referenced this pull request May 26, 2025
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

I am having second thoughts about some of my design choices, here, but I think it's useless to _internally_ debate them further.

r? `@ghost`

try-job: test-various
try-job: aarch64-apple
try-job: aarch64-gnu
try-job: armhf-gnu
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
try-job: i686-msvc-1
try-job: i686-msvc-2
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.


/// ABIs relevant to Windows or x86 targets
X86(X86Call),
}
Copy link
Member

Choose a reason for hiding this comment

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

😍

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah so that decision actually does look right to someone who is not inside my head? Great.

@workingjubilee

This comment was marked as resolved.

@workingjubilee

This comment was marked as resolved.

@workingjubilee
Copy link
Member Author

@bors try

@bors
Copy link
Collaborator

bors commented May 26, 2025

⌛ Trying commit 17fab7d with merge c4f8500...

bors added a commit that referenced this pull request May 26, 2025
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

I am having second thoughts about some of my design choices, here, but I think it's useless to _internally_ debate them further.

r? `@ghost`

try-job: test-various
try-job: aarch64-apple
try-job: aarch64-gnu
try-job: armhf-gnu
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
try-job: i686-msvc-1
try-job: i686-msvc-2
@workingjubilee workingjubilee removed PG-exploit-mitigations Project group: Exploit mitigations O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) labels May 26, 2025
@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 Jun 3, 2025
- Add AbiMapping for encoding the nuance of deprecated ABIs
makes entry_abi a lowering of the ABI string, so now it can be
```json
  "entry_abi": "C",
  "entry_abi": "win64",
  "entry_abi": "aapcs",
```
`adjust_abi` is not needed and `is_abi_supported` can be a 1-liner.
@workingjubilee
Copy link
Member Author

@bors r-

@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 Jun 3, 2025
@workingjubilee
Copy link
Member Author

implemented requested namechange by Ralf in this diff and this is passing CI again. I think Ralf is traveling or sommat and this is otherwise functionally identical so

@bors r=bjorn3

@bors
Copy link
Collaborator

bors commented Jun 3, 2025

📌 Commit 307a18d has been approved by bjorn3

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 Jun 3, 2025
bors added a commit that referenced this pull request Jun 3, 2025
Rollup of 8 pull requests

Successful merges:

 - #137725 (Add `iter` macro)
 - #141455 (std: abort the process on failure to allocate a TLS key)
 - #141569 (Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`)
 - #141698 (Use the informative error as the main const eval error message)
 - #141925 (Remove bootstrap cfgs from library/)
 - #141943 (Remove pre-expansion AST stats.)
 - #141945 (Remove `Path::is_ident`.)
 - #141957 (Add missing `dyn` keywords to tests that do not test for them Part 2)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 644f06e into rust-lang:master Jun 4, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 4, 2025
rust-timer added a commit that referenced this pull request Jun 4, 2025
Rollup merge of #141569 - workingjubilee:canonicalize-abi, r=bjorn3

Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

Our `conv_from_spec_abi`, `adjust_abi`, and `is_abi_supported` combine to give us a very confusing way of reasoning about what _actual_ calling convention we want to lower our code to and whether we want to compile the resulting code at all. Instead of leaving this code as a miniature adventure game in which someone tries to combine stateful mutations into a Rube Goldberg machine that will let them escape the maze and arrive at the promised land of codegen, we let `AbiMap` devour this complexity. Once you have an `AbiMap`, you can answer which `ExternAbi`s will lower to what `CanonAbi`s (and whether they will lower at all).

Removed:
- `conv_from_spec_abi` replaced by `AbiMap::canonize_abi`
- `adjust_abi` replaced by same
- `Conv::PreserveAll` as unused
- `Conv::Cold` as unused
- `enum Conv` replaced by `enum CanonAbi`

target-spec.json changes:
- If you have a target-spec.json then now your "entry-abi" key will be specified in terms of one of the `"{abi}"` strings Rust recognizes, e.g.
```json
    "entry-abi": "C",
    "entry-abi": "win64",
    "entry-abi": "aapcs",
```
@workingjubilee workingjubilee deleted the canonicalize-abi branch June 4, 2025 03:31
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 4, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#137725 (Add `iter` macro)
 - rust-lang/rust#141455 (std: abort the process on failure to allocate a TLS key)
 - rust-lang/rust#141569 (Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`)
 - rust-lang/rust#141698 (Use the informative error as the main const eval error message)
 - rust-lang/rust#141925 (Remove bootstrap cfgs from library/)
 - rust-lang/rust#141943 (Remove pre-expansion AST stats.)
 - rust-lang/rust#141945 (Remove `Path::is_ident`.)
 - rust-lang/rust#141957 (Add missing `dyn` keywords to tests that do not test for them Part 2)

r? `@ghost`
`@rustbot` modify labels: rollup
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Jun 5, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#137725 (Add `iter` macro)
 - rust-lang/rust#141455 (std: abort the process on failure to allocate a TLS key)
 - rust-lang/rust#141569 (Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`)
 - rust-lang/rust#141698 (Use the informative error as the main const eval error message)
 - rust-lang/rust#141925 (Remove bootstrap cfgs from library/)
 - rust-lang/rust#141943 (Remove pre-expansion AST stats.)
 - rust-lang/rust#141945 (Remove `Path::is_ident`.)
 - rust-lang/rust#141957 (Add missing `dyn` keywords to tests that do not test for them Part 2)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-target-specs Area: Compile-target specifications A-targets Area: Concerning the implications of different compiler targets O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) PG-exploit-mitigations Project group: Exploit mitigations 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.

7 participants