@@ -17,6 +17,7 @@ export LIBRARY_PATH="$GCC_PATH"
1717if [[ " $1 " == " --release" ]]; then
1818 export CHANNEL=' release'
1919 CARGO_INCREMENTAL=1 cargo rustc --release
20+ shift
2021else
2122 echo $LD_LIBRARY_PATH
2223 export CHANNEL=' debug'
2526
2627source config.sh
2728
28- rm -r target/out || true
29- mkdir -p target/out/gccjit
29+ function clean() {
30+ rm -r target/out || true
31+ mkdir -p target/out/gccjit
32+ }
3033
31- echo " [BUILD] mini_core"
32- $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
34+ function mini_tests() {
35+ echo " [BUILD] mini_core"
36+ $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
3337
34- echo " [BUILD] example"
35- $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
38+ echo " [BUILD] example"
39+ $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
3640
37- echo " [AOT] mini_core_hello_world"
38- $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
39- $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
41+ echo " [AOT] mini_core_hello_world"
42+ $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
43+ $RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
44+ }
4045
41- echo " [BUILD] sysroot"
42- time ./build_sysroot/build_sysroot.sh
46+ function build_sysroot() {
47+ echo " [BUILD] sysroot"
48+ time ./build_sysroot/build_sysroot.sh
49+ }
4350
44- echo " [AOT] arbitrary_self_types_pointers_and_wrappers"
45- $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
46- $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
51+ function std_tests() {
52+ echo " [AOT] arbitrary_self_types_pointers_and_wrappers"
53+ $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
54+ $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
4755
48- echo " [AOT] alloc_system"
49- $RUSTC example/alloc_system.rs --crate-type lib --target " $TARGET_TRIPLE "
56+ echo " [AOT] alloc_system"
57+ $RUSTC example/alloc_system.rs --crate-type lib --target " $TARGET_TRIPLE "
5058
51- echo " [AOT] alloc_example"
52- $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
53- $RUN_WRAPPER ./target/out/alloc_example
59+ echo " [AOT] alloc_example"
60+ $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
61+ $RUN_WRAPPER ./target/out/alloc_example
5462
55- echo " [AOT] dst_field_align"
56- # FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
57- $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
58- $RUN_WRAPPER ./target/out/dst_field_align || (echo $? ; false)
63+ echo " [AOT] dst_field_align"
64+ # FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
65+ $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
66+ $RUN_WRAPPER ./target/out/dst_field_align || (echo $? ; false)
5967
60- echo " [AOT] std_example"
61- $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
62- $RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE
68+ echo " [AOT] std_example"
69+ $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
70+ $RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE
6371
64- echo " [AOT] subslice-patterns-const-eval"
65- $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
66- $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
72+ echo " [AOT] subslice-patterns-const-eval"
73+ $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
74+ $RUN_WRAPPER ./target/out/subslice-patterns-const-eval
6775
68- echo " [AOT] track-caller-attribute"
69- $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
70- $RUN_WRAPPER ./target/out/track-caller-attribute
76+ echo " [AOT] track-caller-attribute"
77+ $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
78+ $RUN_WRAPPER ./target/out/track-caller-attribute
7179
72- echo " [BUILD] mod_bench"
73- $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
80+ echo " [BUILD] mod_bench"
81+ $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
82+ }
7483
7584# FIXME(antoyo): linker gives multiple definitions error on Linux
7685# echo "[BUILD] sysroot in release mode"
@@ -95,11 +104,13 @@ $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
95104# fi
96105# popd
97106
98- pushd build_sysroot/sysroot_src/library/core/tests
99- echo " [TEST] libcore"
100- rm -r ./target || true
101- ../../../../../cargo.sh test
102- popd
107+ function test_libcore() {
108+ pushd build_sysroot/sysroot_src/library/core/tests
109+ echo " [TEST] libcore"
110+ rm -r ./target || true
111+ ../../../../../cargo.sh test
112+ popd
113+ }
103114
104115# TODO(antoyo): uncomment when it works.
105116# pushd regex
@@ -130,20 +141,21 @@ popd
130141# echo "[BENCH RUN] mod_bench"
131142# hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_*
132143
133- echo
134- echo " [TEST] rust-lang/rust"
144+ function test_rustc() {
145+ echo
146+ echo " [TEST] rust-lang/rust"
135147
136- rust_toolchain=$( cat rust-toolchain)
148+ rust_toolchain=$( cat rust-toolchain)
137149
138- git clone https://github.com/rust-lang/rust.git || true
139- cd rust
140- git fetch
141- git checkout $( rustc -V | cut -d' ' -f3 | tr -d ' (' )
142- export RUSTFLAGS=
150+ git clone https://github.com/rust-lang/rust.git || true
151+ cd rust
152+ git fetch
153+ git checkout $( rustc -V | cut -d' ' -f3 | tr -d ' (' )
154+ export RUSTFLAGS=
143155
144- rm config.toml || true
156+ rm config.toml || true
145157
146- cat > config.toml << EOF
158+ cat > config.toml << EOF
147159[rust]
148160codegen-backends = []
149161deny-warnings = false
@@ -154,24 +166,52 @@ local-rebuild = true
154166rustc = "$HOME /.rustup/toolchains/$rust_toolchain -$TARGET_TRIPLE /bin/rustc"
155167EOF
156168
157- rustc -V | cut -d' ' -f3 | tr -d ' ('
158- git checkout $( rustc -V | cut -d' ' -f3 | tr -d ' (' ) src/test
159-
160- for test in $( rg -i --files-with-matches " //(\[\w+\])?~|// error-pattern:|// build-fail|// run-fail|-Cllvm-args" src/test/ui) ; do
161- rm $test
162- done
163-
164- git checkout -- src/test/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed
165-
166- rm -r src/test/ui/{abi* ,extern/,llvm-asm/,panic-runtime/,panics/,unsized-locals/,proc-macro/,threads-sendsync/,thinlto/,simd* ,borrowck/,test* ,* lto* .rs} || true
167- for test in $( rg --files-with-matches " catch_unwind|should_panic|thread|lto" src/test/ui) ; do
168- rm $test
169- done
170- git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs
171- git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs
172- rm src/test/ui/llvm-asm/llvm-asm-in-out-operand.rs || true # TODO(antoyo): Enable back this test if I ever implement the llvm_asm! macro.
173-
174- RUSTC_ARGS=" -Zpanic-abort-tests -Zsymbol-mangling-version=v0 -Zcodegen-backend=" $( pwd) " /../target/" $CHANNEL " /librustc_codegen_gcc." $dylib_ext " --sysroot " $( pwd) " /../build_sysroot/sysroot -Cpanic=abort"
175-
176- echo " [TEST] rustc test suite"
177- COMPILETEST_FORCE_STAGE0=1 ./x.py test --run always --stage 0 src/test/ui/ --rustc-args " $RUSTC_ARGS "
169+ rustc -V | cut -d' ' -f3 | tr -d ' ('
170+ git checkout $( rustc -V | cut -d' ' -f3 | tr -d ' (' ) src/test
171+
172+ for test in $( rg -i --files-with-matches " //(\[\w+\])?~|// error-pattern:|// build-fail|// run-fail|-Cllvm-args" src/test/ui) ; do
173+ rm $test
174+ done
175+
176+ git checkout -- src/test/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed
177+
178+ rm -r src/test/ui/{abi* ,extern/,llvm-asm/,panic-runtime/,panics/,unsized-locals/,proc-macro/,threads-sendsync/,thinlto/,simd* ,borrowck/,test* ,* lto* .rs} || true
179+ for test in $( rg --files-with-matches " catch_unwind|should_panic|thread|lto" src/test/ui) ; do
180+ rm $test
181+ done
182+ git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs
183+ git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs
184+ rm src/test/ui/llvm-asm/llvm-asm-in-out-operand.rs || true # TODO(antoyo): Enable back this test if I ever implement the llvm_asm! macro.
185+
186+ RUSTC_ARGS=" -Zpanic-abort-tests -Zsymbol-mangling-version=v0 -Zcodegen-backend=" $( pwd) " /../target/" $CHANNEL " /librustc_codegen_gcc." $dylib_ext " --sysroot " $( pwd) " /../build_sysroot/sysroot -Cpanic=abort"
187+
188+ echo " [TEST] rustc test suite"
189+ COMPILETEST_FORCE_STAGE0=1 ./x.py test --run always --stage 0 src/test/ui/ --rustc-args " $RUSTC_ARGS "
190+ }
191+
192+ function clean_ui_tests() {
193+ find rust/build/x86_64-unknown-linux-gnu/test/ui/ -name stamp -exec rm -rf {} \;
194+ }
195+
196+ case $1 in
197+ " --test-rustc" )
198+ test_rustc
199+ ;;
200+
201+ " --test-libcore" )
202+ test_libcore
203+ ;;
204+
205+ " --clean-ui-tests" )
206+ clean_ui_tests
207+ ;;
208+
209+ * )
210+ clean
211+ mini_tests
212+ build_sysroot
213+ std_tests
214+ test_libcore
215+ test_rustc
216+ ;;
217+ esac
0 commit comments