From 852d996f8f5f1e5e0114dc82aaf33d81c725fb20 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Sun, 19 Jan 2020 15:08:08 +0000 Subject: Better search for static C library at start of configuration Until now, to see if a working static C library and `sys/cdefs.h' exist, we were checking absolute locations like `/usr/include/sys/cdefs.h' or `/usr/lib/libc.a' and `/usr/lib64/libc.a'. But this is not robust because on different systems, they can be in different locations. With this commit, we actually use `find' to find the location of `libc.a' and use that to add elements to CPPFLAGS and LDFLAGS. This should fix the problem on systems that have them on non-standard locations. --- reproduce/software/bash/configure.sh | 183 ++++++++++++++--------------------- 1 file changed, 75 insertions(+), 108 deletions(-) (limited to 'reproduce/software') diff --git a/reproduce/software/bash/configure.sh b/reproduce/software/bash/configure.sh index 08f2609..0bb0917 100755 --- a/reproduce/software/bash/configure.sh +++ b/reproduce/software/bash/configure.sh @@ -819,42 +819,6 @@ static_build=no -# inform the user that the build process is starting -# ------------------------------------------------- -if [ $printnotice = yes ]; then - tsec=10 - cat < /dev/null 2>/dev/null; then host_cc=1 on_mac_os=yes else + host_cc=0 on_mac_os=no fi @@ -876,74 +841,33 @@ 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, -# `/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. +# Necessary C library element positions +# ------------------------------------- # -# 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. -gccwarning=0 -if [ $host_cc = 0 ]; then - if ! [ -f /usr/include/sys/cdefs.h ]; then - host_cc=1 - gccwarning=1 - cat <" > $testsource echo "#include " >> $testsource - echo "int main(void){printf(\"...yes\");" >> $testsource + echo "#include " >> $testsource + echo "int main(void){printf(\"...yes\n\");" >> $testsource echo " return EXIT_SUCCESS;}" >> $testsource - if gcc $testsource -o$testprog -static -lc && $testprog; then + cc_call="gcc $testsource $CPPFLAGS $LDFLAGS -o$testprog -static -lc" + if $cc_call && $testprog; then + gccwarning=0 good_static_libc=1 rm $testsource $testprog else + echo; echo "Compilation command:"; echo "$cc_call" good_static_libc=0 rm $testsource gccwarning=1 @@ -979,15 +907,18 @@ if [ $host_cc = 0 ]; then !!!!!!!!!!!!!!!!!!!!!! Warning !!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -A usable static C library ('libc.a', in any directory) cannot be linked in -the current settings of this system. Because of this we can't build a -static PatchELF, hence we can't build GCC. +A usable static C library ('libc.a', in any directory) cannot be linked, +and 'sys/cdefs.h' cannot be included with the current settings of this +system. Because of this we can't build a static PatchELF, hence we can't +build GCC. If you have 'libc.a', but in a non-standard location (for example in -'/PATH/TO/STATIC/LIBC/libc.a'), please run this command, then re-configure -the project to fix this problem. +'/PATH/TO/STATIC/LIBC/libc.a' and '/PATH/TO/SYS/CDEFS_H/sys/cdefs.h'), +please run the commands below, then re-configure the project to fix this +problem. export LDFLAGS="-L/PATH/TO/STATIC/LIBC \$LDFLAGS" +export CPPFLAGS="-I/PATH/TO/SYS/CDEFS_H \$LDFLAGS" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -996,7 +927,7 @@ EOF fi # Print a warning if GCC is not meant to be built. -if [ $gccwarning = 1 ]; then +if [ x"$gccwarning" = x1 ]; then cat <