Commit graph

45 commits

Author SHA1 Message Date
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
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
b0600b2326
Rollup merge of #145531 - sayantn:detect-apxf-avx10, r=Amanieu
Add runtime detection for APX-F and AVX10

This was missed in rust-lang/rust#139534 and rust-lang/rust#139675

`@rustbot` label O-x86_64 O-x86_32 A-target-feature
r? `@Amanieu`
2025-08-20 00:45:57 -04:00
Jacob Pratt
9261fcf159
Rollup merge of #145417 - a4lg:riscv-arch-platform-guide-ch2, r=Amanieu
std_detect: RISC-V platform guide documentation

This is practically a revert of a revert, making the commit e907456b2e10622ccd854a3bba8d02ce170b5dbb on `stdarch` come around again with minor fixes, enhancements and adjustments.

An excerpt from the original commit message follows:

Since there's no architectural feature detection on RISC-V (unlike `CPUID` on x86 architectures and some system registers on Arm/AArch64), runtime feature detection entirely depends on the platform-specific facility.

As a result, availability of each feature heavily depends on the platform and its version.

To help users make a decision for feature checking on a RISC-V system, this commit adds a platform guide with minimum supported platform versions.
2025-08-20 00:45:57 -04:00
许杰友 Jieyou Xu (Joe)
bdd3bc82c8
Rollup merge of #145099 - heiher:loong-32s, r=folkertdev
rustc_target: Add the `32s` target feature for LoongArch

LLVM: https://github.com/llvm/llvm-project/pull/139695
2025-08-19 19:42:08 +08:00
Tsukasa OI
ee7627ee40 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.
2025-08-19 01:38:27 +00:00
sayantn
40fc7df963
Add runtime detection for APX-F and AVX10 2025-08-17 19:34:18 +05:30
Josh Triplett
1ae4a0cc34 library: Migrate from cfg_if to cfg_select
Migrate the standard library from using the external `cfg_if` crate to
using the now-built-in `cfg_select` macro.

This does not yet eliminate the dependency from
`library/std/Cargo.toml`, because while the standard library itself no
longer uses `cfg_if`, it also incorporates the `backtrace` crate, which
does.

Migration assisted by the following vim command (after selecting the
full `cfg_if!` invocation):

```
'<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e
```

This is imperfect, but substantially accelerated the process. This
prompts for confirmation on the `} else {` since that can also appear
inside one of the arms. This also requires manual intervention to handle
any multi-line conditions.
2025-08-16 05:28:31 -07:00
Tsukasa OI
bec399e5a0 std_detect: RISC-V platform guide documentation
This is practically a revert of a revert, making the
commit e907456b2e10622ccd854a3bba8d02ce170b5dbb on `stdarch` come around
again with minor fixes, enhancements and adjustments.

An excerpt from the original commit message follows:

Since there's no architectural feature detection on RISC-V (unlike `CPUID`
on x86 architectures and some system registers on Arm/AArch64), runtime
feature detection entirely depends on the platform-specific facility.

As a result, availability of each feature heavily depends on the platform
and its version.

To help users make a decision for feature checking on a RISC-V system, this
commit adds a platform guide with minimum supported platform versions.
2025-08-15 02:34:17 +00:00
WANG Rui
0246245420 rustc_target: Add the 32s target feature for LoongArch 2025-08-09 13:54:09 +08:00
Tsukasa OI
c51e5ce452 std_detect: Linux 6.16 support for RISC-V
It adds feature detection of 1 extension (new in std_detect).

New RISC-V Extension:

1.  "Zabha"
2025-07-31 07:39:10 +00:00
bjorn3
b481c5b8ba std_detect testing improvements
* Fix riscv testing. Previously the mod tests; would be looking for
  src/detect/os/tests.rs.
* Replace a test with an unnamed const item. It is testing that no
  warnings are emitted. It doesn't contain any checks that need to run
  at runtime. Replacing the test allows removing the tidy:skip directive
  for test locations.
2025-07-24 13:01:08 +00:00
Jakub Beránek
9a1179c4de
Embed auxv files directly into the test binary 2025-07-22 20:22:16 +02:00
Jakub Beránek
81d90d8257
Improve error messages of auxv loading 2025-07-22 20:22:16 +02:00
Jakub Beránek
e07a1bbb79
Move tests around to appease tidy 2025-07-22 20:22:16 +02:00
Jakub Beránek
ee6f2c5276
Reformat std_detect 2025-07-22 20:17:46 +02:00
Jakub Beránek
5b2de8ab27
Move std_detect from library/stdarch to library 2025-07-22 20:17:06 +02:00