build_gcc.sh (2086B)
1 #!/usr/bin/env bash 2 #===- libcxx/utils/docker/scripts/build-gcc.sh ----------------------------===// 3 # 4 # The LLVM Compiler Infrastructure 5 # 6 # This file is distributed under the University of Illinois Open Source 7 # License. See LICENSE.TXT for details. 8 # 9 #===-----------------------------------------------------------------------===// 10 11 set -e 12 13 14 function show_usage() { 15 cat << EOF 16 Usage: build-gcc.sh [options] 17 18 Run autoconf with the specified arguments. Used inside docker container. 19 20 Available options: 21 -h|--help show this help message 22 --source the source path from which to run the configuration. 23 --to destination directory where to install the targets. 24 Required options: --to, at least one --install-target. 25 26 All options after '--' are passed to CMake invocation. 27 EOF 28 } 29 30 GCC_INSTALL_DIR="" 31 GCC_SOURCE_DIR="" 32 33 while [[ $# -gt 0 ]]; do 34 case "$1" in 35 --to) 36 shift 37 GCC_INSTALL_DIR="$1" 38 shift 39 ;; 40 --source) 41 shift 42 GCC_SOURCE_DIR="$1" 43 shift 44 ;; 45 -h|--help) 46 show_usage 47 exit 0 48 ;; 49 *) 50 echo "Unknown option: $1" 51 exit 1 52 esac 53 done 54 55 if [ "$GCC_INSTALL_DIR" == "" ]; then 56 echo "No install directory. Please specify the --to argument." 57 exit 1 58 fi 59 60 if [ "$GCC_SOURCE_DIR" == "" ]; then 61 echo "No source directory. Please specify the --source argument." 62 exit 1 63 fi 64 65 GCC_NAME=`basename $GCC_SOURCE_DIR` 66 GCC_BUILD_DIR="/tmp/gcc-build-root/build-$GCC_NAME" 67 68 mkdir -p "$GCC_INSTALL_DIR" 69 mkdir -p "$GCC_BUILD_DIR" 70 pushd "$GCC_BUILD_DIR" 71 72 # Run the build as specified in the build arguments. 73 echo "Running configuration" 74 $GCC_SOURCE_DIR/configure --prefix=$GCC_INSTALL_DIR \ 75 --disable-bootstrap --disable-libgomp --disable-libitm \ 76 --disable-libvtv --disable-libcilkrts --disable-libmpx \ 77 --disable-liboffloadmic --disable-libcc1 --enable-languages=c,c++ 78 79 NPROC=`nproc` 80 echo "Running build with $NPROC threads" 81 make -j$NPROC 82 83 echo "Installing to $GCC_INSTALL_DIR" 84 make install -j$NPROC 85 86 popd 87 88 # Cleanup. 89 rm -rf "$GCC_BUILD_DIR" 90 91 echo "Done"