blob: 85feb16acd6a3fafa8303dae42b5a3ec1ad8a257 [file] [log] [blame]
Eric Fiselier9c97ca12018-11-19 18:43:31 +00001#!/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
11set -e
12
13
14function show_usage() {
15 cat << EOF
16Usage: build-gcc.sh [options]
17
18Run autoconf with the specified arguments. Used inside docker container.
19
20Available 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.
24Required options: --to, at least one --install-target.
25
26All options after '--' are passed to CMake invocation.
27EOF
28}
29
30GCC_INSTALL_DIR=""
31GCC_SOURCE_DIR=""
32
33while [[ $# -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
53done
54
55if [ "$GCC_INSTALL_DIR" == "" ]; then
56 echo "No install directory. Please specify the --to argument."
57 exit 1
58fi
59
60if [ "$GCC_SOURCE_DIR" == "" ]; then
61 echo "No source directory. Please specify the --source argument."
62 exit 1
63fi
64
65GCC_NAME=`basename $GCC_SOURCE_DIR`
66GCC_BUILD_DIR="/tmp/gcc-build-root/build-$GCC_NAME"
67
68mkdir -p "$GCC_INSTALL_DIR"
69mkdir -p "$GCC_BUILD_DIR"
70pushd "$GCC_BUILD_DIR"
71
72# Run the build as specified in the build arguments.
73echo "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
79NPROC=`nproc`
80echo "Running build with $NPROC threads"
81make -j$NPROC
82
83echo "Installing to $GCC_INSTALL_DIR"
84make install -j$NPROC
85
86popd
87
88# Cleanup.
89rm -rf "$GCC_BUILD_DIR"
90
91echo "Done"