]>
Commit | Line | Data |
---|---|---|
c295e0f8 XL |
1 | #!/bin/bash |
2 | ||
3 | # TODO(antoyo): rewrite to cargo-make (or just) or something like that to only rebuild the sysroot when needed? | |
4 | ||
5 | set -e | |
6 | ||
5e7ed085 | 7 | if [ -f ./gcc_path ]; then |
c295e0f8 XL |
8 | export GCC_PATH=$(cat gcc_path) |
9 | else | |
10 | echo 'Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details' | |
11 | exit 1 | |
12 | fi | |
13 | ||
14 | export LD_LIBRARY_PATH="$GCC_PATH" | |
15 | export LIBRARY_PATH="$GCC_PATH" | |
16 | ||
5e7ed085 FG |
17 | features= |
18 | ||
19 | if [[ "$1" == "--features" ]]; then | |
20 | shift | |
21 | features="--features $1" | |
22 | shift | |
23 | fi | |
24 | ||
c295e0f8 XL |
25 | if [[ "$1" == "--release" ]]; then |
26 | export CHANNEL='release' | |
5e7ed085 | 27 | CARGO_INCREMENTAL=1 cargo rustc --release $features |
c295e0f8 XL |
28 | shift |
29 | else | |
30 | echo $LD_LIBRARY_PATH | |
31 | export CHANNEL='debug' | |
5e7ed085 FG |
32 | cargo rustc $features |
33 | fi | |
34 | ||
35 | if [[ "$1" == "--build" ]]; then | |
36 | exit | |
c295e0f8 XL |
37 | fi |
38 | ||
39 | source config.sh | |
40 | ||
41 | function clean() { | |
42 | rm -r target/out || true | |
43 | mkdir -p target/out/gccjit | |
44 | } | |
45 | ||
46 | function mini_tests() { | |
47 | echo "[BUILD] mini_core" | |
48 | $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE | |
49 | ||
50 | echo "[BUILD] example" | |
51 | $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE | |
52 | ||
53 | echo "[AOT] mini_core_hello_world" | |
54 | $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE | |
55 | $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd | |
56 | } | |
57 | ||
58 | function build_sysroot() { | |
59 | echo "[BUILD] sysroot" | |
60 | time ./build_sysroot/build_sysroot.sh | |
61 | } | |
62 | ||
63 | function std_tests() { | |
64 | echo "[AOT] arbitrary_self_types_pointers_and_wrappers" | |
65 | $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE | |
66 | $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers | |
67 | ||
68 | echo "[AOT] alloc_system" | |
69 | $RUSTC example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE" | |
70 | ||
71 | echo "[AOT] alloc_example" | |
72 | $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE | |
73 | $RUN_WRAPPER ./target/out/alloc_example | |
74 | ||
75 | echo "[AOT] dst_field_align" | |
76 | # FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. | |
77 | $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE | |
78 | $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) | |
79 | ||
80 | echo "[AOT] std_example" | |
81 | $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE | |
82 | $RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE | |
83 | ||
84 | echo "[AOT] subslice-patterns-const-eval" | |
85 | $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE | |
86 | $RUN_WRAPPER ./target/out/subslice-patterns-const-eval | |
87 | ||
88 | echo "[AOT] track-caller-attribute" | |
89 | $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE | |
90 | $RUN_WRAPPER ./target/out/track-caller-attribute | |
91 | ||
92 | echo "[BUILD] mod_bench" | |
93 | $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE | |
94 | } | |
95 | ||
96 | # FIXME(antoyo): linker gives multiple definitions error on Linux | |
97 | #echo "[BUILD] sysroot in release mode" | |
98 | #./build_sysroot/build_sysroot.sh --release | |
99 | ||
100 | # TODO(antoyo): uncomment when it works. | |
101 | #pushd simple-raytracer | |
102 | #if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then | |
103 | #echo "[BENCH COMPILE] ebobby/simple-raytracer" | |
104 | #hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ | |
105 | #"RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ | |
106 | #"../cargo.sh build" | |
107 | ||
108 | #echo "[BENCH RUN] ebobby/simple-raytracer" | |
109 | #cp ./target/*/debug/main ./raytracer_cg_gccjit | |
110 | #hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_gccjit | |
111 | #else | |
112 | #echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" | |
113 | #echo "[COMPILE] ebobby/simple-raytracer" | |
114 | #../cargo.sh build | |
115 | #echo "[BENCH RUN] ebobby/simple-raytracer (skipped)" | |
116 | #fi | |
117 | #popd | |
118 | ||
119 | function test_libcore() { | |
120 | pushd build_sysroot/sysroot_src/library/core/tests | |
121 | echo "[TEST] libcore" | |
122 | rm -r ./target || true | |
123 | ../../../../../cargo.sh test | |
124 | popd | |
125 | } | |
126 | ||
127 | # TODO(antoyo): uncomment when it works. | |
128 | #pushd regex | |
129 | #echo "[TEST] rust-lang/regex example shootout-regex-dna" | |
130 | #../cargo.sh clean | |
131 | ## Make sure `[codegen mono items] start` doesn't poison the diff | |
132 | #../cargo.sh build --example shootout-regex-dna | |
133 | #cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt | |
134 | #diff -u res.txt examples/regexdna-output.txt | |
135 | ||
136 | #echo "[TEST] rust-lang/regex tests" | |
137 | #../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options | |
138 | #popd | |
139 | ||
140 | #echo | |
141 | #echo "[BENCH COMPILE] mod_bench" | |
142 | ||
143 | #COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" | |
144 | #COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" | |
145 | #COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" | |
146 | #COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" | |
147 | #COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort" | |
148 | ||
149 | ## Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow | |
150 | #hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" | |
151 | ||
152 | #echo | |
153 | #echo "[BENCH RUN] mod_bench" | |
154 | #hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* | |
155 | ||
156 | function test_rustc() { | |
157 | echo | |
158 | echo "[TEST] rust-lang/rust" | |
159 | ||
5e7ed085 | 160 | rust_toolchain=$(cat rust-toolchain | grep channel | sed 's/channel = "\(.*\)"/\1/') |
c295e0f8 XL |
161 | |
162 | git clone https://github.com/rust-lang/rust.git || true | |
163 | cd rust | |
164 | git fetch | |
165 | git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(') | |
166 | export RUSTFLAGS= | |
167 | ||
5e7ed085 FG |
168 | git apply - <<EOF |
169 | diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs | |
170 | index 887d27fd6dca4..2c2239f2b83d1 100644 | |
171 | --- a/src/tools/compiletest/src/header.rs | |
172 | +++ b/src/tools/compiletest/src/header.rs | |
173 | @@ -806,8 +806,8 @@ pub fn make_test_description<R: Read>( | |
174 | cfg: Option<&str>, | |
175 | ) -> test::TestDesc { | |
176 | let mut ignore = false; | |
177 | #[cfg(not(bootstrap))] | |
178 | - let ignore_message: Option<String> = None; | |
179 | + let ignore_message: Option<&str> = None; | |
180 | let mut should_fail = false; | |
181 | ||
182 | let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some(); | |
183 | ||
184 | EOF | |
185 | ||
c295e0f8 XL |
186 | rm config.toml || true |
187 | ||
188 | cat > config.toml <<EOF | |
189 | [rust] | |
190 | codegen-backends = [] | |
191 | deny-warnings = false | |
192 | ||
193 | [build] | |
194 | cargo = "$(which cargo)" | |
195 | local-rebuild = true | |
196 | rustc = "$HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE/bin/rustc" | |
197 | EOF | |
198 | ||
199 | rustc -V | cut -d' ' -f3 | tr -d '(' | |
200 | git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(') src/test | |
201 | ||
202 | for test in $(rg -i --files-with-matches "//(\[\w+\])?~|// error-pattern:|// build-fail|// run-fail|-Cllvm-args" src/test/ui); do | |
203 | rm $test | |
204 | done | |
205 | ||
206 | git checkout -- src/test/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed | |
207 | ||
5e7ed085 | 208 | rm -r src/test/ui/{abi*,extern/,panic-runtime/,panics/,unsized-locals/,proc-macro/,threads-sendsync/,thinlto/,simd*,borrowck/,test*,*lto*.rs} || true |
c295e0f8 XL |
209 | for test in $(rg --files-with-matches "catch_unwind|should_panic|thread|lto" src/test/ui); do |
210 | rm $test | |
211 | done | |
212 | git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs | |
213 | git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs | |
c295e0f8 | 214 | |
a2a8927a | 215 | RUSTC_ARGS="-Zpanic-abort-tests -Csymbol-mangling-version=v0 -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot -Cpanic=abort" |
c295e0f8 XL |
216 | |
217 | echo "[TEST] rustc test suite" | |
218 | COMPILETEST_FORCE_STAGE0=1 ./x.py test --run always --stage 0 src/test/ui/ --rustc-args "$RUSTC_ARGS" | |
219 | } | |
220 | ||
221 | function clean_ui_tests() { | |
222 | find rust/build/x86_64-unknown-linux-gnu/test/ui/ -name stamp -exec rm -rf {} \; | |
223 | } | |
224 | ||
225 | case $1 in | |
226 | "--test-rustc") | |
227 | test_rustc | |
228 | ;; | |
229 | ||
230 | "--test-libcore") | |
231 | test_libcore | |
232 | ;; | |
233 | ||
234 | "--clean-ui-tests") | |
235 | clean_ui_tests | |
236 | ;; | |
237 | ||
5e7ed085 FG |
238 | "--std-tests") |
239 | std_tests | |
240 | ;; | |
241 | ||
242 | "--build-sysroot") | |
243 | build_sysroot | |
244 | ;; | |
245 | ||
c295e0f8 XL |
246 | *) |
247 | clean | |
248 | mini_tests | |
249 | build_sysroot | |
250 | std_tests | |
251 | test_libcore | |
252 | test_rustc | |
253 | ;; | |
254 | esac |