about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-01-31 18:31:33 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2021-01-31 18:31:33 +0100
commitd556c56f792756dd7cfec742b9f2e07612dc10f4 (patch)
treecad2e5a8fe6635c92a496921493d5bdc3e28c19f
parent17cffc1757dc6d8a89e2537e90c6cc5b336a66bf (diff)
downloadrust-d556c56f792756dd7cfec742b9f2e07612dc10f4.tar.gz
rust-d556c56f792756dd7cfec742b9f2e07612dc10f4.zip
Add option to build using the sysroot of rustc
-rwxr-xr-xbuild.sh37
-rwxr-xr-xtest.sh2
2 files changed, 27 insertions, 12 deletions
diff --git a/build.sh b/build.sh
index 2f8e0bbc460..598ce35ecea 100755
--- a/build.sh
+++ b/build.sh
@@ -3,7 +3,7 @@ set -e
 
 # Settings
 export CHANNEL="release"
-build_sysroot=1
+build_sysroot="clif"
 target_dir='build'
 oldbe=''
 while [[ $# != 0 ]]; do
@@ -11,8 +11,9 @@ while [[ $# != 0 ]]; do
         "--debug")
             export CHANNEL="debug"
             ;;
-        "--without-sysroot")
-            build_sysroot=0
+        "--sysroot")
+            build_sysroot=$2
+            shift
             ;;
         "--target-dir")
             target_dir=$2
@@ -23,7 +24,7 @@ while [[ $# != 0 ]]; do
             ;;
         *)
             echo "Unknown flag '$1'"
-            echo "Usage: ./build.sh [--debug] [--without-sysroot] [--target-dir DIR] [--oldbe]"
+            echo "Usage: ./build.sh [--debug] [--sysroot none|clif|llvm] [--target-dir DIR] [--oldbe]"
             exit 1
             ;;
     esac
@@ -62,10 +63,24 @@ if [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
     cp $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib/*.o "$target_dir/lib/rustlib/$TARGET_TRIPLE/lib/"
 fi
 
-if [[ "$build_sysroot" == "1" ]]; then
-    echo "[BUILD] sysroot"
-    dir=$(pwd)
-    cd "$target_dir"
-    time "$dir/build_sysroot/build_sysroot.sh"
-    cp lib/rustlib/*/lib/libstd-* lib/
-fi
+case "$build_sysroot" in
+    "none")
+        ;;
+    "llvm")
+        cp -r $(rustc --print sysroot)/lib/rustlib/$TARGET_TRIPLE/lib "$target_dir/lib/rustlib/$TARGET_TRIPLE/"
+        ;;
+    "clif")
+        echo "[BUILD] sysroot"
+        dir=$(pwd)
+        cd "$target_dir"
+        time "$dir/build_sysroot/build_sysroot.sh"
+        cp lib/rustlib/*/lib/libstd-* lib/
+        ;;
+    *)
+        echo "Unknown sysroot kind \`$build_sysroot\`."
+        echo "The allowed values are:"
+        echo "    none A sysroot that doesn't contain the standard library"
+        echo "    llvm Copy the sysroot from rustc compiled by cg_llvm"
+        echo "    clif Build a new sysroot using cg_clif"
+        exit 1
+esac
diff --git a/test.sh b/test.sh
index 97d82c18d97..5ab10e0e905 100755
--- a/test.sh
+++ b/test.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 set -e
 
-./build.sh --without-sysroot "$@"
+./build.sh --sysroot none "$@"
 
 rm -r target/out || true