From b6627956b63c603654d67bd349a8c6afac421131 Mon Sep 17 00:00:00 2001 From: Paulo Matos Date: Tue, 12 Nov 2019 19:26:36 +0100 Subject: [PATCH] Improve gcc detection in configure script (#2897) Improve gcc detection in configure script We have been detecting gcc by the CC variable but this fails under ubuntu for example where you might specify CC='gcc-8' to ./configure. Also consider clang impersonator to be gcc. Related to #2890 --- racket/src/cfg-racket | 8 +++++++- racket/src/racket/configure.ac | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/racket/src/cfg-racket b/racket/src/cfg-racket index abd2b2710e..b3af235ef6 100755 --- a/racket/src/cfg-racket +++ b/racket/src/cfg-racket @@ -4610,7 +4610,13 @@ SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} AR_FLAGS="'"'"${ARFLAGS}"'"' is_gmake=`make -v no-such-target-we-hope 2>&1 | grep "GNU Make"` # If using gcc, we want all warnings: -if test "$CC" = "gcc" ; then +is_gcc=`$CC -v 2>&1 | tail -n 1 | grep -E '^gcc version [[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ \([^\)]+\)[[:space:]]*$'` + +# We also need to test if $CC is gcc itself because on mac, +# where clang impersonates gcc, although is_gcc is false, we want +# to use it as if it was gcc. +# See https://github.com/racket/racket/pull/2897#pullrequestreview-314906673 +if test "$is_gcc" != "" || test "`basename $CC`" = "gcc"; then COMPFLAGS="$COMPFLAGS -Wall" # Use -MMD when we have gcc and gnumake: diff --git a/racket/src/racket/configure.ac b/racket/src/racket/configure.ac index c563aa4409..ed0c5bd171 100644 --- a/racket/src/racket/configure.ac +++ b/racket/src/racket/configure.ac @@ -463,7 +463,15 @@ SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} AR_FLAGS="'"'"${ARFLAGS}"'"' is_gmake=`make -v no-such-target-we-hope 2>&1 | grep "GNU Make"` # If using gcc, we want all warnings: -if test "$CC" = "gcc" ; then +changequote(<<, >>)dnl +is_gcc=`$CC -v 2>&1 | tail -n 1 | grep -E '^gcc version [[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ \([^\)]+\)[[:space:]]*$'` +changequote([, ])dnl + +# We also need to test if $CC is gcc itself because on mac, +# where clang impersonates gcc, although is_gcc is false, we want +# to use it as if it was gcc. +# See https://github.com/racket/racket/pull/2897#pullrequestreview-314906673 +if test "$is_gcc" != "" || test "`basename $CC`" = "gcc"; then COMPFLAGS="$COMPFLAGS -Wall" # Use -MMD when we have gcc and gnumake: