Commit Graph

69 Commits

Author SHA1 Message Date
patrikas-sestokas
eb3bf33322 Fix asimd/neon detection on aarch64-darwin
'hw.optional.AdvSIMD' sysctl key doesn't resolve on macOS 26.5.1 and 26.6,
breaking `asimd` and `sha2`/`sha3` downstream.

Now `asimd` is determined by checking 'hw.optional.AdvSIMD' || 'hw.optional.arm.AdvSIMD' to support old and new envs.
2026-08-13 02:48:15 +03:00
Jacob Pratt
9f20455d74 Rollup merge of #152439 - him2him2:fix-typos-libs, r=clarfonthey
Fix typos and grammar in library documentation

Fix contextual typos and grammar issues in library docs that automated spellcheckers miss:

- `library/core/src/macros/panic.md`: remove duplicate word ("another other" → "another")
- `library/core/src/error.md`: fix spacing ("Often times" → "Oftentimes")
- `library/core/src/ptr/docs/as_ref.md`: fix wrong types in Null-unchecked section (`&mut T` → `&T`)
- `library/core/src/ffi/c_ulong.md`: fix article ("an `u64`" → "a `u64`")
- `library/core/src/ffi/c_void.md`: fix plural ("compiler" → "compilers")
- `library/core/src/ptr/docs/as_uninit_slice.md`: fix subject-verb agreement ("is true" → "are true")
- `library/std_detect/README.md`: fix article ("an user-space" → "a user-space")

No functional changes.
2026-07-26 00:21:49 -04:00
Jonathan Brouwer
1b823bd424 Rollup merge of #159188 - Kobzol:rustdoc-json-private, r=Mark-Simulacrum
Always generate private and hidden items in JSON docs of the stdlib

This data is needed for downstream tools, e.g. cargo-semver-checks, to analyse the whole stdlib.

For the HTML output it is configurable using `build.library-docs-private-items`, but to avoid adding a separate config for just the JSON format, I think that we can just enable it unconditionally.

An alternative would be to change the flag from a bool to something like
```rust
enum StdDocsPrivateItems {
    No,
    Yes,
    Html,
    Json
}
```
2026-07-19 23:26:24 +02:00
Jakub Beránek
c84d862635 Fix documentation in stdarch 2026-07-19 10:23:59 +02:00
Jonathan Brouwer
ac05d382c9 Rollup merge of #159222 - joshtriplett:main, r=petrochenkov
semicolon_in_expressions_from_macros: Lint on non-local macros too

The `semicolon_in_expressions_from_macros` lint previously suppressed
warnings about non-local macros. This masks a lint that will
subsequently become a hard error.

Stop suppressing it, dropping the `is_local` flag and check.

Fix the test for this case to now expect the error. Drop a separate test
that depended on the lack of error (and that specifically notes it
should be dropped once the lint becomes a hard error).
2026-07-15 16:17:09 +02:00
Krasimir Georgiev
1a56799fef cleanup: upstream dropped AMX-TF32
Co-authored-by: Gwen Mittertreiner <gmtr@google.com>
2026-07-14 15:04:41 -07:00
Josh Triplett
aa53feef9a std_detect: Eliminate incorrect symlink in macro arm
The macro is used in expressions, but the arm for eliminating a trailing
comma introduces a semicolon.
2026-07-13 14:54:42 -07:00
Josh Stone
ad2ea99740 Replace version placeholders with 1.97.0
(cherry picked from commit 54bca41297a0a7527f521675debe733efa224ae3)
2026-05-31 06:56:01 -07:00
Jarrod Petz
1c3a69a6e4 Detect clflushopt in is_x86_feature_detected!
Wire up runtime detection for the `clflushopt` feature: add it to the
`is_x86_feature_detected!` feature list (gated on `clflushopt_target_feature`),
enable it from CPUID leaf 7 EBX bit 23, and add it to the std_detect
x86-specific dump test.
2026-05-29 21:08:11 +10:00
Jonathan Brouwer
4b21499e14 Rollup merge of #155856 - imazen:winarm-stable-features, r=Amanieu
std_detect: support detecting more features on aarch64 Windows

Wires `IsProcessorFeaturePresent` calls for the `PF_ARM_*` constants exposed in Windows SDK 26100 (Windows 11 24H2), plus an architectural derivation for `rdm`. All eight feature names have been stable in `is_aarch64_feature_detected!` on Linux/Darwin/BSD since Rust 1.60 — this brings the Windows backend to parity.

| Feature | Source on Windows |
|---|---|
| `fp16`  | `PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE`  (value 67) |
| `i8mm`  | `PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE`  (value 66) |
| `bf16`  | `PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE`  (value 68) |
| `sha3`  | `PF_ARM_SHA3` (value 64) **AND** `PF_ARM_SHA512` (value 65) |
| `lse2`  | `PF_ARM_LSE2_AVAILABLE`                   (value 62) |
| `f32mm` | `PF_ARM_SVE_F32MM_INSTRUCTIONS_AVAILABLE` (value 58) |
| `f64mm` | `PF_ARM_SVE_F64MM_INSTRUCTIONS_AVAILABLE` (value 59) |
| `rdm`   | derived from `PF_ARM_V82_DP` (see below) |

`PF_ARM_SVE_F32MM` / `PF_ARM_SVE_F64MM` (values 58 / 59) were already added as commented-out placeholders in rust-lang/stdarch#1749 — they have direct stable Feature mappings (`f32mm`, `f64mm`), unlike their sibling values 52 / 53 / 57 (`SVE_BF16`, `SVE_EBF16`, `SVE_I8MM`) which have no SVE-specific stdarch Feature name and remain commented for that reason.

`sha3` requires both `PF_ARM_SHA3` (FEAT_SHA3) and `PF_ARM_SHA512` (FEAT_SHA512), matching the existing convention from rust-lang/stdarch#1749 where `sve2-aes` is set only when both `PF_ARM_SVE_AES` and `PF_ARM_SVE_PMULL128` are present.

### `rdm` derivation

There is no `PF_ARM_RDM_*` constant; Microsoft has never defined one. We derive it from `PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE` (FEAT_DotProd) via the following architectural chain:

1. FEAT_DotProd is an optional v8.2-A feature, so its presence implies the core implements at least v8.1-A.
2. Per Arm ARM K.a §D17.2.91: *"In an ARMv8.1 implementation, if FEAT_AdvSIMD is implemented, FEAT_RDM is implemented."*
3. AdvSIMD is universally implemented on every Windows-on-ARM SKU.
4. Therefore: DotProd ⇒ v8.1-A baseline + AdvSIMD ⇒ FEAT_RDM.

This is the same derivation .NET 10 uses, with comment cited verbatim ([dotnet/runtime PR 109493](https://github.com/dotnet/runtime/pull/109493), shipped in v10.0.0 at [`src/native/minipal/cpufeatures.c`](https://github.com/dotnet/runtime/blob/v10.0.0/src/native/minipal/cpufeatures.c)):

> *"IsProcessorFeaturePresent does not have a dedicated flag for RDM, so we enable it by implication.
> 1) DP is an optional instruction set for Armv8.2, which may be included only in processors implementing at least Armv8.1.
> 2) Armv8.1 requires RDM when AdvSIMD is implemented, and AdvSIMD is a baseline requirement of .NET.
> Therefore, by documented standard, DP cannot exist here without RDM. In practice, there is only one CPU supported by Windows that includes RDM without DP, so this implication also has little practical chance of a false negative."*

The "one CPU with RDM without DP" trade-off applies equally to us: we accept a possible false negative on that single SKU rather than introducing a more aggressive heuristic.

### Tests

Adds `println!` lines to the existing `aarch64_windows()` test in `library/std_detect/tests/cpu-detection.rs` for each newly-detected feature, mirroring the existing single-line pattern. No structural assertions added.

### Scope

Stable feature names only. The unstable SME family (`sme`, `sme2`, `sme2p1`, `sme_*`, `ssve_fp8*`) and other unstable additions tracked under rust-lang/rust#127764 are intentionally out of scope here to keep this PR minimal — happy to do a follow-up.

### References

- Tracking issue: rust-lang/rust#127764 (`stdarch_aarch64_feature_detection`)
- Precedent: rust-lang/stdarch#1749 (taiki-e, merged 2025-03-24) — added the SVE constants this builds on
- MS docs: [`IsProcessorFeaturePresent`](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent) — full PF_ARM_* table

r? @Amanieu

cc @taiki-e (author of rust-lang/stdarch#1749, would appreciate your eyes on the `rdm` inference)

@rustbot label +T-libs +O-windows +O-ARM
2026-04-29 23:51:34 +02:00
Jonathan Brouwer
e8243d2979 Rollup merge of #154510 - heiher:stabilize-loongarch-target-features, r=Amanieu
Partially stabilize LoongArch target features

This PR stabilizes the following target features:

- div32
- lam-bh
- lamcas
- ld-seq-sa
- scq

Docs PR: https://github.com/rust-lang/reference/pull/2217

r? @Amanieu
2026-04-27 19:54:43 +02:00
Lilith River
f0a751d726 std_detect: support detecting more features on aarch64 Windows
Wire IsProcessorFeaturePresent for the PF_ARM_* constants exposed in
Windows SDK 26100 (Win11 24H2):

  fp16   PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE  (67)
  i8mm   PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE  (66)
  bf16   PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE  (68)
  sha3   PF_ARM_SHA3 (64) AND PF_ARM_SHA512 (65)
  lse2   PF_ARM_LSE2_AVAILABLE                   (62)
  f32mm  PF_ARM_SVE_F32MM_INSTRUCTIONS_AVAILABLE (58)
  f64mm  PF_ARM_SVE_F64MM_INSTRUCTIONS_AVAILABLE (59)

Also derive `rdm` from FEAT_DotProd. There is no PF_ARM_RDM_* constant;
FEAT_DotProd is an optional v8.2-A feature only present on cores that
implement at least v8.1-A, and v8.1-A with AdvSIMD mandates FEAT_RDM
(Arm ARM K.a §D17.2.91). AdvSIMD is universal on Windows-on-ARM. See
PR description for full rationale and .NET 10 precedent.

All eight feature names have been stable in `is_aarch64_feature_detected!`
on Linux/Darwin/BSD since Rust 1.60.
2026-04-27 01:54:43 -06:00
Laine Taffin Altman
1f17857123 std_detect on AArch64 Darwin: Detect FEAT_SVE_B16B16
This is now exposed via `sysctl` as of macOS "Tahoe" 26.4 (or possibly earlier).
2026-03-27 17:24:27 -07:00
WANG Rui
d3a782dfab Partially stabilize LoongArch target features
This PR stabilizes the following target features:

- div32
- lam-bh
- lamcas
- ld-seq-sa
- scq
2026-03-27 17:15:27 +08:00
sayantn
db18ecf263 Require avxvnni for avx10.2 2026-02-25 06:50:39 +05:30
Folkert de Vries
14d29f9ae2 Stabilize cfg_select 2026-02-22 19:59:25 +01:00
mu001999
73c42c1800 Remove or allow unused features in library doc and tests 2026-02-13 09:27:16 +08:00
ron
1a43039e4d Fix typos and grammar in library documentation
- library/core/src/macros/panic.md: remove duplicate word ("another other" → "another")
- library/core/src/error.md: fix spacing ("Often times" → "Oftentimes")
- library/core/src/ptr/docs/as_ref.md: fix wrong types in Null-unchecked section (&mut T → &T)
- library/core/src/ffi/c_ulong.md: fix article ("an u64" → "a u64")
- library/core/src/ffi/c_void.md: fix plural ("old Rust compiler" → "old Rust compilers")
- library/core/src/ptr/docs/as_uninit_slice.md: fix subject-verb agreement ("is true" → "are true")
- library/std_detect/README.md: fix article ("an user-space" → "a user-space")
2026-02-10 10:21:46 -05:00
Mark Rousskov
bc611ce5f1 Replace version placeholders with 1.94 2026-01-20 21:17:10 -05:00
bjorn3
c873d16323 Remove unnecessary module 2026-01-08 15:02:42 +00:00
bjorn3
3fed6e67ef Remove a couple of outdated fields in std_detect Cargo.toml
It is no longer a part of the stdarch repo and the rest is not necessary
anymore due to no longer publishing to crates.io.
2026-01-08 14:50:12 +00:00
bjorn3
665770ec84 Remove std_detect_file_io and std_detect_dlsym_getauxval features
They were introduced back when std_detect was a standalone crate
published to crates.io. The motivation for std_detect_dlsym_getauxval
was to allow using getauxval without dlopen when statically linking
musl, which we now unconditionally do for musl. And for
std_detect_file_io to allow no_std usage, which std_detect now supports
even with that feature enabled as it directly uses libc. This also
prevents accidentally disabling runtime feature detection when using
cargo build -Zbuild-std -Zbuild-std-features=
2026-01-08 14:50:12 +00:00
bors
00f49d2204 Auto merge of #145948 - a4lg:riscv-stabilize-target-features-v2, r=Amanieu
Stabilize 29 RISC-V target features (`riscv_ratified_v2`)

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. rust-lang/rust#140570) + ABI (cf. rust-lang/rust#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
2026-01-03 07:26:35 +00:00
Jonathan Brouwer
71b17c5c18 Rollup merge of #150264 - RalfJung:target-feature-tracking-split, r=Amanieu
split up tracking issue for target feature feature gates

https://github.com/rust-lang/rust/issues/44839 is tracking too many things at once. We usually have a separate tracking issue for each feature gate, so let's do that here as well:

-  rust-lang/rust#150244
- rust-lang/rust#150245
- rust-lang/rust#150246
- rust-lang/rust#150247
- rust-lang/rust#150248
- rust-lang/rust#150249
- rust-lang/rust#150250
- rust-lang/rust#150251
- rust-lang/rust#150252
- rust-lang/rust#150253
- rust-lang/rust#150254
- rust-lang/rust#150255
- rust-lang/rust#150256
- rust-lang/rust#150257
- rust-lang/rust#150258
- rust-lang/rust#150259
- rust-lang/rust#150260
- rust-lang/rust#150261

Closes https://github.com/rust-lang/rust/issues/44839 in favor of the ones listed above.

r? `@Amanieu`
2026-01-01 02:47:20 +01:00
bors
2e854a9344 Auto merge of #150357 - ZuseZ4:zusez4-stdarch-push, r=sayantan
stdarch subtree update

Subtree update of `stdarch` to 61119062fb.

Created using https://github.com/rust-lang/josh-sync.

r? `@sayantn`

My first josh sync, it lgtm, but let me know if I missed something.
I'm especially looking forward to the amd GPU module, which we want to use for the offload project.
2025-12-26 10:44:27 +00:00
Manuel Drehwald
6f06d386b8 cpuid is safe since the stdarch sync, so remove unsafe from usages 2025-12-26 08:46:49 +01:00
Ralf Jung
a8e5693797 split up tracking issue for target feature feature gates 2025-12-22 13:29:11 +01:00
Boxy Uwu
90a33f69f4 replace version placeholder 2025-12-19 15:04:30 -08:00
Laine Taffin Altman
8d37589f37 std_detect: AArch64 Darwin: expose SME F16F16 and B16B16 features
This synchronizes the list with the current state of `sysctl` on macOS “Tahoe” 26.2.


r? @Amanieu
2025-12-15 22:08:00 -08:00
Matthew Maurer
17230eb5bb rustc_target: aarch64: Remove deprecated FEAT_TME
ARM has withdrawn FEAT_TME

https://developer.arm.com/documentation/102105/lb-05/

LLVM has dropped support for it recently as a result.
2025-11-25 00:43:01 +00:00
Folkert de Vries
ac3faf0cae fix incorrect import on aarch64-unknown-openbsd 2025-11-13 18:31:14 +01:00
Matthias Krüger
da171df13c Rollup merge of #147024 - brad0:std_detect_openbsd_elf_aux_info, r=Mark-Simulacrum
std_detect: Support run-time detection on OpenBSD using elf_aux_info
2025-11-08 15:42:20 +01:00
Folkert de Vries
7516645928 stabilize s390x_target_feature_vector 2025-11-06 12:49:48 +01:00
Folkert de Vries
c59298da36 stabilize stdarch_s390x_feature_detection 2025-11-06 12:49:46 +01:00
Folkert de Vries
02e4db5cc6 std_detect: give s390x features more accurate features / tracking issues 2025-11-06 12:49:04 +01:00
Folkert de Vries
d69442fe9c std_detect: remove unneeded stability lines from s390x features macro 2025-11-06 12:49:04 +01:00
Stuart Cook
c9ca719218 Rollup merge of #147586 - folkertdev:std-detect-expands-to-true, r=Amanieu
std-detect: improve detect macro docs

Specifically, document that the detect macros expand to `true` when the feature is statically enabled.

Now that we have a bunch of these macros, perhaps we should streamline further how they are documented?

r? ``@Amanieu``
2025-11-06 14:07:16 +11:00
Brad Smith
cb0a705581 std_detect: Support run-time detection on OpenBSD using elf_aux_info 2025-11-02 15:11:25 -05:00
Augie Fackler
efb9a41f0e cleanup: upstream dropped amx-transpose functionality
See also LLVM change 5322fb626820. Looks like this was
just removed entirely.
2025-10-31 13:48:05 -04:00
Folkert de Vries
bc911c2cdd std-detect: improve detect macro docs
document that the detect macros expand to `true` when the feature is statically enabled
2025-10-16 11:03:22 +02:00
Tsukasa OI
316a79f432 Stabilize 29 RISC-V target features (riscv_ratified_v2)
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 + ABI handling.
    It excludes "E" and all floating point-arithmetic extensions.
    "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!()`.
2025-09-17 10:54:02 +00:00
Laine Taffin Altman
d49f6a789f std_detect Darwin AArch64: synchronize features
Brings the list of checkable features up to date with the initial release of macOS 26 "Tahoe".
2025-09-13 23:29:55 -07:00
Laine Taffin Altman
edc87e301b std_detect Darwin AArch64: re-alphabetize 2025-09-13 23:25:30 -07:00
Laine Taffin Altman
d8cc5757ba std_detect Darwin AArch64: add new-style detection for FEAT_CRC32
Now that this feature has a standard identifier, Darwin has started exposing it accordingly, in addition to the existing less-standard way.  Check both, and enable the `crc` feature if either identifier for it is present to ensure backwards and forwards compatibility.
2025-09-13 23:25:29 -07:00
Fang He
4c849c73a4 fix typo in comment 2025-09-12 08:18:26 +08:00
Fang He
de359c569b fix typos in comment 2025-09-08 18:48:19 +08:00
Fang He
be284b697f add some comments to clarify the fix 2025-09-08 18:39:39 +08:00
Fang He
c776fbf1eb check before test for hardware capabilites in bits 32~63 of usize 2025-09-08 16:35:03 +08:00
Jacob Pratt
03aa3b8489 Rollup merge of #145415 - a4lg:riscv-implication-to-c, r=Amanieu
std_detect: RISC-V: implement implication to "C"

Just like we implemented relatively complex rules to imply other extensions **from** "C" (and some others), this commit implements implication **to** the "C" extension from others, complying the following text in the ISA Manual (although there's no direct imply/depend references).

> The C extension is the superset of the following extensions:
>
> - Zca
> - Zcf if F is specified (RV32 only)
> - Zcd if D is specified

This is formally verified so that no other extension combinations (*not* in this implementation) can (currently) imply the "C" extension.

Note: this is a `std_detect` change and not main target feature handling.
2025-08-21 01:12:18 -04:00
Jacob Pratt
84c5d20fe7 Rollup merge of #145619 - joshtriplett:use-the-right-core, r=tgross35
`std_detect`: Use `rustc-std-workspace-*` to pull in `compiler-builtins`

https://github.com/rust-lang/rust/pull/145489 changed `std_detect` to no
longer depend on `cfg-if`, which meant it no longer indirectly pulled in
`rustc-std-workspace-core` via `cfg-if`. That caused it to no longer
depend on `compiler-builtins`.

Change `std_detect` to use `rustc-std-workspace-core` and
`rustc-std-workspace-alloc`, to integrate with the rustc workspace. This
also pulls in `compiler-builtins` via `rustc-std-workspace-core`.

Closes: https://github.com/rust-lang/rust/issues/145594
2025-08-20 00:45:58 -04:00