Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose is_s390x_feature_detected! from std::arch #138275

Merged
merged 1 commit into from
Mar 16, 2025

Conversation

folkertdev
Copy link
Contributor

tracking issue: #135413
implementation: rust-lang/stdarch#1699 (more features added in rust-lang/stdarch#1720)

This macro was part of the recent stdarch synchronization, but not yet exposed via std::arch.

r? libs

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 9, 2025
@Mark-Simulacrum
Copy link
Member

@bors r+

Technically new API area, but seems basically obviously fine to add as unstable.

@bors
Copy link
Contributor

bors commented Mar 15, 2025

📌 Commit a312635 has been approved by Mark-Simulacrum

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 Mar 15, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 16, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang#133055 (Expand `CloneToUninit` documentation.)
 - rust-lang#137147 (Add exclude to config.toml)
 - rust-lang#137864 (Don't drop `Rvalue::WrapUnsafeBinder` during GVN)
 - rust-lang#137890 (doc: clarify that consume can be called after BufReader::peek)
 - rust-lang#137956 (Add RTN support to rustdoc)
 - rust-lang#137968 (Properly escape regexes in Python scripts)
 - rust-lang#138082 (Remove `#[cfg(not(test))]` gates in `core`)
 - rust-lang#138275 (expose `is_s390x_feature_detected!` from `std::arch`)
 - rust-lang#138303 (Fix Ptr inconsistency in {Rc,Arc})
 - rust-lang#138309 (Add missing doc for intrinsic (Fix PR135334))
 - rust-lang#138323 (Expand and organize `offset_of!` documentation.)
 - rust-lang#138329 (debug-assert that the size_hint is well-formed in `collect`)
 - rust-lang#138465 (linkchecker: bump html5ever)
 - rust-lang#138471 (Clean up some tests in tests/ui)
 - rust-lang#138472 (Add codegen test for rust-lang#129795)
 - rust-lang#138484 (Use lit span when suggesting suffix lit cast)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8210b84 into rust-lang:master Mar 16, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 16, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 16, 2025
Rollup merge of rust-lang#138275 - folkertdev:expose-is-s390x-feature-detected, r=Mark-Simulacrum

expose `is_s390x_feature_detected!` from `std::arch`

tracking issue: rust-lang#135413
implementation: rust-lang/stdarch#1699 (more features added in rust-lang/stdarch#1720)

This macro was part of the recent `stdarch` synchronization, but not yet exposed via `std::arch`.

r? libs
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Mar 19, 2025
…-detected, r=Mark-Simulacrum

expose `is_s390x_feature_detected!` from `std::arch`

tracking issue: rust-lang#135413
implementation: rust-lang/stdarch#1699 (more features added in rust-lang/stdarch#1720)

This macro was part of the recent `stdarch` synchronization, but not yet exposed via `std::arch`.

r? libs
@uweigand
Copy link
Contributor

Not sure if this is directly related, but as of a few days ago, I now see this failure in ./x.py check:

...
9   |           $(cfg!(target_feature = $target_feature_lit) ||)*
    |                  ^^^^^^^^^^^^^^
