Skip to content

Conversation

@a4lg
Copy link
Contributor

@a4lg a4lg commented Aug 28, 2025

This commit stabilizes RISC-V target features with following constraints:

  • Describes a ratified extension.
  • Implemented on Rust 1.88.0 or before.
    Waiting for four+ version cycles seems sufficient.
  • Does not disrupt current rustc's target feature (cf. Need comprehensive story for target_feature compat #140570) + ABI (cf. Some -Ctarget-features must be restrained on RISCV #132618) handling.
    It excludes E and all floating point-arithmetic extensions. The Zfinx family does not involve floating point registers but not stabilizing for now to avoid possible confusion between the F extension family.
  • Not vector-related (floating point and integer).
    While integer vector subsets should not cause any ABI issues (as they don't use ABI-dependent floating point registers), we need to discuss before stabilizing them.
  • Supported by the lowest LLVM version supported by rustc (LLVM 20).

List of target features to be stabilized:

  1. b
  2. za64rs (no-RT)
  3. za128rs (no-RT)
  4. zaamo
  5. zabha
  6. zacas
  7. zalrsc
  8. zama16b (no-RT)
  9. zawrs
  10. zca
  11. zcb
  12. zcmop
  13. zic64b (no-RT)
  14. zicbom
  15. zicbop (no-RT)
  16. zicboz
  17. ziccamoa (no-RT)
  18. ziccif (no-RT)
  19. zicclsm (no-RT)
  20. ziccrse (no-RT)
  21. zicntr
  22. zicond
  23. zicsr
  24. zifencei
  25. zihintntl
  26. zihintpause
  27. zihpm
  28. zimop
  29. ztso

Of which, 20 of them (29 minus 9 "no-RT" target features) support runtime detection through std::arch::is_riscv_feature_detected!().

Corresponding PR for the Reference: rust-lang/reference#1987


Description in older revision(s)

  • Not vector-related (including not FP-related ones).
    No ABI issues will not occur unless floating point registers are involved. But for integer-only vector ones, we'll be stabilizing in another time.

The original text is rewritten to avoid confusion as per @RalfJung's request.

Of which, 19 of them support runtime detection through std_detect.

This is rewritten to correlate this PR with a public API (instead of an internal crate).

r? @Amanieu
@rustbot label +O-riscv

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 28, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@rustbot rustbot added the O-riscv Target: RISC-V architecture label Aug 28, 2025
@a4lg
Copy link
Contributor Author

a4lg commented Aug 28, 2025

I expect that this PR lands on the version 1.92 cycle (I chose extensions with relatively low risk factors) but happy if it could be merged in the version 1.91 cycle.

@Amanieu Amanieu added T-lang Relevant to the language team I-libs-api-nominated Nominated for discussion during a libs-api team meeting. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. I-libs-api-nominated Nominated for discussion during a libs-api team meeting. labels Aug 29, 2025
@Amanieu
Copy link
Member

Amanieu commented Aug 29, 2025

LGTM, these are all officially ratified RISC-V extensions.

@rfcbot merge

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Aug 29, 2025

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Aug 29, 2025
@traviscross traviscross added I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang S-waiting-on-documentation Status: Waiting on approved PRs to documentation before merging I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels Aug 29, 2025
@traviscross
Copy link
Contributor

We'll need a PR to the Reference submitted and accepted ahead of this being merged.

@rfcbot reviewed

cc @rust-lang/lang-docs @RalfJung

@a4lg
Copy link
Contributor Author

a4lg commented Aug 30, 2025

Consideration: Feature Naming (for std_detect)

The only initial intent of riscv_ratified_v2 (which feels a bit blunt) was to avoid crashing with existing riscv_ratified1 and later noticed that x86 uses various feature names on stabilization.

I considered the similar after the initial submission but didn't for several reasons:

  1. Many extensions to be stabilized are general purpose (even some of them are split from an early version of the I base ISA) and clear distinction will confuse the users between plain riscv_ratified (it's just a collection of extensions where runtime detection of them is stabilized in Rust 1.78.0 and contains rich extensions like scalar cryptography).
  2. Considering future extensions to be stabilized in Rust and the history (some RISC-V extensions are split from others and semantic naming may not work in the near future), either of them seems inevitable:
    1. Using the extension name itself or similar or
    2. Using blunt version schemes like in this PR.

After consideration, I prefer blunt naming scheme (pure versioning regardless of the category) for runtime detection of RISC-V extensions.

Consideration: Deferring to Version 1.92 Cycle may Have its Benefit

Although I'll rush for the version 1.91 cycle if possible, I have to say that deferring this might be an option.

I'm talking about #145071, which raises the minimum LLVM version to 20. After this PR is merged, I think we can safely introduce the Zacas extension without riscv_ratified_v3 (I excluded Zacas from this PR because of this minimum LLVM version issue).

So, if we don't make it to the version 1.91 cycle, waiting for #145071 might be an option.

Footnotes

  1. The same feature name does not allow multiple stabilized versions.

a4lg added a commit to a4lg/rust-reference that referenced this pull request Aug 30, 2025
The `Zb` extension does not exist and we instead have the `B` extension
which is a superset of the three subextensions: `Zba`, `Zbb` and `Zbs`.

This commit fixes this issue and updates the reference URL to the source
code of the latest ratified ISA Manual (version 20250508).

To align with rust-lang/rust#145948,
this commit performs rename, not removal.
a4lg added a commit to a4lg/rust-reference that referenced this pull request Aug 30, 2025
Because unstable "B" (incorrectly named as `zb`) was there, this commit
adds 28 minus one ("B") new extensions to be stabilized.

This commit directly corresponds to rust-lang/rust#145948.

References:

1.  RISC-V Instruction Set Manual (version 20250508):
    <https://github.com/riscv/riscv-isa-manual/tree/20250508>
2.  RISC-V Profiles (version 1.0 - RVA23 is not stabilized at the time):
    <https://github.com/riscv/riscv-profiles/tree/v1.0>
3.  RISC-V Profiles (RVA23/RVB23-ratified version):
    <https://github.com/riscv/riscv-profiles/tree/rva23-rvb23-ratified>
a4lg added a commit to a4lg/rust-reference that referenced this pull request Aug 30, 2025
The `Zb` extension does not exist and we instead have the `B` extension
which is a superset of the three subextensions: `Zba`, `Zbb` and `Zbs`.

This commit fixes this issue and updates the reference URL to the source
code of the latest ratified ISA Manual (version 20250508).

To align with rust-lang/rust#145948,
this commit performs rename, not removal.
a4lg added a commit to a4lg/rust-reference that referenced this pull request Aug 30, 2025
Because unstable "B" (incorrectly named as `zb`) was there, this commit
adds 28 minus one ("B") new extensions to be stabilized.

This commit directly corresponds to rust-lang/rust#145948.

References:

1.  RISC-V Instruction Set Manual (version 20250508):
    <https://github.com/riscv/riscv-isa-manual/tree/20250508>
2.  RISC-V Profiles (version 1.0 - RVA23 is not stabilized at the time):
    <https://github.com/riscv/riscv-profiles/tree/v1.0>
3.  RISC-V Profiles (RVA23/RVB23-ratified version):
    <https://github.com/riscv/riscv-profiles/tree/rva23-rvb23-ratified>
a4lg added a commit to a4lg/rust-reference that referenced this pull request Aug 30, 2025
The `Zb` extension does not exist and we instead have the `B` extension
which is a superset of the three subextensions: `Zba`, `Zbb` and `Zbs`.

This commit fixes this issue and updates the reference URL to the source
code of the latest ratified ISA Manual (version 20250508).

To align with rust-lang/rust#145948,
this commit performs rename, not removal.
a4lg added a commit to a4lg/rust-reference that referenced this pull request Aug 30, 2025
Because unstable "B" (incorrectly named as `zb`) was there, this commit
adds 28 minus one ("B") new extensions to be stabilized.

This commit directly corresponds to rust-lang/rust#145948.

References:

1.  RISC-V Instruction Set Manual (version 20250508):
    <https://github.com/riscv/riscv-isa-manual/tree/20250508>
2.  RISC-V Profiles (version 1.0 - RVA23 is not stabilized at the time):
    <https://github.com/riscv/riscv-profiles/tree/v1.0>
3.  RISC-V Profiles (RVA23/RVB23-ratified version):
    <https://github.com/riscv/riscv-profiles/tree/rva23-rvb23-ratified>
@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Oct 22, 2025
@pthariensflame
Copy link
Contributor

So…the idea was to wait for the 1.92 cycle. But now we're on the 1.94 cycle. Any plans?

@RalfJung
Copy link
Member

This is currently waiting for a checkbox by @BurntSushi, @scottmcm, or @the8472.

@RalfJung
Copy link
Member

Also Cc @kito-cheng @michaelmaitland @robin-randhawa-sifive @topperc as Risc-V target maintainers, to double-check that these target features are safe to stabilize, in particular from an ABI perspective. :)

@traviscross traviscross added the I-lang-nominated Nominated for discussion during a lang team meeting. label Dec 12, 2025
@topperc
Copy link

topperc commented Dec 12, 2025

Also Cc @kito-cheng @michaelmaitland @robin-randhawa-sifive @topperc as Risc-V target maintainers, to double-check that these target features are safe to stabilize, in particular from an ABI perspective. :)

