5 export CHANNEL="release"
9 while [[ $# != 0 ]]; do
12 export CHANNEL="debug"
23 oldbe='--features oldbe'
26 echo "Unknown flag '$1'"
27 echo "Usage: ./build.sh [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--oldbe]"
35 unset CARGO_TARGET_DIR
37 if [[ "$unamestr" == 'Linux' ]]; then
38 export RUSTFLAGS='-Clink-arg=-Wl,-rpath=$ORIGIN/../lib '$RUSTFLAGS
39 elif [[ "$unamestr" == 'Darwin' ]]; then
40 export RUSTFLAGS='-Csplit-debuginfo=unpacked -Clink-arg=-Wl,-rpath,@loader_path/../lib -Zosx-rpath-install-name '$RUSTFLAGS
46 if [[ "$CHANNEL" == "release" ]]; then
47 cargo build $oldbe --release
52 source scripts/ext_config.sh
56 mkdir "$target_dir"/bin "$target_dir"/lib
57 ln target/$CHANNEL/cg_clif{,_build_sysroot} "$target_dir"/bin
58 ln target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir"/lib
59 ln rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
61 mkdir -p "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
62 if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
63 cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
66 case "$build_sysroot" in
70 cp -r $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib "$target_dir/lib/rustlib/$TARGET_TRIPLE/"
73 echo "[BUILD] sysroot"
76 time "$dir/build_sysroot/build_sysroot.sh"
77 cp lib/rustlib/*/lib/libstd-* lib/
80 echo "Unknown sysroot kind \`$build_sysroot\`."
81 echo "The allowed values are:"
82 echo " none A sysroot that doesn't contain the standard library"
83 echo " llvm Copy the sysroot from rustc compiled by cg_llvm"
84 echo " clif Build a new sysroot using cg_clif"