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...

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 assume we can then just leave this in in preparation for when a softfloat powerpc target gets added, since it'll presumably use the RustcAbi mechanism for that (AFAIK LLVM has no proper ABI control for powerpc). @folkertdev would still be nice if we could get a quick confirmation of that. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh wait I just realized we actually assert that this is non-softfloat immediately in the next line. Given precedent set for other targets then yeah checking rustc_abi here is definitely the right call; this just slipped through during review of the original code (hard to blame anyone for that, checking target.abi is extremely natural, but sadly wrong).

@RalfJung
Copy link
Member Author

RalfJung commented Mar 2, 2026

@bors r=mati865

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 2, 2026

📌 Commit c66597e has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Mar 2, 2026
@workingjubilee
Copy link
Member

I wish we did something more structural here, as I've voiced, but I have no objection to this merging since the previous version also is Technically Wrong so like... Technically Right But Confusing is I guess a better starting ground for building a more structural change.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 2, 2026
prefer actual ABI-controling fields over target.abi when making ABI decisions

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 rust-lang#153035 which does something similar for PowerPC, and [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/De-spaghettifying.20ABI.20controls/with/575095372). Happy to delay this PR if someone has a better idea.

Cc @folkertdev @workingjubilee
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 2, 2026
prefer actual ABI-controling fields over target.abi when making ABI decisions

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 rust-lang#153035 which does something similar for PowerPC, and [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/De-spaghettifying.20ABI.20controls/with/575095372). Happy to delay this PR if someone has a better idea.

Cc @folkertdev @workingjubilee
rust-bors bot pushed a commit that referenced this pull request Mar 3, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #151864 (Implement AST -> HIR generics propagation in delegation)
 - #152941 (prefer actual ABI-controling fields over target.abi when making ABI decisions)
 - #153227 (Don’t report missing fields in struct exprs with syntax errors.)
 - #152966 (Migrate 11 tests from tests/ui/issues to specific directories)
 - #153003 (rustdoc: make `--emit` and `--out-dir` mimic rustc)
 - #153034 (Remove unhelpful hint from trivial bound errors)
 - #153221 (Add release notes for 1.94.0)
 - #153297 (Update the name of the Hermit operating system)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 3, 2026
prefer actual ABI-controling fields over target.abi when making ABI decisions

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 rust-lang#153035 which does something similar for PowerPC, and [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/De-spaghettifying.20ABI.20controls/with/575095372). Happy to delay this PR if someone has a better idea.

Cc @folkertdev @workingjubilee
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 3, 2026
prefer actual ABI-controling fields over target.abi when making ABI decisions

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 rust-lang#153035 which does something similar for PowerPC, and [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/De-spaghettifying.20ABI.20controls/with/575095372). Happy to delay this PR if someone has a better idea.

Cc @folkertdev @workingjubilee
rust-bors bot pushed a commit that referenced this pull request Mar 3, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152941 (prefer actual ABI-controling fields over target.abi when making ABI decisions)
 - #153227 (Don’t report missing fields in struct exprs with syntax errors.)
 - #153265 (Clarified doc comments + added tests confirming current behavior for intersperse/intersperse_with)
 - #152966 (Migrate 11 tests from tests/ui/issues to specific directories)
 - #153003 (rustdoc: make `--emit` and `--out-dir` mimic rustc)
 - #153034 (Remove unhelpful hint from trivial bound errors)
 - #153152 (Migration of LintDiagnostic - part 5)
 - #153177 (disable the ptr_fragment_in_final test on s390x)
 - #153221 (Add release notes for 1.94.0)
 - #153279 (feat: Provide an '.item_kind()' method on ItemEnum)
 - #153297 (Update the name of the Hermit operating system)
 - #153309 (Cleanup of c-variadic link test)
@RalfJung
Copy link
Member Author

RalfJung commented Mar 3, 2026

You mean voiced here? As indicated in my reply, I'm not sure how that's supposed to fully replace rustc_abi.

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-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