3 # TODO(antoyo): rewrite to cargo-make (or just) or something like that to only rebuild the sysroot when needed?
7 if [ -f .
/gcc_path
]; then
8 export GCC_PATH
=$
(cat gcc_path
)
10 echo 'Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
14 export LD_LIBRARY_PATH
="$GCC_PATH"
15 export LIBRARY_PATH
="$GCC_PATH"
23 while [[ $# -gt 0 ]]; do
26 codegen_channel
=release
30 sysroot_channel
=release
33 --no-default-features)
35 flags
="$flags --no-default-features"
40 flags
="$flags --features $1"
68 func
=extended_sysroot_tests
81 echo "Unknown option $1"
87 if [[ $channel == "release" ]]; then
88 export CHANNEL
='release'
89 CARGO_INCREMENTAL
=1 cargo rustc
--release $flags
93 export CHANNEL
='debug'
97 if (( $build_only == 1 )); then
104 rm -r target
/out || true
105 mkdir
-p target
/out
/gccjit
108 function mini_tests
() {
109 echo "[BUILD] mini_core"
110 $RUSTC example
/mini_core.rs
--crate-name mini_core
--crate-type lib
,dylib
--target $TARGET_TRIPLE
112 echo "[BUILD] example"
113 $RUSTC example
/example.rs
--crate-type lib
--target $TARGET_TRIPLE
115 echo "[AOT] mini_core_hello_world"
116 $RUSTC example
/mini_core_hello_world.rs
--crate-name mini_core_hello_world
--crate-type bin
-g --target $TARGET_TRIPLE
117 $RUN_WRAPPER .
/target
/out
/mini_core_hello_world abc bcd
120 function build_sysroot
() {
121 echo "[BUILD] sysroot"
122 time .
/build_sysroot
/build_sysroot.sh
125 function std_tests
() {
126 echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
127 $RUSTC example
/arbitrary_self_types_pointers_and_wrappers.rs
--crate-name arbitrary_self_types_pointers_and_wrappers
--crate-type bin
--target $TARGET_TRIPLE
128 $RUN_WRAPPER .
/target
/out
/arbitrary_self_types_pointers_and_wrappers
130 echo "[AOT] alloc_system"
131 $RUSTC example
/alloc_system.rs
--crate-type lib
--target "$TARGET_TRIPLE"
133 echo "[AOT] alloc_example"
134 $RUSTC example
/alloc_example.rs
--crate-type bin
--target $TARGET_TRIPLE
135 $RUN_WRAPPER .
/target
/out
/alloc_example
137 echo "[AOT] dst_field_align"
138 # FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
139 $RUSTC example
/dst-field-align.rs
--crate-name dst_field_align
--crate-type bin
--target $TARGET_TRIPLE
140 $RUN_WRAPPER .
/target
/out
/dst_field_align ||
(echo $?
; false
)
142 echo "[AOT] std_example"
143 std_flags
="--cfg feature=\"master\""
144 if (( $gcc_master_branch == 0 )); then
147 $RUSTC example
/std_example.rs
--crate-type bin
--target $TARGET_TRIPLE $std_flags
148 $RUN_WRAPPER .
/target
/out
/std_example
--target $TARGET_TRIPLE
150 echo "[AOT] subslice-patterns-const-eval"
151 $RUSTC example
/subslice-patterns-const-eval.rs
--crate-type bin
-Cpanic=abort
--target $TARGET_TRIPLE
152 $RUN_WRAPPER .
/target
/out
/subslice-patterns-const-eval
154 echo "[AOT] track-caller-attribute"
155 $RUSTC example
/track-caller-attribute.rs
--crate-type bin
-Cpanic=abort
--target $TARGET_TRIPLE
156 $RUN_WRAPPER .
/target
/out
/track-caller-attribute
158 echo "[BUILD] mod_bench"
159 $RUSTC example
/mod_bench.rs
--crate-type bin
--target $TARGET_TRIPLE
162 # FIXME(antoyo): linker gives multiple definitions error on Linux
163 #echo "[BUILD] sysroot in release mode"
164 #./build_sysroot/build_sysroot.sh --release
166 function test_libcore
() {
167 pushd build_sysroot
/sysroot_src
/library
/core
/tests
168 echo "[TEST] libcore"
169 rm -r .
/target || true
170 ..
/..
/..
/..
/..
/cargo.sh
test
175 #echo "[BENCH COMPILE] mod_bench"
177 #COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
178 #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"
179 #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"
180 #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"
181 #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"
183 ## Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow
184 #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"
187 #echo "[BENCH RUN] mod_bench"
188 #hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_*
190 function extended_sysroot_tests
() {
191 if (( $gcc_master_branch == 0 )); then
197 echo "[TEST] rust-random/rand"
198 ..
/cargo.sh
test --workspace
201 #pushd simple-raytracer
202 #echo "[BENCH COMPILE] ebobby/simple-raytracer"
203 #hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
204 #"RUSTC=rustc RUSTFLAGS='' cargo build" \
207 #echo "[BENCH RUN] ebobby/simple-raytracer"
208 #cp ./target/debug/main ./raytracer_cg_gcc
209 #hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_gcc
213 echo "[TEST] rust-lang/regex example shootout-regex-dna"
215 export CG_RUSTFLAGS
="--cap-lints warn" # newer aho_corasick versions throw a deprecation warning
216 # Make sure `[codegen mono items] start` doesn't poison the diff
217 ..
/cargo.sh build
--example shootout-regex-dna
218 cat examples
/regexdna-input.txt \
219 | ..
/cargo.sh run
--example shootout-regex-dna \
220 |
grep -v "Spawned thread" > res.txt
221 diff -u res.txt examples
/regexdna-output.txt
223 echo "[TEST] rust-lang/regex tests"
224 ..
/cargo.sh
test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
228 function test_rustc
() {
230 echo "[TEST] rust-lang/rust"
232 rust_toolchain
=$
(cat rust-toolchain |
grep channel |
sed 's/channel = "\(.*\)"/\1/')
234 git clone https
://github.com
/rust-lang
/rust.git || true
237 git checkout $
(rustc
-V | cut
-d' ' -f3 |
tr -d '(')
240 git apply ..
/rustc_patches
/compile_test.
patch || true
242 rm config.toml || true
244 cat > config.toml
<<EOF
246 codegen-backends = []
247 deny-warnings = false
250 cargo = "$(which cargo)"
252 rustc = "$HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE/bin/rustc"
255 rustc
-V | cut
-d' ' -f3 |
tr -d '('
256 git checkout $
(rustc
-V | cut
-d' ' -f3 |
tr -d '(') src
/test
258 for test in $
(rg
-i --files-with-matches "//(\[\w+\])?~|// error-pattern:|// build-fail|// run-fail|-Cllvm-args" src
/test
/ui
); do
262 git checkout
-- src
/test
/ui
/issues
/auxiliary
/issue-3136-a.rs
# contains //~ERROR, but shouldn't be removed
264 rm -r src
/test
/ui
/{abi
*,extern
/,panic-runtime
/,panics
/,unsized-locals
/,proc-macro
/,threads-sendsync
/,thinlto
/,borrowck
/,test*,*lto
*.rs
} || true
265 for test in $
(rg
--files-with-matches "catch_unwind|should_panic|thread|lto" src
/test
/ui
); do
268 git checkout src
/test
/ui
/type-alias-impl-trait
/auxiliary
/cross_crate_ice.rs
269 git checkout src
/test
/ui
/type-alias-impl-trait
/auxiliary
/cross_crate_ice2.rs
271 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"
273 echo "[TEST] rustc test suite"
274 COMPILETEST_FORCE_STAGE0
=1 .
/x.py
test --run always
--stage 0 src
/test
/ui
/ --rustc-args "$RUSTC_ARGS"
277 function clean_ui_tests
() {
278 find rust
/build
/x86_64-unknown-linux-gnu
/test
/ui
/ -name stamp
-exec rm -rf {} \
;
287 extended_sysroot_tests