]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_codegen_cranelift/scripts/tests.sh
New upstream version 1.59.0+dfsg1
[rustc.git] / compiler / rustc_codegen_cranelift / scripts / tests.sh
CommitLineData
6a06907d 1#!/usr/bin/env bash
29967ef6
XL
2
3set -e
4
136023e0 5source scripts/config.sh
5869c6ff 6source scripts/ext_config.sh
136023e0
XL
7export RUSTC=false # ensure that cg_llvm isn't accidentally used
8MY_RUSTC="$(pwd)/build/bin/cg_clif $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
29967ef6
XL
9
10function no_sysroot_tests() {
11 echo "[BUILD] mini_core"
fc512014 12 $MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"
29967ef6
XL
13
14 echo "[BUILD] example"
fc512014 15 $MY_RUSTC example/example.rs --crate-type lib --target "$TARGET_TRIPLE"
29967ef6
XL
16
17 if [[ "$JIT_SUPPORTED" = "1" ]]; then
18 echo "[JIT] mini_core_hello_world"
94222f64 19 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"
5869c6ff
XL
20
21 echo "[JIT-lazy] mini_core_hello_world"
94222f64 22 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"
29967ef6
XL
23 else
24 echo "[JIT] mini_core_hello_world (skipped)"
25 fi
26
27 echo "[AOT] mini_core_hello_world"
fc512014 28 $MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target "$TARGET_TRIPLE"
29967ef6
XL
29 $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
30 # (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
6a06907d 31}
29967ef6 32
6a06907d 33function base_sysroot_tests() {
29967ef6 34 echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
fc512014 35 $MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target "$TARGET_TRIPLE"
29967ef6 36 $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
29967ef6 37
a2a8927a
XL
38 echo "[AOT] issue_91827_extern_types"
39 $MY_RUSTC example/issue-91827-extern-types.rs --crate-name issue_91827_extern_types --crate-type bin --target "$TARGET_TRIPLE"
40 $RUN_WRAPPER ./target/out/issue_91827_extern_types
41
6a06907d
XL
42 echo "[AOT] alloc_system"
43 $MY_RUSTC example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE"
44
29967ef6 45 echo "[AOT] alloc_example"
fc512014 46 $MY_RUSTC example/alloc_example.rs --crate-type bin --target "$TARGET_TRIPLE"
29967ef6
XL
47 $RUN_WRAPPER ./target/out/alloc_example
48
49 if [[ "$JIT_SUPPORTED" = "1" ]]; then
50 echo "[JIT] std_example"
94222f64 51 $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
5869c6ff
XL
52
53 echo "[JIT-lazy] std_example"
94222f64 54 $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
29967ef6
XL
55 else
56 echo "[JIT] std_example (skipped)"
57 fi
58
59 echo "[AOT] dst_field_align"
60 # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
fc512014 61 $MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target "$TARGET_TRIPLE"
29967ef6
XL
62 $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
63
64 echo "[AOT] std_example"
fc512014 65 $MY_RUSTC example/std_example.rs --crate-type bin --target "$TARGET_TRIPLE"
29967ef6
XL
66 $RUN_WRAPPER ./target/out/std_example arg
67
68 echo "[AOT] subslice-patterns-const-eval"
fc512014 69 $MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
29967ef6
XL
70 $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
71
72 echo "[AOT] track-caller-attribute"
fc512014 73 $MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
29967ef6
XL
74 $RUN_WRAPPER ./target/out/track-caller-attribute
75
76 echo "[AOT] mod_bench"
fc512014 77 $MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
29967ef6 78 $RUN_WRAPPER ./target/out/mod_bench
cdc7bbd5 79}
29967ef6 80
cdc7bbd5 81function extended_sysroot_tests() {
29967ef6 82 pushd rand
a2a8927a 83 ../build/cargo-clif clean
cdc7bbd5
XL
84 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
85 echo "[TEST] rust-random/rand"
a2a8927a 86 ../build/cargo-clif test --workspace
cdc7bbd5
XL
87 else
88 echo "[AOT] rust-random/rand"
a2a8927a 89 ../build/cargo-clif build --workspace --target $TARGET_TRIPLE --tests
cdc7bbd5 90 fi
29967ef6 91 popd
29967ef6 92
29967ef6
XL
93 pushd simple-raytracer
94 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
95 echo "[BENCH COMPILE] ebobby/simple-raytracer"
a2a8927a 96 hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo-clif clean" \
29967ef6 97 "RUSTC=rustc RUSTFLAGS='' cargo build" \
a2a8927a 98 "../build/cargo-clif build"
29967ef6
XL
99
100 echo "[BENCH RUN] ebobby/simple-raytracer"
101 cp ./target/debug/main ./raytracer_cg_clif
fc512014 102 hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
29967ef6 103 else
a2a8927a 104 ../build/cargo-clif clean
29967ef6
XL
105 echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
106 echo "[COMPILE] ebobby/simple-raytracer"
a2a8927a 107 ../build/cargo-clif build --target $TARGET_TRIPLE
29967ef6
XL
108 echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
109 fi
110 popd
111
112 pushd build_sysroot/sysroot_src/library/core/tests
113 echo "[TEST] libcore"
a2a8927a 114 ../../../../../build/cargo-clif clean
cdc7bbd5 115 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
a2a8927a 116 ../../../../../build/cargo-clif test
cdc7bbd5 117 else
a2a8927a 118 ../../../../../build/cargo-clif build --target $TARGET_TRIPLE --tests
cdc7bbd5 119 fi
29967ef6
XL
120 popd
121
122 pushd regex
123 echo "[TEST] rust-lang/regex example shootout-regex-dna"
a2a8927a 124 ../build/cargo-clif clean
17df50a5 125 export RUSTFLAGS="$RUSTFLAGS --cap-lints warn" # newer aho_corasick versions throw a deprecation warning
29967ef6 126 # Make sure `[codegen mono items] start` doesn't poison the diff
a2a8927a 127 ../build/cargo-clif build --example shootout-regex-dna --target $TARGET_TRIPLE
cdc7bbd5
XL
128 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
129 cat examples/regexdna-input.txt \
a2a8927a 130 | ../build/cargo-clif run --example shootout-regex-dna --target $TARGET_TRIPLE \
cdc7bbd5
XL
131 | grep -v "Spawned thread" > res.txt
132 diff -u res.txt examples/regexdna-output.txt
133 fi
29967ef6 134
cdc7bbd5
XL
135 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
136 echo "[TEST] rust-lang/regex tests"
a2a8927a 137 ../build/cargo-clif test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
cdc7bbd5
XL
138 else
139 echo "[AOT] rust-lang/regex tests"
a2a8927a 140 ../build/cargo-clif build --tests --target $TARGET_TRIPLE
cdc7bbd5 141 fi
29967ef6 142 popd
94222f64 143
c295e0f8
XL
144 pushd portable-simd
145 echo "[TEST] rust-lang/portable-simd"
a2a8927a
XL
146 ../build/cargo-clif clean
147 ../build/cargo-clif build --all-targets --target $TARGET_TRIPLE
94222f64 148 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
a2a8927a 149 ../build/cargo-clif test -q
94222f64
XL
150 fi
151 popd
29967ef6
XL
152}
153
154case "$1" in
155 "no_sysroot")
156 no_sysroot_tests
157 ;;
158 "base_sysroot")
159 base_sysroot_tests
160 ;;
161 "extended_sysroot")
162 extended_sysroot_tests
163 ;;
164 *)
165 echo "unknown test suite"
166 ;;
167esac