Skip to content

Commit f10bf02

Browse files
committed
address review feedbacks
1 parent cb60673 commit f10bf02

6 files changed

Lines changed: 23 additions & 25 deletions

File tree

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,12 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
904904
}
905905
}
906906

907+
/// Runs stdarch's intrinsic-test binary crate to verify that Rust's `core::arch`
908+
/// SIMD intrinsics produce the same results as their C counterparts.
909+
///
910+
/// First runs the `intrinsic-test` binary, which generates C wrapper programs
911+
/// and a Rust Cargo workspace. Then runs `cargo test` on that workspace
912+
/// which compiles both versions and compares their outputs on random inputs.
907913
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
908914
pub struct IntrinsicTest {
909915
host: TargetSelection,
@@ -917,12 +923,12 @@ impl Step for IntrinsicTest {
917923
run.path("library/stdarch/crates/intrinsic-test").path("library/stdarch/crates/core_arch")
918924
}
919925

920-
fn is_default_step(_builder: &Builder<'_>) -> bool {
921-
true
922-
}
923-
924926
fn make_run(run: RunConfig<'_>) {
925-
run.builder.ensure(IntrinsicTest { host: run.target });
927+
let target = run.target;
928+
if !target.contains("aarch64-unknown-linux") && !target.contains("x86_64-unknown-linux") {
929+
return;
930+
}
931+
run.builder.ensure(IntrinsicTest { host: target });
926932
}
927933

928934
fn run(self, builder: &Builder<'_>) {
@@ -949,16 +955,22 @@ impl Step for IntrinsicTest {
949955
None,
950956
)
951957
} else {
952-
return;
958+
panic!("intrinsic-test only supports aarch64/x86_64 Linux, got {host}");
953959
};
954960

955961
let out_dir = builder.out.join(host).join("intrinsic-test");
956962
t!(fs::create_dir_all(&out_dir));
957963

958964
let crates_link = out_dir.join("crates");
959965
if !crates_link.exists() {
960-
std::os::unix::fs::symlink(builder.src.join("library/stdarch/crates"), &crates_link)
961-
.unwrap();
966+
t!(
967+
helpers::symlink_dir(
968+
&builder.config,
969+
&builder.src.join("library/stdarch/crates"),
970+
&crates_link
971+
),
972+
format!("failed to symlink stdarch crates into {}", crates_link.display())
973+
);
962974
}
963975

964976
let mut cmd = builder.tool_cmd(Tool::IntrinsicTest);
@@ -967,7 +979,7 @@ impl Step for IntrinsicTest {
967979
cmd.arg("--target").arg(&*host.triple);
968980
cmd.arg("--skip").arg(&skip_file);
969981
cmd.arg("--sample-percentage").arg("10");
970-
cmd.env("CC", "clang");
982+
cmd.env("CC", builder.cc(host));
971983
cmd.env("CFLAGS", cflags);
972984
cmd.run(builder);
973985

@@ -978,7 +990,7 @@ impl Step for IntrinsicTest {
978990
cargo.arg("--manifest-path").arg(&manifest);
979991
cargo.arg("--target").arg(&*host.triple);
980992
cargo.arg("--profile").arg("release");
981-
cargo.env("CC", "clang");
993+
cargo.env("CC", builder.cc(host));
982994
cargo.env("CFLAGS", cflags);
983995
cargo.env("RUSTC", &builder.initial_rustc);
984996
cargo.env("RUSTC_BOOTSTRAP", "1");

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ bootstrap_tool!(
502502
FeaturesStatusDump, "src/tools/features-status-dump", "features-status-dump";
503503
OptimizedDist, "src/tools/opt-dist", "opt-dist", submodules = &["src/tools/rustc-perf"];
504504
RunMakeSupport, "src/tools/run-make-support", "run_make_support", artifact_kind = ToolArtifactKind::Library;
505-
IntrinsicTest, "library/stdarch/crates/intrinsic-test", "intrinsic-test", is_external_tool = true;
505+
IntrinsicTest, "library/stdarch/crates/intrinsic-test", "intrinsic-test";
506506
);
507507

508508
/// These are the submodules that are required for rustbook to work due to

src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ expression: test
181181
[Test] test::RustcBook
182182
targets: [x86_64-unknown-linux-gnu]
183183
- Set({test::src/doc/rustc})
184-
[Test] test::IntrinsicTest
185-
targets: [x86_64-unknown-linux-gnu]
186-
- Set({test::library/stdarch/crates/core_arch})
187-
- Set({test::library/stdarch/crates/intrinsic-test})
188184
[Test] test::RustdocJSStd
189185
targets: [x86_64-unknown-linux-gnu]
190186
- Suite(test::tests/rustdoc-js-std)

src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ expression: test --skip=coverage
180180
[Test] test::RustcBook
181181
targets: [x86_64-unknown-linux-gnu]
182182
- Set({test::src/doc/rustc})
183-
[Test] test::IntrinsicTest
184-
targets: [x86_64-unknown-linux-gnu]
185-
- Set({test::library/stdarch/crates/core_arch})
186-
- Set({test::library/stdarch/crates/intrinsic-test})
187183
[Test] test::RustdocJSStd
188184
targets: [x86_64-unknown-linux-gnu]
189185
- Suite(test::tests/rustdoc-js-std)

src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ expression: test --skip=tests
144144
[Test] test::RustcBook
145145
targets: [x86_64-unknown-linux-gnu]
146146
- Set({test::src/doc/rustc})
147-
[Test] test::IntrinsicTest
148-
targets: [x86_64-unknown-linux-gnu]
149-
- Set({test::library/stdarch/crates/core_arch})
150-
- Set({test::library/stdarch/crates/intrinsic-test})
151147
[Test] test::RustdocTheme
152148
targets: [x86_64-unknown-linux-gnu]
153149
- Set({test::src/tools/rustdoc-themes})

src/bootstrap/src/core/builder/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,6 @@ mod snapshot {
21382138
[test] link-check <host>
21392139
[test] tier-check <host>
21402140
[test] rustc 0 <host> -> rust-analyzer 1 <host>
2141-
[build] rustc 0 <host> -> IntrinsicTest 1 <host>
21422141
[build] rustc 0 <host> -> RustdocTheme 1 <host>
21432142
[test] rustdoc-theme 1 <host>
21442143
[test] compiletest-rustdoc-ui 1 <host>
@@ -2322,7 +2321,6 @@ mod snapshot {
23222321
[test] rustc 1 <host> -> rust-analyzer 2 <host>
23232322
[doc] rustc (book) <host>
23242323
[test] rustc 1 <host> -> lint-docs 2 <host>
2325-
[build] rustc 0 <host> -> IntrinsicTest 1 <host>
23262324
[build] rustc 0 <host> -> RustdocTheme 1 <host>
23272325
[test] rustdoc-theme 2 <host>
23282326
[test] compiletest-rustdoc-ui 2 <host>

0 commit comments

Comments
 (0)