5 export CHANNEL="release"
9 while [[ $# != 0 ]]; do
12 export CHANNEL="debug"
22 oldbe='--features oldbe'
25 echo "Unknown flag '$1'"
26 echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR] [--oldbe]"
34 unset CARGO_TARGET_DIR
36 if [[ "$unamestr" == 'Linux' ]]; then
37 export RUSTFLAGS='-Clink-arg=-Wl,-rpath=$ORIGIN/../lib '$RUSTFLAGS
38 elif [[ "$unamestr" == 'Darwin' ]]; then
39 export RUSTFLAGS='-Csplit-debuginfo=unpacked -Clink-arg=-Wl,-rpath,@loader_path/../lib -Zosx-rpath-install-name '$RUSTFLAGS
45 if [[ "$CHANNEL" == "release" ]]; then
46 cargo build $oldbe --release
51 source scripts/ext_config.sh
55 mkdir "$target_dir"/bin "$target_dir"/lib
56 ln target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
57 ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
58 ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
60 mkdir -p "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
61 if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
62 cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
65 if [[ "$build_sysroot" == "1" ]]; then
66 echo "[BUILD] sysroot"
69 time "$dir/build_sysroot/build_sysroot.sh"
70 cp lib/rustlib/*/lib/libstd-* lib/