]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/scripts/tests.sh
Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup
[rust.git] / compiler / rustc_codegen_cranelift / scripts / tests.sh
1 #!/usr/bin/env bash
2
3 set -e
4
5 source build/config.sh
6 source scripts/ext_config.sh
7 MY_RUSTC="$RUSTC $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
8
9 function no_sysroot_tests() {
10     echo "[BUILD] mini_core"
11     $MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"
12
13     echo "[BUILD] example"
14     $MY_RUSTC example/example.rs --crate-type lib --target "$TARGET_TRIPLE"
15
16     if [[ "$JIT_SUPPORTED" = "1" ]]; then
17         echo "[JIT] mini_core_hello_world"
18         CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
19
20         echo "[JIT-lazy] mini_core_hello_world"
21         CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
22     else
23         echo "[JIT] mini_core_hello_world (skipped)"
24     fi
25
26     echo "[AOT] mini_core_hello_world"
27     $MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target "$TARGET_TRIPLE"
28     $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
29     # (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
30 }
31
32 function base_sysroot_tests() {
33     echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
34     $MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target "$TARGET_TRIPLE"
35     $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
36
37     echo "[AOT] alloc_system"
38     $MY_RUSTC example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE"
39
40     echo "[AOT] alloc_example"
41     $MY_RUSTC example/alloc_example.rs --crate-type bin --target "$TARGET_TRIPLE"
42     $RUN_WRAPPER ./target/out/alloc_example
43
44     if [[ "$JIT_SUPPORTED" = "1" ]]; then
45         echo "[JIT] std_example"
46         $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
47
48         echo "[JIT-lazy] std_example"
49         $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --cfg lazy_jit --target "$HOST_TRIPLE"
50     else
51         echo "[JIT] std_example (skipped)"
52     fi
53
54     echo "[AOT] dst_field_align"
55     # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
56     $MY_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)
58
59     echo "[AOT] std_example"
60     $MY_RUSTC example/std_example.rs --crate-type bin --target "$TARGET_TRIPLE"
61     $RUN_WRAPPER ./target/out/std_example arg
62
63     echo "[AOT] subslice-patterns-const-eval"
64     $MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
65     $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
66
67     echo "[AOT] track-caller-attribute"
68     $MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
69     $RUN_WRAPPER ./target/out/track-caller-attribute
70
71     echo "[AOT] mod_bench"
72     $MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
73     $RUN_WRAPPER ./target/out/mod_bench
74 }
75
76 function extended_sysroot_tests() {
77     pushd rand
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
86     popd
87
88     pushd simple-raytracer
89     if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
90         echo "[BENCH COMPILE] ebobby/simple-raytracer"
91         hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
92         "RUSTC=rustc RUSTFLAGS='' cargo build" \
93         "../build/cargo.sh build"
94
95         echo "[BENCH RUN] ebobby/simple-raytracer"
96         cp ./target/debug/main ./raytracer_cg_clif
97         hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
98     else
99         echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
100         echo "[COMPILE] ebobby/simple-raytracer"
101         ../build/cargo.sh build --target $TARGET_TRIPLE
102         echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
103     fi
104     popd
105
106     pushd build_sysroot/sysroot_src/library/core/tests
107     echo "[TEST] libcore"
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
114     popd
115
116     pushd regex
117     echo "[TEST] rust-lang/regex example shootout-regex-dna"
118     cargo clean
119     export RUSTFLAGS="$RUSTFLAGS --cap-lints warn" # newer aho_corasick versions throw a deprecation warning
120     # Make sure `[codegen mono items] start` doesn't poison the diff
121     ../build/cargo.sh build --example shootout-regex-dna --target $TARGET_TRIPLE
122     if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
123         cat examples/regexdna-input.txt \
124             | ../build/cargo.sh run --example shootout-regex-dna --target $TARGET_TRIPLE \
125             | grep -v "Spawned thread" > res.txt
126         diff -u res.txt examples/regexdna-output.txt
127     fi
128
129     if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
130         echo "[TEST] rust-lang/regex tests"
131         ../build/cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
132     else
133         echo "[AOT] rust-lang/regex tests"
134         ../build/cargo.sh build --tests --target $TARGET_TRIPLE
135     fi
136     popd
137 }
138
139 case "$1" in
140     "no_sysroot")
141         no_sysroot_tests
142         ;;
143     "base_sysroot")
144         base_sysroot_tests
145         ;;
146     "extended_sysroot")
147         extended_sysroot_tests
148         ;;
149     *)
150         echo "unknown test suite"
151         ;;
152 esac