Skip to content

Commit 9f602bf

Browse files
committed
Use qemu to run tests for AArch64 when using a different host arch
1 parent 045ae10 commit 9f602bf

File tree

2 files changed

+58
-28
lines changed

2 files changed

+58
-28
lines changed

config.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,23 @@ else
1010
exit 1
1111
fi
1212

13-
TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
13+
HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
14+
TARGET_TRIPLE=$HOST_TRIPLE
15+
#TARGET_TRIPLE="aarch64-unknown-linux-gnu"
1416

15-
export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
17+
linker=''
18+
RUN_WRAPPER=''
19+
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
20+
if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
21+
# We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
22+
linker='-Clinker=aarch64-linux-gnu-gcc'
23+
RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu'
24+
else
25+
echo "Unknown non-native platform"
26+
fi
27+
fi
28+
29+
export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
1630

1731
# FIXME remove once the atomic shim is gone
1832
if [[ `uname` == 'Darwin' ]]; then

test.sh

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,85 @@ rm -r target/out || true
1616
mkdir -p target/out/clif
1717

1818
echo "[BUILD] mini_core"
19-
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib
19+
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
2020

2121
echo "[BUILD] example"
22-
$RUSTC example/example.rs --crate-type lib
22+
$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
2323

24-
echo "[JIT] mini_core_hello_world"
25-
CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit
24+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
25+
echo "[JIT] mini_core_hello_world"
26+
CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE
27+
else
28+
echo "[JIT] mini_core_hello_world (skipped)"
29+
fi
2630

2731
echo "[AOT] mini_core_hello_world"
28-
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g
29-
./target/out/mini_core_hello_world abc bcd
32+
$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
33+
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
3034
# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd
3135

3236
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
33-
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin
34-
./target/out/arbitrary_self_types_pointers_and_wrappers
37+
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
38+
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
3539

3640
echo "[BUILD] sysroot"
3741
time ./build_sysroot/build_sysroot.sh
3842

3943
echo "[AOT] alloc_example"
40-
$RUSTC example/alloc_example.rs --crate-type bin
41-
./target/out/alloc_example
44+
$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
45+
$RUN_WRAPPER ./target/out/alloc_example
4246

43-
echo "[JIT] std_example"
44-
CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs
47+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
48+
echo "[JIT] std_example"
49+
CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs --target $HOST_TRIPLE
50+
else
51+
echo "[JIT] std_example (skipped)"
52+
fi
4553

4654
echo "[AOT] dst_field_align"
4755
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
48-
$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin
49-
./target/out/dst_field_align
56+
$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
57+
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
5058

5159
echo "[AOT] std_example"
52-
$RUSTC example/std_example.rs --crate-type bin
53-
./target/out/std_example
60+
$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
61+
$RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE
5462

5563
echo "[AOT] subslice-patterns-const-eval"
56-
$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort
57-
./target/out/subslice-patterns-const-eval
64+
$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
65+
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
5866

5967
echo "[AOT] track-caller-attribute"
60-
$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort
61-
./target/out/track-caller-attribute
68+
$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
69+
$RUN_WRAPPER ./target/out/track-caller-attribute
6270

6371
echo "[BUILD] mod_bench"
64-
$RUSTC example/mod_bench.rs --crate-type bin
72+
$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
6573

6674
# FIXME linker gives multiple definitions error on Linux
6775
#echo "[BUILD] sysroot in release mode"
6876
#./build_sysroot/build_sysroot.sh --release
6977

7078
pushd simple-raytracer
71-
echo "[BENCH COMPILE] ebobby/simple-raytracer"
72-
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \
79+
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
80+
echo "[BENCH COMPILE] ebobby/simple-raytracer"
81+
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \
7382
"RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \
7483
"../cargo.sh build"
7584

76-
echo "[BENCH RUN] ebobby/simple-raytracer"
77-
cp ./target/*/debug/main ./raytracer_cg_clif
78-
hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
85+
echo "[BENCH RUN] ebobby/simple-raytracer"
86+
cp ./target/*/debug/main ./raytracer_cg_clif
87+
hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
88+
else
89+
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
90+
echo "[COMPILE] ebobby/simple-raytracer"
91+
../cargo.sh build
92+
echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
93+
fi
7994
popd
8095

8196
pushd build_sysroot/sysroot_src/src/libcore/tests
97+
echo "[TEST] libcore"
8298
rm -r ./target || true
8399
../../../../../cargo.sh test
84100
popd

0 commit comments

Comments
 (0)