Skip to content

rustc_codegen_llvm: handle LLVM 24 ABI constraints - #162783

Open
durin42 wants to merge 1 commit into
rust-lang:mainfrom
durin42:llvm-24-riscv-hardfloat
Open

durin42 wants to merge 1 commit into
rust-lang:mainfrom
durin42:llvm-24-riscv-hardfloat

Conversation

@durin42

@durin42 durin42 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

LLVM 24 is pickier about things like hard-float being disabled but the compiled module ABI mentioning hard-float. As an example, if the user specifies target-features=-d to disable the d extension but the declared target-abi is lp64d that's now an error where before I guess it was a warning.

This fix seems somewhat inelegant, but in the name of keeping the behavior changes minimal I did gate the new behavior to only happen on LLVM 24. I'm very open to alternative solutions!

An LLM was used to identify the breaking commit and help me sort out why the commit was breaking.

@rustbot label: +llvm-main

LLVM 24 is pickier about things like hard-float being disabled but
the compiled module ABI mentioning hard-float. As an example, if the
user specifies target-features=-d to disable the d extension but the
declared target-abi is lp64d that's now an error where before I guess it
was a warning.

This fix seems somewhat inelegant, but in the name of keeping the
behavior changes minimal I did gate the new behavior to only happen on
LLVM 24. I'm very open to alternative solutions!

An LLM was used to identify the breaking commit and help me sort out
_why_ the commit was breaking.
@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 Sep 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
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 76 candidates
  • Random selection from 18 candidates

@rustbot rustbot added the llvm-main Marks PRs that are making Rust work with LLVM main (this label is consumed by CI tooling) label Sep 14, 2026
@arichardson

Copy link
Copy Markdown
Contributor

Apologies for this breakage. My change was intended to buy NFC but apparently there is no test coverage for this. While longer term this should probably be an error it's definitely not supposed to cause churn for downstreams.

@arichardson

Copy link
Copy Markdown
Contributor

It does seem like this change is an improvement regardless of whether my commit is reverted or not so it definitely LGTM from a functional point. Not a rust expert so can't comment on style or anything else.

@beetrees

beetrees commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

rustc has generally been moving towards emitting hard errors when target features required by the ABI aren't enabled (e.g. #161280), so changing the target ABI we pass to LLVM seems like the wrong solution. Instead we should add RISC-V to the hard error ABI feature check.

cc @RalfJung

@RalfJung

RalfJung commented Sep 15, 2026

Copy link
Copy Markdown
Member

Agreed, the proposed behavior in this PR is IMO a very bad idea. It's basically re-introducing the broken LLVM behavior that LLVM finally fixed, of silently changing the ABI. We should never silently change the ABI, that's plain unsound.

Instead we should add RISC-V to the hard error ABI feature check.

Agreed. This matches #161280.

@RalfJung

RalfJung commented Sep 15, 2026

Copy link
Copy Markdown
Member

Apologies for this breakage. My change was intended to buy NFC but apparently there is no test coverage for this. While longer term this should probably be an error it's definitely not supposed to cause churn for downstreams.

No need to apologize, I am very happy that LLVM is finally moving towards actually complaining about nonsensical ABI requests from the frontend, rather than silently doing something arbitrary. :)

llvm/llvm-project#111334 deliberately introduced such errors for the ARM backend. I'd love for RISCV and all the other backends to do the same.

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. llvm-main Marks PRs that are making Rust work with LLVM main (this label is consumed by CI tooling) 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