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