From 743637f54b99310defc2cc5bdbc1bbd8d3e09e0f Mon Sep 17 00:00:00 2001 From: Raul Infante-Sainz Date: Tue, 30 Apr 2019 17:56:46 +0100 Subject: Better configure checks to see if GCC can be built Until now, to test if GCC can use `sys/cdefs.h', we were building a small test program using it. But after testing on an Ubuntu 14.04, we noticed that the GCC test during the configure script passes, but GCC still can't be built. After some investigation we noticed its available in other directories, but during the build of GCC, those directories aren't used, and it only assumes it to be under `/usr/include'. So with this commit, we are only checking this particular location for this header, not a test run of GCC. After fixing this, we noticed that GCC's build crashed again because it couldn't link with `libc.a' (or `libc.so'). So we also added a for this library and added a new warning to inform the user what they might be able to do. Finally, we noticed that in one of the last steps of building GCC, we weren't using `&&', but `;', so the GCC name file would be built, even when the GCC build failed. --- configure | 86 +++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 24 deletions(-) (limited to 'configure') diff --git a/configure b/configure index a71c815..0c0404d 100755 --- a/configure +++ b/configure @@ -884,41 +884,79 @@ fi # # 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. +# `/usr/include/sys/cdefs.h' and `/usr/lib/libc.a' are not available by +# default. So GCC will crash with different ugly errors! The only solution +# is that user manually installs the `multilib' part as root, before +# running the configure script. +# +# Note that `sys/cdefs.h' may be available in other directories (for +# example `/usr/include/x86_64-linux-gnu/') that are automatically included +# in an installed GCC. HOWEVER during the build of GCC, all those other +# directories are ignored. So even if they exist, they are useless. +warningsleep=0 if [ $host_cc = 0 ]; then - tfile=$sdir/gcc-cdefs-test.c; - echo "#include " > $tfile; - echo "int main(void){return 0;}" >> $tfile; - if gcc $tfile -o $sdir/gcc-cdefs-test &> /dev/null; then - rm $sdir/gcc-cdefs-test*; - else + if ! [ -f /usr/include/sys/cdefs.h ]; then host_cc=1 - fi; - rm -f $tfile; + warningsleep=1 + cat <