]> git.lizzy.rs Git - rust.git/blob - config.sh
Document running rust code from the shell
[rust.git] / 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="aarch64-unknown-linux-gnu"
16
17 linker=''
18 RUN_WRAPPER=''
19 if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
20    if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then
21       # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
22       linker='-Clinker=aarch64-linux-gnu-gcc'
23       RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu'
24    else
25       echo "Unknown non-native platform"
26    fi
27 fi
28
29 export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
30
31 # FIXME remove once the atomic shim is gone
32 if [[ `uname` == 'Darwin' ]]; then
33    export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
34 fi
35
36 RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
37 export RUSTC_LOG=warn # display metadata load errors
38
39 export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib"
40 export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
41
42 export CG_CLIF_DISPLAY_CG_TIME=1
43 export CG_CLIF_INCR_CACHE_DISABLED=1