Skip to content

Commit 5c82915

Browse files
committed
address review feedbacks
1 parent e0ae211 commit 5c82915

3 files changed

Lines changed: 23 additions & 13 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
@@ -957,6 +957,12 @@ impl Step for StdarchVerify {
957957
}
958958
}
959959

960+
/// Runs stdarch's intrinsic-test binary crate to verify that Rust's `core::arch`
961+
/// SIMD intrinsics produce the same results as their C counterparts.
962+
///
963+
/// First runs the `intrinsic-test` binary, which generates C wrapper programs
964+
/// and a Rust Cargo workspace. Then runs `cargo test` on that workspace
965+
/// which compiles both versions and compares their outputs on random inputs.
960966
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
961967
pub struct IntrinsicTest {
962968
host: TargetSelection,
@@ -970,12 +976,12 @@ impl Step for IntrinsicTest {
970976
run.path("library/stdarch/crates/intrinsic-test").path("library/stdarch/crates/core_arch")
971977
}
972978

973-
fn is_default_step(_builder: &Builder<'_>) -> bool {
974-
true
975-
}
976-
977979
fn make_run(run: RunConfig<'_>) {
978-
run.builder.ensure(IntrinsicTest { host: run.target });
980+
let target = run.target;
981+
if !target.contains("aarch64-unknown-linux") && !target.contains("x86_64-unknown-linux") {
982+
return;
983+
}
984+
run.builder.ensure(IntrinsicTest { host: target });
979985
}
980986

981987
fn run(self, builder: &Builder<'_>) {
@@ -1002,16 +1008,22 @@ impl Step for IntrinsicTest {
10021008
None,
10031009
)
10041010
} else {
1005-
return;
1011+
panic!("intrinsic-test only supports aarch64/x86_64 Linux, got {host}");
10061012
};
10071013

10081014
let out_dir = builder.out.join(host).join("intrinsic-test");
10091015
t!(fs::create_dir_all(&out_dir));
10101016

10111017
let crates_link = out_dir.join("crates");
10121018
if !crates_link.exists() {
1013-
std::os::unix::fs::symlink(builder.src.join("library/stdarch/crates"), &crates_link)
1014-
.unwrap();
1019+
t!(
1020+
helpers::symlink_dir(
1021+
&builder.config,
1022+
&builder.src.join("library/stdarch/crates"),
1023+
&crates_link
1024+
),
1025+
format!("failed to symlink stdarch crates into {}", crates_link.display())
1026+
);
10151027
}
10161028

10171029
let mut cmd = builder.tool_cmd(Tool::IntrinsicTest);
@@ -1020,7 +1032,7 @@ impl Step for IntrinsicTest {
10201032
cmd.arg("--target").arg(&*host.triple);
10211033
cmd.arg("--skip").arg(&skip_file);
10221034
cmd.arg("--sample-percentage").arg("10");
1023-
cmd.env("CC", "clang");
1035+
cmd.env("CC", builder.cc(host));
10241036
cmd.env("CFLAGS", cflags);
10251037
cmd.run(builder);
10261038

@@ -1031,7 +1043,7 @@ impl Step for IntrinsicTest {
10311043
cargo.arg("--manifest-path").arg(&manifest);
10321044
cargo.arg("--target").arg(&*host.triple);
10331045
cargo.arg("--profile").arg("release");
1034-
cargo.env("CC", "clang");
1046+
cargo.env("CC", builder.cc(host));
10351047
cargo.env("CFLAGS", cflags);
10361048
cargo.env("RUSTC", &builder.initial_rustc);
10371049
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
@@ -508,7 +508,7 @@ bootstrap_tool!(
508508
FeaturesStatusDump, "src/tools/features-status-dump", "features-status-dump";
509509
OptimizedDist, "src/tools/opt-dist", "opt-dist", submodules = &["src/tools/rustc-perf"];
510510
RunMakeSupport, "src/tools/run-make-support", "run_make_support", artifact_kind = ToolArtifactKind::Library;
511-
IntrinsicTest, "library/stdarch/crates/intrinsic-test", "intrinsic-test", is_external_tool = true;
511+
IntrinsicTest, "library/stdarch/crates/intrinsic-test", "intrinsic-test";
512512
);
513513

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

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)