]> git.lizzy.rs Git - rust.git/blob - scripts/config.sh
fix shellcheck error of SC2148
[rust.git] / scripts / config.sh
1 #!/usr/bin/env bash
2 set -e
3
4 unamestr=`uname`
5 if [[ "$unamestr" == 'Linux' ]]; then
6    dylib_ext='so'
7 elif [[ "$unamestr" == 'Darwin' ]]; then
8    dylib_ext='dylib'
9 else
10    echo "Unsupported os"
11    exit 1
12 fi
13
14 HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ")
15 TARGET_TRIPLE=$HOST_TRIPLE
16 #TARGET_TRIPLE="x86_64-pc-windows-gnu"
17 #TARGET_TRIPLE="aarch64-unknown-linux-gnu"
18
19 linker=''
20 RUN_WRAPPER=''
21 export JIT_SUPPORTED=1
22 if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
23    export JIT_SUPPORTED=0
24    if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
25       # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
26       linker='-Clinker=aarch64-linux-gnu-gcc'
27       RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu'
28    elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
29       # We are cross-compiling for Windows. Run tests in wine.
30       RUN_WRAPPER='wine'
31    else
32       echo "Unknown non-native platform"
33    fi
34 fi
35
36 if echo "$RUSTC_WRAPPER" | grep sccache; then
37 echo
38 echo -e "\x1b[1;93m=== Warning: Unset RUSTC_WRAPPER to prevent interference with sccache ===\x1b[0m"
39 echo
40 export RUSTC_WRAPPER=
41 fi
42
43 dir=$(cd $(dirname "$BASH_SOURCE"); pwd)
44
45 export RUSTC=$dir"/cg_clif"
46 export RUSTFLAGS=$linker
47 export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\
48 '-Zcodegen-backend='$dir'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir'/sysroot'
49
50 # FIXME remove once the atomic shim is gone
51 if [[ `uname` == 'Darwin' ]]; then
52    export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
53 fi
54
55 export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib"
56 export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
57
58 export CG_CLIF_DISPLAY_CG_TIME=1