diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 47318d3c086f5..e7c58bce84259 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1056,6 +1056,117 @@ impl CommandLineStep for StdarchVerify { } } +/// Runs `core_arch`'s inline unit and `assert_instr` tests for the native +/// targets rust already tests on (x86_64 / aarch64). +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct CoreArchTest { + build_compiler: Compiler, + host: TargetSelection, +} + +impl CommandLineStep for CoreArchTest { + type Output = (); + const IS_HOST: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias("core-arch") + } + + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(CoreArchTest { + build_compiler: get_compiler_to_test(run.builder, run.target), + host: run.target, + }); + } + + fn run(self, builder: &Builder<'_>) { + let host = self.host; + if !host.contains("x86_64-unknown-linux") && !host.contains("aarch64-unknown-linux") { + builder.info(&format!("Skipping core_arch tests, unsupported on {host}")); + return; + } + + let build_compiler = self.build_compiler; + builder.std(build_compiler, host); + let record_failed_tests = builder.ensure(SetupFailedTestsFile); + + let mut cargo = tool::prepare_tool_cargo( + builder, + build_compiler, + Mode::ToolStd, + host, + Kind::Test, + "library/stdarch/crates/core_arch", + SourceType::InTree, + &[], + ); + cargo.env("TARGET", host.to_string().as_str()); + + let allowed_features = [ + // tidy-alphabetical-start + "aarch64_unstable_target_feature", + "abi_unadjusted", + "abi_vectorcall", + "allow_internal_unstable", + "arm_target_feature", + "asm_experimental_arch", + "avx10_target_feature", + "clflushopt_target_feature", + "const_cmp", + "const_eval_select", + "const_trait_impl", + "core_intrinsics", + "custom_inner_attributes", + "decl_macro", + "doc_cfg", + "f16", + "fmt_helpers_for_derive", + "funnel_shifts", + "hexagon_target_feature", + "link_llvm_intrinsics", + "loongarch_target_feature", + "maybe_uninit_as_bytes", + "min_adt_const_params", + "mips_target_feature", + "movrs_target_feature", + "no_core", + "powerpc_target_feature", + "proc_macro_hygiene", + "repr_simd", + "riscv_target_feature", + "rtm_target_feature", + "rustc_attrs", + "simd_ffi", + "staged_api", + "stdarch_arm_feature_detection", + "stdarch_internal", + "stdarch_mips_feature_detection", + "stdarch_powerpc_feature_detection", + "stmt_expr_attributes", + "test", + "wasm_target_feature", + "x86_amx_intrinsics", + // tidy-alphabetical-end + ]; + cargo.allow_features(&allowed_features.join(",")); + cargo.rustflag("-Zmerge-functions=disabled"); + + run_cargo_test( + cargo, + &[], + &["core_arch".to_string()], + Some("core_arch"), + host, + builder, + record_failed_tests, + ); + } +} + /// Runs stdarch's intrinsic-test binary crate to verify that Rust's `core::arch` /// SIMD intrinsics produce the same results as their C counterparts. /// diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 32ed54050dc3d..0e4f2906c0d49 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -187,6 +187,9 @@ expression: test [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index d1cdf81a14e08..996c3ba17438c 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -184,6 +184,9 @@ expression: test --skip=coverage [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index df4b8a2ce1299..f24d8a9a11cd4 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -187,6 +187,9 @@ expression: test --skip=coverage-map [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index 75992df8aa616..318433fc4568e 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -187,6 +187,9 @@ expression: test --skip=coverage-run [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index 72839a9dddb10..1c10b30f723c3 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -148,6 +148,9 @@ expression: test --skip=tests [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocTheme targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rustdoc-themes}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index a44052fac41f9..d6336c14e0ae9 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -184,6 +184,9 @@ expression: test --skip=tests/coverage [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index ee846481847cd..ea91c610295ca 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -128,6 +128,9 @@ expression: test --skip=tests --skip=library --skip=tidyselftest [Test] test::RustcBook targets: [x86_64-unknown-linux-gnu] - Set({src/doc/rustc}) +[Test] test::CoreArchTest + targets: [x86_64-unknown-linux-gnu] + - Set({core-arch}) [Test] test::RustdocTheme targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rustdoc-themes}) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 0bd0781133684..c9cea120dbd22 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -922,6 +922,7 @@ impl<'a> Builder<'a> { test::Clippy, test::CompiletestTest, test::StdarchVerify, + test::CoreArchTest, test::CrateRunMakeSupport, test::CrateBuildHelper, test::RustdocJSStd, diff --git a/src/ci/docker/scripts/stage_2_test_set1.sh b/src/ci/docker/scripts/stage_2_test_set1.sh index 62b3c2c051a40..e64d73e7c1309 100755 --- a/src/ci/docker/scripts/stage_2_test_set1.sh +++ b/src/ci/docker/scripts/stage_2_test_set1.sh @@ -20,8 +20,15 @@ if [ "$LLVM_VERSION" = "21" ]; then SKIP_INTRINSICS="--skip intrinsic-test" fi +# Skip core-arch on LLVM < 23 to avoid CI failures. +if [ -n "$LLVM_VERSION" ] && [ "$LLVM_VERSION" -lt 23 ]; then + echo "LLVM_VERSION < 23; skipping core-arch" + SKIP_CORE_ARCH="--skip core-arch" +fi + ../x.py --stage 2 test \ ${SKIP_TIDY:+$SKIP_TIDY} \ ${SKIP_INTRINSICS:+$SKIP_INTRINSICS} \ + ${SKIP_CORE_ARCH:+$SKIP_CORE_ARCH} \ --skip compiler \ --skip src diff --git a/src/ci/docker/scripts/stage_2_test_set2.sh b/src/ci/docker/scripts/stage_2_test_set2.sh index c0cdc31011378..933ada10e1ff1 100755 --- a/src/ci/docker/scripts/stage_2_test_set2.sh +++ b/src/ci/docker/scripts/stage_2_test_set2.sh @@ -29,10 +29,17 @@ if [ "$LLVM_VERSION" = "21" ]; then SKIP_INTRINSICS="--skip intrinsic-test" fi +# Skip core-arch on LLVM < 23 to avoid CI failures. +if [ -n "$LLVM_VERSION" ] && [ "$LLVM_VERSION" -lt 23 ]; then + echo "LLVM_VERSION < 23; skipping core-arch" + SKIP_CORE_ARCH="--skip core-arch" +fi + ../x.py --stage 2 test \ ${SKIP_TIDY:+$SKIP_TIDY} \ ${SKIP_INTRINSICS:+$SKIP_INTRINSICS} \ ${SKIP_RUST_ANALYZER:+$SKIP_RUST_ANALYZER} \ + ${SKIP_CORE_ARCH:+$SKIP_CORE_ARCH} \ --skip tests \ --skip library \ --skip tidyselftest