55set -e
66# set -x
77
8- if [ -f ./gcc_path ]; then
9- export GCC_PATH=$( cat gcc_path)
10- else
11- echo ' Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
12- exit 1
13- fi
14-
15- export LD_LIBRARY_PATH=" $GCC_PATH "
16- export LIBRARY_PATH=" $GCC_PATH "
17-
188flags=
199gcc_master_branch=1
2010channel=" debug"
2111funcs=()
2212build_only=0
2313nb_parts=0
2414current_part=0
15+ use_system_gcc=0
16+ use_backend=0
17+ cargo_target_dir=" "
18+
19+ export CHANNEL=' debug'
2520
2621while [[ $# -gt 0 ]]; do
2722 case $1 in
2823 --release)
2924 codegen_channel=release
3025 channel=" release"
26+ export CHANNEL=' release'
3127 shift
3228 ;;
3329 --release-sysroot)
@@ -111,6 +107,22 @@ while [[ $# -gt 0 ]]; do
111107 build_only=1
112108 shift
113109 ;;
110+ " --use-system-gcc" )
111+ use_system_gcc=1
112+ shift
113+ ;;
114+ " --use-backend" )
115+ use_backend=1
116+ shift
117+ export BUILTIN_BACKEND=$1
118+ shift
119+ ;;
120+ " --out-dir" )
121+ shift
122+ export CARGO_TARGET_DIR=$1
123+ cargo_target_dir=$1
124+ shift
125+ ;;
114126 " --nb-parts" )
115127 shift
116128 nb_parts=$1
@@ -128,13 +140,25 @@ while [[ $# -gt 0 ]]; do
128140 esac
129141done
130142
131- if [[ $channel == " release" ]]; then
132- export CHANNEL=' release'
133- CARGO_INCREMENTAL=1 cargo rustc --release $flags
143+ if [ -f ./gcc_path ]; then
144+ export GCC_PATH=$( cat gcc_path)
145+ elif (( $use_system_gcc == 1 )) ; then
146+ echo ' Using system GCC'
134147else
135- echo $LD_LIBRARY_PATH
136- export CHANNEL=' debug'
137- cargo rustc $flags
148+ echo ' Please put the path to your custom build of libgccjit in the file `gcc_path`, see Readme.md for details'
149+ exit 1
150+ fi
151+
152+ export LD_LIBRARY_PATH=" $GCC_PATH "
153+ export LIBRARY_PATH=" $GCC_PATH "
154+
155+ if [[ $use_backend == 0 ]]; then
156+ if [[ $channel == " release" ]]; then
157+ CARGO_INCREMENTAL=1 cargo rustc --release $flags
158+ else
159+ echo $LD_LIBRARY_PATH
160+ cargo rustc $flags
161+ fi
138162fi
139163
140164if (( $build_only == 1 )) ; then
145169source config.sh
146170
147171function clean() {
148- rm -r target/out || true
149- mkdir -p target/out /gccjit
172+ rm -r $cargo_target_dir || true
173+ mkdir -p $cargo_target_dir /gccjit
150174}
151175
152176function mini_tests() {
153177 echo " [BUILD] mini_core"
154178 crate_types=" lib,dylib"
179+
155180 if [[ " $HOST_TRIPLE " != " $TARGET_TRIPLE " ]]; then
156181 crate_types=" lib"
157182 fi
158- $RUSTC example/mini_core.rs --crate-name mini_core --crate-type $crate_types --target $TARGET_TRIPLE
183+
184+ $RUST_CMD example/mini_core.rs --crate-name mini_core --crate-type $crate_types --target $TARGET_TRIPLE
159185
160186 echo " [BUILD] example"
161- $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
187+ $RUST_CMD example/example.rs --crate-type lib --target $TARGET_TRIPLE
162188
163189 echo " [AOT] mini_core_hello_world"
164- $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
165- $RUN_WRAPPER ./target/out /mini_core_hello_world abc bcd
190+ $RUST_CMD example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
191+ $RUN_WRAPPER $cargo_target_dir /mini_core_hello_world abc bcd
166192}
167193
168194function build_sysroot() {
@@ -189,42 +215,42 @@ function run_in_vm() {
189215
190216function std_tests() {
191217 echo " [AOT] arbitrary_self_types_pointers_and_wrappers"
192- $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
193- $RUN_WRAPPER ./target/out /arbitrary_self_types_pointers_and_wrappers
218+ $RUST_CMD example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
219+ $RUN_WRAPPER $cargo_target_dir /arbitrary_self_types_pointers_and_wrappers
194220
195221 echo " [AOT] alloc_system"
196- $RUSTC example/alloc_system.rs --crate-type lib --target " $TARGET_TRIPLE "
222+ $RUST_CMD example/alloc_system.rs --crate-type lib --target " $TARGET_TRIPLE "
197223
198224 # FIXME: doesn't work on m68k.
199225 if [[ " $HOST_TRIPLE " == " $TARGET_TRIPLE " ]]; then
200226 echo " [AOT] alloc_example"
201- $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
202- $RUN_WRAPPER ./target/out /alloc_example
227+ $RUST_CMD example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
228+ $RUN_WRAPPER $cargo_target_dir /alloc_example
203229 fi
204230
205231 echo " [AOT] dst_field_align"
206232 # FIXME(antoyo): Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
207- $RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
208- $RUN_WRAPPER ./target/out /dst_field_align || (echo $? ; false)
233+ $RUST_CMD example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
234+ $RUN_WRAPPER $cargo_target_dir /dst_field_align || (echo $? ; false)
209235
210236 echo " [AOT] std_example"
211237 std_flags=" --cfg feature=\" master\" "
212238 if (( $gcc_master_branch == 0 )) ; then
213239 std_flags=" "
214240 fi
215- $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE $std_flags
216- $RUN_WRAPPER ./target/out /std_example --target $TARGET_TRIPLE
241+ $RUST_CMD example/std_example.rs --crate-type bin --target $TARGET_TRIPLE $std_flags
242+ $RUN_WRAPPER $cargo_target_dir /std_example --target $TARGET_TRIPLE
217243
218244 echo " [AOT] subslice-patterns-const-eval"
219- $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
220- $RUN_WRAPPER ./target/out /subslice-patterns-const-eval
245+ $RUST_CMD example/subslice-patterns-const-eval.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
246+ $RUN_WRAPPER $cargo_target_dir /subslice-patterns-const-eval
221247
222248 echo " [AOT] track-caller-attribute"
223- $RUSTC example/track-caller-attribute.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
224- $RUN_WRAPPER ./target/out /track-caller-attribute
249+ $RUST_CMD example/track-caller-attribute.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE
250+ $RUN_WRAPPER $cargo_target_dir /track-caller-attribute
225251
226252 echo " [BUILD] mod_bench"
227- $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
253+ $RUST_CMD example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
228254}
229255
230256function setup_rustc() {
@@ -233,7 +259,7 @@ function setup_rustc() {
233259 git clone https://github.com/rust-lang/rust.git || true
234260 cd rust
235261 git fetch
236- git checkout $( rustc -V | cut -d' ' -f3 | tr -d ' (' )
262+ git checkout $( $RUSTC -V | cut -d' ' -f3 | tr -d ' (' )
237263 export RUSTFLAGS=
238264
239265 rm config.toml || true
@@ -258,8 +284,8 @@ llvm-filecheck = "`which FileCheck-10 || which FileCheck-11 || which FileCheck-1
258284download-ci-llvm = false
259285EOF
260286
261- rustc -V | cut -d' ' -f3 | tr -d ' ('
262- git checkout $( rustc -V | cut -d' ' -f3 | tr -d ' (' ) tests
287+ $RUSTC -V | cut -d' ' -f3 | tr -d ' ('
288+ git checkout $( $RUSTC -V | cut -d' ' -f3 | tr -d ' (' ) tests
263289}
264290
265291function asm_tests() {
@@ -286,17 +312,17 @@ function test_libcore() {
286312# echo "[BENCH COMPILE] mod_bench"
287313
288314# COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"
289- # 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"
290- # 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"
291- # 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"
292- # 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"
315+ # COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o $cargo_target_dir /mod_bench_llvm_0 -Cpanic=abort"
316+ # COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o $cargo_target_dir /mod_bench_llvm_1 -Cpanic=abort"
317+ # COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o $cargo_target_dir /mod_bench_llvm_2 -Cpanic=abort"
318+ # COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o $cargo_target_dir /mod_bench_llvm_3 -Cpanic=abort"
293319
294320# # Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow
295321# 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"
296322
297323# echo
298324# echo "[BENCH RUN] mod_bench"
299- # hyperfine --runs ${RUN_RUNS:-10} ./target/out/ mod_bench{,_inline} ./target/out /mod_bench_llvm_*
325+ # hyperfine --runs ${RUN_RUNS:-10} $cargo_target_dir/ mod_bench{,_inline} $cargo_target_dir /mod_bench_llvm_*
300326
301327function extended_rand_tests() {
302328 if (( $gcc_master_branch == 0 )) ; then
0 commit comments