The list looks good to me.

@traviscross traviscross added the P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang label Dec 17, 2025
@rust-rfcbot rust-rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Dec 17, 2025
@rust-rfcbot
Copy link
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Dec 17, 2025
@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Dec 18, 2025
@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Dec 27, 2025
@rust-rfcbot
Copy link
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@Amanieu
Copy link
Member

Amanieu commented Jan 3, 2026

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 3, 2026

📌 Commit 316a79f has been approved by Amanieu

It is now in the queue for this repository.

@bors bors 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 Jan 3, 2026
@bors
Copy link
Collaborator

bors commented Jan 3, 2026

⌛ Testing commit 316a79f with merge 00f49d2...

@bors
Copy link
Collaborator

bors commented Jan 3, 2026

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing 00f49d2 to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 3, 2026
@bors bors merged commit 00f49d2 into rust-lang:main Jan 3, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 50d5940 (parent) -> 00f49d2 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 00f49d22042dce59561b36eb075bbf5e343c23c4 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 3339.0s -> 4285.0s (+28.3%)
  2. aarch64-gnu-llvm-20-1: 3558.7s -> 4070.3s (+14.4%)
  3. dist-aarch64-msvc: 5569.5s -> 6358.1s (+14.2%)
  4. dist-aarch64-llvm-mingw: 5821.1s -> 6594.4s (+13.3%)
  5. dist-x86_64-illumos: 5804.8s -> 6331.2s (+9.1%)
  6. x86_64-msvc-ext1: 7163.4s -> 7719.8s (+7.8%)
  7. test-various: 7468.3s -> 6930.1s (-7.2%)
  8. i686-gnu-nopt-2: 8091.8s -> 7509.1s (-7.2%)
  9. dist-aarch64-linux: 6716.8s -> 6251.9s (-6.9%)
  10. x86_64-gnu-llvm-21-1: 4476.1s -> 4173.4s (-6.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (00f49d2): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary 3.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.2% [3.2%, 3.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 470.889s -> 472.503s (0.34%)
Artifact size: 390.82 MiB -> 390.81 MiB (-0.00%)

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. merged-by-bors This PR was explicitly merged by bors. O-riscv Target: RISC-V architecture S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-documentation Status: Waiting on approved PRs to documentation before merging T-lang Relevant to the language team T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.