]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/build.sh
Rollup merge of #79174 - taiki-e:std-future, r=Mark-Simulacrum
[rust.git] / compiler / rustc_codegen_cranelift / build.sh
1 #!/bin/bash
2 set -e
3
4 # Settings
5 export CHANNEL="release"
6 build_sysroot=1
7 target_dir='build'
8 while [[ $# != 0 ]]; do
9     case $1 in
10         "--debug")
11             export CHANNEL="debug"
12             ;;
13         "--without-sysroot")
14             build_sysroot=0
15             ;;
16         "--target-dir")
17             target_dir=$2
18             shift
19             ;;
20         *)
21             echo "Unknown flag '$1'"
22             echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR]"
23             ;;
24     esac
25     shift
26 done
27
28 # Build cg_clif
29 unset CARGO_TARGET_DIR
30 export RUSTFLAGS="-Zrun_dsymutil=no"
31 unamestr=$(uname)
32 if [[ "$unamestr" == 'Linux' ]]; then
33    export RUSTFLAGS='-Clink-arg=-Wl,-rpath=$ORIGIN/../lib '$RUSTFLAGS
34 elif [[ "$unamestr" == 'Darwin' ]]; then
35    export RUSTFLAGS='-Clink-arg=-Wl,-rpath,@loader_path/../lib -Zosx-rpath-install-name '$RUSTFLAGS
36    dylib_ext='dylib'
37 else
38    echo "Unsupported os"
39    exit 1
40 fi
41 if [[ "$CHANNEL" == "release" ]]; then
42     cargo build --release
43 else
44     cargo build
45 fi
46
47 rm -rf "$target_dir"
48 mkdir "$target_dir"
49 mkdir "$target_dir"/bin "$target_dir"/lib
50 ln target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
51 ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
52 ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
53
54 if [[ "$build_sysroot" == "1" ]]; then
55     echo "[BUILD] sysroot"
56     export CG_CLIF_INCR_CACHE_DISABLED=1
57     dir=$(pwd)
58     cd "$target_dir"
59     time "$dir/build_sysroot/build_sysroot.sh"
60 fi