5 export CG_CLIF_DISPLAY_CG_TIME=1
6 export CG_CLIF_DISABLE_INCR_CACHE=1
8 export HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
9 export TARGET_TRIPLE=${TARGET_TRIPLE:-$HOST_TRIPLE}
13 case "$TARGET_TRIPLE" in
15 export JIT_SUPPORTED=1
18 export JIT_SUPPORTED=0
22 if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
23 export JIT_SUPPORTED=0
24 if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
25 # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
26 export RUSTFLAGS='-Clinker=aarch64-linux-gnu-gcc '$RUSTFLAGS
27 export RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu'
28 elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
29 # We are cross-compiling for Windows. Run tests in wine.
30 export RUN_WRAPPER='wine'
32 echo "Unknown non-native platform"
36 # FIXME fix `#[linkage = "extern_weak"]` without this
37 if [[ "$(uname)" == 'Darwin' ]]; then
38 export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
41 MY_RUSTC="$(pwd)/build/rustc-clif $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
43 function no_sysroot_tests() {
44 echo "[BUILD] mini_core"
45 $MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"
47 echo "[BUILD] example"
48 $MY_RUSTC example/example.rs --crate-type lib --target "$TARGET_TRIPLE"
50 if [[ "$JIT_SUPPORTED" = "1" ]]; then
51 echo "[JIT] mini_core_hello_world"
52 CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
54 echo "[JIT-lazy] mini_core_hello_world"
55 CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
57 echo "[JIT] mini_core_hello_world (skipped)"
60 echo "[AOT] mini_core_hello_world"
61 $MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target "$TARGET_TRIPLE"
62 $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
63 # (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
66 function base_sysroot_tests() {
67 echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
68 $MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target "$TARGET_TRIPLE"
69 $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
71 echo "[AOT] issue_91827_extern_types"
72 $MY_RUSTC example/issue-91827-extern-types.rs --crate-name issue_91827_extern_types --crate-type bin --target "$TARGET_TRIPLE"
73 $RUN_WRAPPER ./target/out/issue_91827_extern_types
75 echo "[BUILD] alloc_system"
76 $MY_RUSTC example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE"
78 echo "[AOT] alloc_example"
79 $MY_RUSTC example/alloc_example.rs --crate-type bin --target "$TARGET_TRIPLE"
80 $RUN_WRAPPER ./target/out/alloc_example
82 if [[ "$JIT_SUPPORTED" = "1" ]]; then
83 echo "[JIT] std_example"
84 $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
86 echo "[JIT-lazy] std_example"
87 $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
89 echo "[JIT] std_example (skipped)"
92 echo "[AOT] std_example"
93 $MY_RUSTC example/std_example.rs --crate-type bin --target "$TARGET_TRIPLE"
94 $RUN_WRAPPER ./target/out/std_example arg
96 echo "[AOT] dst_field_align"
97 $MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target "$TARGET_TRIPLE"
98 $RUN_WRAPPER ./target/out/dst_field_align
100 echo "[AOT] subslice-patterns-const-eval"
101 $MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
102 $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
104 echo "[AOT] track-caller-attribute"
105 $MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
106 $RUN_WRAPPER ./target/out/track-caller-attribute
108 echo "[AOT] float-minmax-pass"
109 $MY_RUSTC example/float-minmax-pass.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
110 $RUN_WRAPPER ./target/out/float-minmax-pass
112 echo "[AOT] mod_bench"
113 $MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
114 $RUN_WRAPPER ./target/out/mod_bench
117 function extended_sysroot_tests() {
119 ../build/cargo-clif clean
120 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
121 echo "[TEST] rust-random/rand"
122 ../build/cargo-clif test --workspace
124 echo "[AOT] rust-random/rand"
125 ../build/cargo-clif build --workspace --target $TARGET_TRIPLE --tests
129 pushd simple-raytracer
130 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
131 echo "[BENCH COMPILE] ebobby/simple-raytracer"
132 hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo-clif clean" \
133 "RUSTFLAGS='' cargo build" \
134 "../build/cargo-clif build"
136 echo "[BENCH RUN] ebobby/simple-raytracer"
137 cp ./target/debug/main ./raytracer_cg_clif
138 hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
140 ../build/cargo-clif clean
141 echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
142 echo "[COMPILE] ebobby/simple-raytracer"
143 ../build/cargo-clif build --target $TARGET_TRIPLE
144 echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
148 pushd build_sysroot/sysroot_src/library/core/tests
149 echo "[TEST] libcore"
150 ../../../../../build/cargo-clif clean
151 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
152 ../../../../../build/cargo-clif test
154 ../../../../../build/cargo-clif build --target $TARGET_TRIPLE --tests
159 echo "[TEST] rust-lang/regex example shootout-regex-dna"
160 ../build/cargo-clif clean
161 export RUSTFLAGS="$RUSTFLAGS --cap-lints warn" # newer aho_corasick versions throw a deprecation warning
162 # Make sure `[codegen mono items] start` doesn't poison the diff
163 ../build/cargo-clif build --example shootout-regex-dna --target $TARGET_TRIPLE
164 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
165 cat examples/regexdna-input.txt \
166 | ../build/cargo-clif run --example shootout-regex-dna --target $TARGET_TRIPLE \
167 | grep -v "Spawned thread" > res.txt
168 diff -u res.txt examples/regexdna-output.txt
171 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
172 echo "[TEST] rust-lang/regex tests"
173 ../build/cargo-clif test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
175 echo "[AOT] rust-lang/regex tests"
176 ../build/cargo-clif build --tests --target $TARGET_TRIPLE
181 echo "[TEST] rust-lang/portable-simd"
182 ../build/cargo-clif clean
183 ../build/cargo-clif build --all-targets --target $TARGET_TRIPLE
184 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
185 ../build/cargo-clif test -q
198 extended_sysroot_tests
201 echo "unknown test suite"