...
50  | /         macro_rules! $macro_name {
51  | |             $(
52  | |                 ($feature_lit) => {
53  | |                     $crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?)
    | |                     -------------------------------------------------------------------------------------------------------------------------- in this macro invocation (#2)
...   |
87  | |             };
88  | |         }
    | |_________- in this expansion of `is_s390x_feature_detected!` (#1)
    |
   ::: library/std/tests/run-time-detect.rs:154:9
    |
154 |           is_s390x_feature_detected!("vector-packed-decimal-enhancement-2")
    |           ----------------------------------------------------------------- in this macro invocation (#1)
    |
    = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 266 more
    = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
    = help: try referring to `$crate::detect_feature` crate for guidance on how handle this unexpected cfg
    = help: the macro `$crate::detect_feature` may come from an old version of the `std_detect` crate, try updating your dependency with `cargo update -p std_detect`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

error: unexpected `cfg` condition value: `vector-packed-decimal-enhancement`
   --> /home/stefansf/devel/dailyrust-workdir/rust/library/stdarch/crates/std_detect/src/detect/macros.rs:9:16
    |
4   |   macro_rules! detect_feature {
    |   ---------------------------
    |   |
    |   in this expansion of `$crate::detect_feature!` (#2)
    |   in this expansion of `$crate::detect_feature!` (#3)
5   |       ($feature:tt, $feature_lit:tt) => {
6   |           $crate::detect_feature!($feature, $feature_lit : $feature_lit)
    |           -------------------------------------------------------------- in this macro invocation (#3)
...
9   |           $(cfg!(target_feature = $target_feature_lit) ||)*
    |                  ^^^^^^^^^^^^^^
...
50  | /         macro_rules! $macro_name {
51  | |             $(
52  | |                 ($feature_lit) => {
53  | |                     $crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?)
    | |                     -------------------------------------------------------------------------------------------------------------------------- in this macro invocation (#2)
...   |
87  | |             };
88  | |         }
    | |_________- in this expansion of `is_s390x_feature_detected!` (#1)
    |
   ::: library/std/tests/run-time-detect.rs:158:9
    |
158 |           is_s390x_feature_detected!("vector-packed-decimal-enhancement")
    |           --------------------------------------------------------------- in this macro invocation (#1)
    |
    = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 266 more
    = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
    = help: try referring to `$crate::detect_feature` crate for guidance on how handle this unexpected cfg
    = help: the macro `$crate::detect_feature` may come from an old version of the `std_detect` crate, try updating your dependency with `cargo update -p std_detect`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

error: unexpected `cfg` condition value: `vector-packed-decimal`
   --> /home/stefansf/devel/dailyrust-workdir/rust/library/stdarch/crates/std_detect/src/detect/macros.rs:9:16
    |
4   |   macro_rules! detect_feature {
    |   ---------------------------
    |   |
    |   in this expansion of `$crate::detect_feature!` (#2)
    |   in this expansion of `$crate::detect_feature!` (#3)
5   |       ($feature:tt, $feature_lit:tt) => {
6   |           $crate::detect_feature!($feature, $feature_lit : $feature_lit)
    |           -------------------------------------------------------------- in this macro invocation (#3)
...
9   |           $(cfg!(target_feature = $target_feature_lit) ||)*
    |                  ^^^^^^^^^^^^^^
...
50  | /         macro_rules! $macro_name {
51  | |             $(
52  | |                 ($feature_lit) => {
53  | |                     $crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?)
    | |                     -------------------------------------------------------------------------------------------------------------------------- in this macro invocation (#2)
...   |
87  | |             };
88  | |         }
    | |_________- in this expansion of `is_s390x_feature_detected!` (#1)
    |
   ::: library/std/tests/run-time-detect.rs:160:43
    |
160 |       println!("vector-packed-decimal: {}", is_s390x_feature_detected!("vector-packed-decimal"));
    |                                             --------------------------------------------------- in this macro invocation (#1)
    |
    = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 266 more
    = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
    = help: try referring to `$crate::detect_feature` crate for guidance on how handle this unexpected cfg
    = help: the macro `$crate::detect_feature` may come from an old version of the `std_detect` crate, try updating your dependency with `cargo update -p std_detect`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

error: could not compile `std` (test "run-time-detect") due to 11 previous errors
warning: build failed, waiting for other jobs to finish...
Build completed unsuccessfully in 0:00:30

@folkertdev
Copy link
Contributor Author

I suspect this is a caching issue of some kind? I ran run the following just fine (with qemu)

#![cfg_attr(
    all(target_arch = "s390x", target_os = "linux"),
    feature(stdarch_s390x_feature_detection)
)]

use std::arch::is_s390x_feature_detected;
fn main() {
    println!(
        "vector-packed-decimal-enhancement-2: {}",
        is_s390x_feature_detected!("vector-packed-decimal-enhancement-2")
    );
}

on current nightly. You could try a ./x clean maybe? (I'm assuming you are on a commit that should have this macro exposed?)

@uweigand
Copy link
Contributor

I still see the failure today after cleaning everything. The failure occurs during stage0 library build, where the std library sources included in the Rust repo (rust/library/std) are being built with the bootstrap compiler (https://static.rust-lang.org/dist/2025-02-18/rustc-beta-s390x-unknown-linux-gnu.tar.xz). Is this supposed to work now?

@folkertdev
Copy link
Contributor Author

I believe bootstrap updates in tandem with the standard releases, so maybe wait for that?

@uweigand
Copy link
Contributor

I believe bootstrap updates in tandem with the standard releases, so maybe wait for that?

I just ran ./x.py run src/tools/bump-stage0 and the build is now using https://static.rust-lang.org/dist/2025-03-23/rustc-beta-s390x-unknown-linux-gnu.tar.xz. But I'm still getting the same error ...

I suspect something else must be going on here. A minimal command line to reproduce is

RUSTC_BOOTSTRAP=1 /home/uweigand/rust/build/s390x-unknown-linux-gnu/stage0/bin/rustc
library/std/tests/run-time-detect.rs --test --target s390x-unknown-linux-gnu
--check-cfg "cfg(test)" -D unexpected-cfgs
--sysroot /home/uweigand/rust/build/s390x-unknown-linux-gnu/stage0-sysroot

where /home/uweigand/rust/build/s390x-unknown-linux-gnu/stage0/bin/rustc is (after my change) version rustc 1.86.0-beta.7 (7824ede68 2025-03-22), and /home/uweigand/rust/build/s390x-unknown-linux-gnu/stage0-sysroot contains a lib/rustlib/s390x-unknown-linux-gnu/lib/libstd-743ebc1720e92b95.rmeta that was apparently just rebuilt from mainline sources using that same 2025-03-22 compiler. This should all be recent enough, shouldn't it?

@folkertdev
Copy link
Contributor Author

The build of stage0 appears new enough, but does not contain all commits of the master branch. Only critical bug fixes are backported (e.g. see this PR to beta which that commit is a part of #138817).

So modulo these beta backports, the code used for bootstrap should only update every 6 weeks. The next release is in roughly 7 days, so I expect these issues to be resolved early next week.

I did ask some further questions here #t-libs > target features, core_arch and bootstrap, because another sync from core_arch to rust/rust also caused issues with these tests. It still looks like the next release cycle should resolve these issues.

The true problem here is that stdarch and rust-lang/rust are in different repositories. There are some plans to change that, but it's tricky and has downsides too.

@uweigand
Copy link
Contributor

The build of stage0 appears new enough, but does not contain all commits of the master branch. Only critical bug fixes are backported (e.g. see this PR to beta which that commit is a part of #138817).

Oh, so the stage0 compiler binaries were created on 2025-03-22, but from the beta branch, not master. That's the bit I was missing - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants