]> git.lizzy.rs Git - rust.git/blob - test.sh
Fix debug build
[rust.git] / test.sh
1 #!/bin/bash
2 set -e
3
4 # Build cg_clif
5 if [[ "$1" == "--release" ]]; then
6     export CHANNEL='release'
7     CARGO_INCREMENTAL=1 cargo rustc --release -- -Zrun_dsymutil=no
8 else
9     export CHANNEL='debug'
10     cargo rustc -- -Zrun_dsymutil=no
11 fi
12
13 # Config
14 source scripts/config.sh
15 export CG_CLIF_INCR_CACHE_DISABLED=1
16 RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
17
18 # Cleanup
19 rm -r target/out || true
20 mkdir -p target/out/clif
21
22 # Perform all tests
23 echo "[BUILD] mini_core"
24 $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
25
26 echo "[BUILD] example"
27 $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
28
29 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
30     echo "[JIT] mini_core_hello_world"
31     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
32 else
33     echo "[JIT] mini_core_hello_world (skipped)"
34 fi
35
36 echo "[AOT] mini_core_hello_world"
37 $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
38 $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
39 # (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
40
41 echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
42 $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
43 $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
44
45 echo "[BUILD] sysroot"
46 time ./build_sysroot/build_sysroot.sh --release
47
48 echo "[AOT] alloc_example"
49 $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
50 $RUN_WRAPPER ./target/out/alloc_example
51
52 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
53     echo "[JIT] std_example"
54     CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs --target $HOST_TRIPLE
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.
61 $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
62 $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
63
64 echo "[AOT] std_example"
65 $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
66 $RUN_WRAPPER ./target/out/std_example arg
67
68 echo "[AOT] subslice-patterns-const-eval"
69 $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
70 $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
71
72 echo "[AOT] track-caller-attribute"
73 $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
74 $RUN_WRAPPER ./target/out/track-caller-attribute
75
76 echo "[AOT] mod_bench"
77 $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
78 $RUN_WRAPPER ./target/out/mod_bench
79
80 pushd rand
81 rm -r ./target || true
82 ../cargo.sh test --workspace
83 popd
84
85 pushd simple-raytracer
86 if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
87     echo "[BENCH COMPILE] ebobby/simple-raytracer"
88     hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \
89     "RUSTFLAGS='' cargo build" \
90     "../cargo.sh build"
91
92     echo "[BENCH RUN] ebobby/simple-raytracer"
93     cp ./target/debug/main ./raytracer_cg_clif
94     hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
95 else
96     echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
97     echo "[COMPILE] ebobby/simple-raytracer"
98     ../cargo.sh build
99     echo "[BENCH RUN] ebobby/simple-raytracer (skipped)"
100 fi
101 popd
102
103 pushd build_sysroot/sysroot_src/library/core/tests
104 echo "[TEST] libcore"
105 rm -r ./target || true
106 ../../../../../cargo.sh test
107 popd
108
109 pushd regex
110 echo "[TEST] rust-lang/regex example shootout-regex-dna"
111 ../cargo.sh clean
112 # Make sure `[codegen mono items] start` doesn't poison the diff
113 ../cargo.sh build --example shootout-regex-dna
114 cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt
115 diff -u res.txt examples/regexdna-output.txt
116
117 echo "[TEST] rust-lang/regex tests"
118 ../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options
119 popd