From 0e4d4b357f4c2209aea8012847b1309fe8b33b13 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Sun, 5 Jul 2020 19:17:05 +0100 Subject: Configure script prefers clang for macOS systems In the previous commit (Commit 1bc00c9: Only using clang in macOS systems that also have GCC) we set the used C compiler for high-level programs to be 'clang' on macOS systems. But I forgot to do the same kind of change in the configure script (to prefer 'clang' when we are testing for a C compiler on the host). With this commit, the compiler checking phases of the configure script have been improved, so on macOS systems, we now first search for 'clang', then search for 'gcc'. While doing this, I also noticed that the 'rpath' checking command was done before we actually define 'instdir'!!! So in effect, the 'rpath' directory was being set to '/lib'! So with this commit, this test has been taken to after defining 'instdir'. --- reproduce/software/shell/configure.sh | 224 +++++++++++++++++++--------------- 1 file changed, 128 insertions(+), 96 deletions(-) (limited to 'reproduce/software/shell') diff --git a/reproduce/software/shell/configure.sh b/reproduce/software/shell/configure.sh index f428416..001b531 100755 --- a/reproduce/software/shell/configure.sh +++ b/reproduce/software/shell/configure.sh @@ -186,35 +186,93 @@ free_space_warning() +# See if we are on a Linux-based system +# -------------------------------------- +# +# Some features are tailored to GNU/Linux systems, while the BSD-based +# behavior is different. Initially we only tested macOS (hence the name of +# the variable), but as FreeBSD is also being inlucded in our tests. As +# more systems get used, we need to tailor these kinds of things better. +kernelname=$(uname -s) +if [ x$kernelname = xLinux ]; then + on_mac_os=no + + # Don't forget to add the respective C++ compiler below (leave 'cc' in + # the end). + c_compiler_list="gcc clang cc" +else + host_cc=1 + on_mac_os=yes + + # Don't forget to add the respective C++ compiler below (leave 'cc' in + # the end). + c_compiler_list="clang gcc cc" +fi + + + + + # Check for C/C++ compilers # ------------------------- # -# To build the software, we'll need some basic tools (the compilers in -# particular) to be present. -hascc=0; -if type cc > /dev/null 2>/dev/null; then - if type c++ > /dev/null 2>/dev/null; then export CC=cc; hascc=1; fi -else - if type gcc > /dev/null 2>/dev/null; then - if type g++ > /dev/null 2>/dev/null; then export CC=gcc; hascc=1; fi +# To build the software, we'll need some basic tools (the C/C++ compilers +# in particular) to be present. +has_compilers=no +for c in $c_compiler_list; do + + # Set the respective C++ compiler. + if [ x$c = xcc ]; then cplus=c++; + elif [ x$c = xgcc ]; then cplus=g++; + elif [ x$c = xclang ]; then cplus=clang++; else - if type clang > /dev/null 2>/dev/null; then - if type clang++ > /dev/null 2>/dev/null; then export CC=clang; hascc=1; fi + cat < /dev/null 2>/dev/null; then + export CC=$c; + if type $cplus > /dev/null 2>/dev/null; then + export CXX=$cplus + has_compilers=yes + break fi fi -fi -if [ $hascc = 0 ]; then +done +if [ x$has_compilers = xno ]; then cat < $testsource < #include @@ -257,7 +314,7 @@ else ______________________________________________________ !!!!!!! C compiler doesn't work !!!!!!! -Host C compiler ('gcc') can't build a simple program. +Host C compiler ('$CC') can't build a simple program. A working C compiler is necessary for building the project's software. Please use the error message above to find a good solution and re-run the @@ -268,11 +325,6 @@ link below and we'll try to help https://savannah.nongnu.org/support/?func=additem&group=reproduce -TIP: Once you find the solution, you can use the '-e' option to use -existing configuration: - - $ ./project configure -e - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! EOF @@ -283,28 +335,6 @@ fi -# See if the linker accepts -Wl,-rpath-link -# ----------------------------------------- -# -# `-rpath-link' is used to write the information of the linked shared -# library into the shared object (library or program). But some versions of -# LLVM's linker don't accept it an can cause problems. -cat > $testsource < -#include -int main(void) {return EXIT_SUCCESS;} -EOF -if $CC $testsource -o$testprog -Wl,-rpath-link 2>/dev/null > /dev/null; then - export rpath_command="-Wl,-rpath-link=$instdir/lib" -else - export rpath_command="" -fi -rm -f $testprog $testsource - - - - - # See if we need the dynamic-linker (-ldl) # ---------------------------------------- # @@ -326,7 +356,7 @@ if $CC $testsource -o$testprog 2>/dev/null > /dev/null; then else needs_ldl=yes; fi -rm -f $testprog $testsource + @@ -351,25 +381,6 @@ static_build=no -# See if we are on a Linux-based system -# -------------------------------------- -# -# Some features are tailored to GNU/Linux systems, while the BSD-based -# behavior is different. Initially we only tested macOS (hence the name of -# the variable), but as FreeBSD is also being inlucded in our tests. As -# more systems get used, we need to tailor these kinds of things better. -kernelname=$(uname -s) -if [ x$kernelname = xLinux ]; then - on_mac_os=no -else - host_cc=1 - on_mac_os=yes -fi - - - - - # Print warning if the host CC is to be used. if [ x$host_cc = x1 ]; then cat < $testsource < +#include +int main(void) {return EXIT_SUCCESS;} +EOF +if $CC $testsource -o$testprog -Wl,-rpath-link 2>/dev/null > /dev/null; then + export rpath_command="-Wl,-rpath-link=$instdir/lib" +else + export rpath_command="" +fi + + + + + +# Delete the compiler testing directory +# ------------------------------------- +# +# This directory was made above to make sure the necessary compilers can be +# run. +rm -f $testprog $testsource +rm -rf $compilertestdir + + + + + # Paths needed by the host compiler (only for `basic.mk') # ------------------------------------------------------- # -- cgit v1.2.1