Skip to content

prefer actual ABI-controling fields over target.abi when making ABI decisions#152941

Open
RalfJung wants to merge 1 commit intorust-lang:mainfrom
RalfJung:abi-control
Open

prefer actual ABI-controling fields over target.abi when making ABI decisions#152941
RalfJung wants to merge 1 commit intorust-lang:mainfrom
RalfJung:abi-control

Conversation

@RalfJung
Copy link
Member

@RalfJung RalfJung commented Feb 21, 2026

We don't actually check that abi is consistent with the fields that control the ABI, e.g. one could set llvm_abiname to "ilp32e" on a riscv target without setting a matching abi. So, if we need to make actual decisions, better to use the source of truth we forward to LLVM than the informational string we forward to the user.

This is a breaking change for aarch64 JSON target specs: setting abi to "softfloat" is no longer enough; one has to also set rustc_abi to "softfloat". That is consistent with riscv and arm32, but it's still surprising. Cc @Darksonn in case this affects the Linux kernel.

Also see #153035 which does something similar for PowerPC, and Zulip. Happy to delay this PR if someone has a better idea.

Cc @folkertdev @workingjubilee

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Feb 21, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 21, 2026

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 68 candidates
  • Random selection from 14 candidates

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the abi-control branch 2 times, most recently from f2e7433 to d7ea008 Compare February 21, 2026 21:13
// Everything else is assumed to use a hardfloat ABI. neon and fp-armv8 must be enabled.
// `FeatureConstraints` uses Rust feature names, hence only "neon" shows up.
FeatureConstraints { required: &["neon"], incompatible: &[] }
match self.rustc_abi {
Copy link
Member Author

Choose a reason for hiding this comment

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

This actually seems like a great improvement in consistency; every other match in this function is about rustc_abi / llvm_abiname / llvm_floatabi.

@Darksonn
Copy link
Member

Linux just uses the built-in aarch64-unknown-none-softfloat target. Target.json is only used on x86, where we do set rustc-abi to x86-softfloat.

@RalfJung
Copy link
Member Author

Okay, sounds good then. (That value has been renamed to "softfloat" recently but we accept the old one as well.)

@RalfJung RalfJung added the relnotes Marks issues that should be documented in the release notes of the next release. label Feb 22, 2026
Copy link
Member

@mati865 mati865 left a comment

Choose a reason for hiding this comment

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

r=me with nit addressed

View changes since this review

// Rust does not currently support any powerpc softfloat targets.
let target = &bx.cx.tcx.sess.target;
let is_soft_float_abi = target.abi == Abi::SoftFloat;
let is_soft_float_abi = target.rustc_abi == Some(RustcAbi::Softfloat);
Copy link
Member Author

@RalfJung RalfJung Feb 24, 2026

Choose a reason for hiding this comment

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

We don't actually use RustcAbi::Softfloat on powerpc currently.
@Gelbpunkt Do we even have a powerpc softfloat target and how does it work? @folkertdev which target was this check supposed to deal with?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have softfloat powerpc targets at the moment, but I'm pretty sure the RfL people will want to add one? Not sure what the plans are for that...

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. relnotes Marks issues that should be documented in the release notes of the next release. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants