From 5aa5ab4ed7e4259d14743fb916f922b77a5b695a Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Sun, 7 Apr 2019 01:18:21 +0100 Subject: --host-cc configure option to avoid building GCC, M4 mandatory In some cases (specially when debugging the pipeline), its very time-consuming to install GCC. With this commit, a `--host-cc' option has been added to avoid building the C compiler when necessary. The test to see if `sys/cdefs.h' is available on the system (necessary to build GCC) has also been moved to the configure script to print a more visible warning and also use the new `host_cc' variable to let `dependencies-basic.mk' know that GCC shouldn't be built. Finally, we are having problems installing M4 from source, so it has been set as a mandatory dependency. --- configure | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 6f4895b..6059c0e 100755 --- a/configure +++ b/configure @@ -35,6 +35,7 @@ set -e jobs=0 build_dir= input_dir= +host_cc=0 software_dir= existing_conf=0 minmapsize=10000000000 @@ -79,6 +80,7 @@ Configure options: -s, --software-dir=STR Directory containing necessary software tarballs. Operating mode options: + --host-cc Use host system's C compiler, don't build GCC. -m, --minmapsize=INT (Gnuastro) Minimum number of bytes to use RAM. -j, --jobs=INT Number of threads to build the software. -e, --existing-conf Use (possibly existing) local configuration. @@ -148,6 +150,8 @@ do -m*) minmapsize=$(echo "$1" | sed -e's/-m//'); check_v "$1" "$minmapsize"; shift;; # Operating mode options + --host-cc) host_cc=1; shift;; + --host-cc=*) on_off_option_error --host-cc;; -j|--jobs) jobs="$2"; check_v "$1" "$jobs"; shift;shift;; -j=*|--jobs=*) jobs="${1#*=}"; check_v "$1" "$jobs"; shift;; -j*) jobs=$(echo "$1" | sed -e's/-j//'); check_v "$1" "$jobs"; shift;; @@ -800,7 +804,12 @@ fi # For the time being, we'll use the existance of `otool' to see if we are # on a Mac OS system or not. Some tools (for example OpenSSL) need to know # this. +# +# On Mac OS, the building of GCC crashes sometimes while building libiberty +# with CLang's `g++'. Until we find a solution, we'll just use the host's C +# compiler. if type otool > /dev/null 2>/dev/null; then + host_cc=1 on_mac_os=yes else on_mac_os=no @@ -865,6 +874,53 @@ fi +# See if GCC can be built +# ----------------------- +# +# On some GNU/Linux distros, the C compiler is broken into `multilib' (for +# 32-bit and 64-bit support, with their own headers). On these systems, +# `sys/cdefs.h' is not available by default. So if the user hasn't manually +# installed it before this configure script, GCC won't build. We are thus +# explicitly testing a small C program here to see if the host's C compiler +# won't have any problems in building GCC. +if [ $host_cc = 0 ]; then + tfile=$bdir/gcc-cdefs-test.c; + echo "#include " > $$tfile; + echo "int main(void){return 0;}" >> $$tfile; + if gcc $$tfile -o $bdir/gcc-cdefs-test &> /dev/null; then + rm $bdir/gcc-cdefs-test*; + else + host_cc=1 + fi; + rm $$tfile; + + if [ $host_cc = 1 ]; then + cat <