Skip to content

Commit ec76334

Browse files
committed
Build all tests when cross-compiling
1 parent b1d0ad2 commit ec76334

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

build.sh

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
5555
ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
5656

5757
mkdir -p "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
58+
mkdir -p "$target_dir/lib/rustlib/$HOST_TRIPLE/lib/"
5859
if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
5960
cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
6061
fi
@@ -64,12 +65,18 @@ case "$build_sysroot" in
6465
;;
6566
"llvm")
6667
cp -r $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib "$target_dir/lib/rustlib/$TARGET_TRIPLE/"
68+
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
69+
cp -r $(rustc --print sysroot)/lib/rustlib/$HOST_TRIPLE/lib "$target_dir/lib/rustlib/$HOST_TRIPLE/"
70+
fi
6771
;;
6872
"clif")
6973
echo "[BUILD] sysroot"
7074
dir=$(pwd)
7175
cd "$target_dir"
7276
time "$dir/build_sysroot/build_sysroot.sh"
77+
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
78+
time TARGET_TRIPLE="$HOST_TRIPLE" "$dir/build_sysroot/build_sysroot.sh"
79+
fi
7380
cp lib/rustlib/*/lib/libstd-* lib/
7481
;;
7582
*)

scripts/tests.sh

+32-13
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,20 @@ function base_sysroot_tests() {
7171
echo "[AOT] mod_bench"
7272
$MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
7373
$RUN_WRAPPER ./target/out/mod_bench
74+
}
7475

76+
function extended_sysroot_tests() {
7577
pushd rand
76-
rm -r ./target || true
77-
../build/cargo.sh test --workspace
78+
cargo clean
79+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
80+
echo "[TEST] rust-random/rand"
81+
../build/cargo.sh test --workspace
82+
else
83+
echo "[AOT] rust-random/rand"
84+
../build/cargo.sh build --workspace --target $TARGET_TRIPLE --tests
85+
fi
7886
popd
79-
}
8087

81-
function extended_sysroot_tests() {
8288
pushd simple-raytracer
8389
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
8490
echo "[BENCH COMPILE] ebobby/simple-raytracer"
@@ -92,27 +98,40 @@ function extended_sysroot_tests() {
9298
else
9399
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
94100
echo "[COMPILE] ebobby/simple-raytracer"
95-
../cargo.sh build
101+
../build/cargo.sh build --target $TARGET_TRIPLE
96102
echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
97103
fi
98104
popd
99105

100106
pushd build_sysroot/sysroot_src/library/core/tests
101107
echo "[TEST] libcore"
102-
rm -r ./target || true
103-
../../../../../build/cargo.sh test
108+
cargo clean
109+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
110+
../../../../../build/cargo.sh test
111+
else
112+
../../../../../build/cargo.sh build --target $TARGET_TRIPLE --tests
113+
fi
104114
popd
105115

106116
pushd regex
107117
echo "[TEST] rust-lang/regex example shootout-regex-dna"
108-
../build/cargo.sh clean
118+
cargo clean
109119
# Make sure `[codegen mono items] start` doesn't poison the diff
110-
../build/cargo.sh build --example shootout-regex-dna
111-
cat examples/regexdna-input.txt | ../build/cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt
112-
diff -u res.txt examples/regexdna-output.txt
120+
../build/cargo.sh build --example shootout-regex-dna --target $TARGET_TRIPLE
121+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
122+
cat examples/regexdna-input.txt \
123+
| ../build/cargo.sh run --example shootout-regex-dna --target $TARGET_TRIPLE \
124+
| grep -v "Spawned thread" > res.txt
125+
diff -u res.txt examples/regexdna-output.txt
126+
fi
113127

114-
echo "[TEST] rust-lang/regex tests"
115-
../build/cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
128+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
129+
echo "[TEST] rust-lang/regex tests"
130+
../build/cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
131+
else
132+
echo "[AOT] rust-lang/regex tests"
133+
../build/cargo.sh build --tests --target $TARGET_TRIPLE
134+
fi
116135
popd
117136
}
118137

0 commit comments

Comments
 (0)