Skip to content

turn ABI-controlling target features into a target modifier - #160593

Open
RalfJung wants to merge 4 commits into
rust-lang:mainfrom
RalfJung:abi-relevant-target-features
Open

turn ABI-controlling target features into a target modifier#160593
RalfJung wants to merge 4 commits into
rust-lang:mainfrom
RalfJung:abi-relevant-target-features

Conversation

@RalfJung

@RalfJung RalfJung commented Aug 5, 2026

Copy link
Copy Markdown
Member

This makes it so that we can mark "internal" target features (which we track as target features in the compiler but do not expose as such to the user) as target modifiers, to be really sure that they are set consistently across all targets. For instance, if there was a value for -Ctarget-cpu that affected ABI-relevant target features, we'd catch mismatches in the value of that target feature.

For now, this just complements the ABI check logic in abi_required_features, but I think long-term it might even be able to fully replace that logic. This would, for example, let us check consistency of the SPARC ABI (#160562) without introducing a new variant for RustcAbi. OTOH having the ABI represented explicitly is often useful elsewhere in the compiler (e.g. for inline asm) so we may also want to keep both abi_required_features and this new concept of "target features that must be consistent across all crates". We could also eventually turn the target modifier into a safety net: if abi_required_features violations are a hard error and -Ctarget-feature is locked down to reject non-Rust target features, it should be impossible to ever violate the new target modifier check.

Cc @Darksonn @workingjubilee

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

Stacked on top of #160530, only the last commit is new.

@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in cfg and check-cfg configuration

cc @Urgau

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

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

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-rustdoc-json Area: Rustdoc JSON backend 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 Aug 5, 2026
@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 5, 2026
@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

Comment on lines +268 to 270
/// Store values for target modifiers. `gather_target_modifiers` takes those values
/// to decide what to store in metadata.
pub target_modifiers: BTreeMap<OptionsTargetModifiers, String>,

@RalfJung RalfJung Aug 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FWIW I could not quite understand why we have both this map and some extra logic in gather_target_modifiers. When I found this map I had assumed that the entire contents of this map will be stored as target modifier, but instead there's a separate filtering step. Why?

Cc @azhogin

View changes since the review

@RalfJung
RalfJung force-pushed the abi-relevant-target-features branch 2 times, most recently from 0adef58 to d87b168 Compare August 5, 2026 22:20
@RalfJung

RalfJung commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

r? @davidtwco

@rustbot rustbot assigned davidtwco and unassigned mati865 Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-rustdoc-json Area: Rustdoc JSON backend 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. T-rustdoc Relevant to the rustdoc 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