Skip to content

riscv: allow querying 'd' and 'f' target features - #161385

Open
RalfJung wants to merge 2 commits into
rust-lang:mainfrom
RalfJung:riscv-d-f
Open

riscv: allow querying 'd' and 'f' target features#161385
RalfJung wants to merge 2 commits into
rust-lang:mainfrom
RalfJung:riscv-d-f

Conversation

@RalfJung

@RalfJung RalfJung commented Aug 20, 2026

Copy link
Copy Markdown
Member

#156188 has been reverted in #161064 due to concerns about "e" being a negative target feature.

"d" and "f" however are almost normal target features, so let's re-land them.
The one thing that's odd about them is that we cannot allow you to use -Ctarget-feature or #[target_feature] for them on some riscv ABIs. (For now, it remains unstable on all riscv ABIs.) So this means we need the concept of target-features that are fixed by the target spec and cannot be changed by the user. OTOH we kind of already have that, even for fully stable target features:

  • On x86-64, we don't let people disable "sse2". On aarch64, we don't let people disable "neon".
  • Soon, on x86-64 softfloat, we don't let people enable "sse2".

"neon" and "sse2" are even stable target features. With this PR, "d" and "f" remain unstable to toggle; if we ever stabilize them then the rules would be

  • on riscv targets that use a "d" ABI (ilp32d, lp64d), you can't disable either of them
  • on riscv targets that use an "f" ABI (ilp32f, lp64f), you can't disable "f"
  • on riscv ilp32e targets, you can't enable "d"

@rust-lang/lang you already FPC'd this in #156188; please let me know if you want another FCP or if we can just re-land this. Also see below for a proposal to just fully stabilize these target features.

Cc @romancardenas

@rustbot rustbot added 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 20, 2026
@rustbot

rustbot commented Aug 20, 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 75 candidates
  • Random selection from 17 candidates

@RalfJung RalfJung added I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-t-lang Status: Awaiting decision from T-lang labels Aug 20, 2026
@beetrees

Copy link
Copy Markdown
Contributor

I think it would be worth including the cfg-stable-toggle-unstable-* tests from the original PR (#156188).

@beetrees

beetrees commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

EDIT: Never mind, just remembered ILP32E.

@RalfJung

Copy link
Copy Markdown
Member Author

Ah, right. I should probably cherry-pick the original commit and then remove the "e" part.

@traviscross traviscross added T-lang Relevant to the language team P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels Aug 20, 2026
@RalfJung

RalfJung commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

@workingjubilee pointed out that we already have some fully stable target features that can't be toggled:

  • On x86-64, we don't let people disable "sse2". On aarch64, we don't let people disable "neon".
  • Soon, on x86-64 softfloat, we don't let people enable "sse2".

So... should we just fully stabilize "d" and "f", i.e. also for use in -Ctarget-feature and #[target_feature]? The rules as currently implemented would be

  • on riscv targets that use a "d" ABI (ilp32d, lp64d), neither "f" nor "d" can be disabled
  • on riscv targets that use an "f" ABI (ilp32f, lp64f), you can't disable "f"
  • on riscv ilp32e targets, you can't enable "d"

Cc @Amanieu @ZhongyaoChen @CaiWeiran @kito-cheng @michaelmaitland @robin-randhawa-sifive @topperc @sanchuanhehe @almindor @rmsyn

@almindor almindor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@sanchuanhehe sanchuanhehe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@workingjubilee

workingjubilee commented Aug 22, 2026

Copy link
Copy Markdown
Member

Making "d" and "f" fully stable feels like a big "shrug?" to me. I can't think of an enormously strong motivation or, er, demotivation, given that we have to apply restrictions anyways. But unlike with "e", where I'm uncertain about the entire idea of the feature per se, it seems acceptable if unexciting to allow it to join the peculiar ranks of "sse2" and "neon".

Though I also didn't remember that ilp32e works with F and not just that specialist set of target features for, I think, floating point in integer registers, that are mutually-exclusive with F. I guess either way is plausible, at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-t-lang Status: Awaiting decision from T-lang T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants