>From 1bc5acb2df2fdf297bc101f36589ab9f932647bf Mon Sep 17 00:00:00 2001 Message-Id:
From: Stefano Lattarini Date: Wed, 11 Jul 2012 14:36:13 +0200 Subject: [PATCH] tests: don't use C instead of C++ compiler on case-insensitive platforms This change fixes automake bug#11893 and bug#10766. On at least Cygwin and Mac OS X 10.7, the file system where the system compilers are located can be case-insensitive, so that looking for a program named 'CC' might actually find the C compiler in /usr/bin/cc. Now, the Automake configure script looks for a C++ compiler named 'CC' before looking for more obvious names like c++ or g++ (that is done to increase testsuite "coverage in the wild", e.g., preferring, on Solaris, the Sun Studio C++ compiler /usr/bin/CC over the GNU C++ compiler). Since the checks done in AC_PROG_CXX are apparently not strict enough to rule out C compilers like those from GCC or Clang (which are smart enough to recognize if a file has a C++ extension, passing it to the C++ front end) the testsuite might end up using a C compiler where a C++ one is expected, with some subtle bad consequences. * configure.ac: Don't look for a C++ compiler named 'CC' if the "top-level" file system(s) (where /bin and /usr/bin are) are detected to be case-insensitive. Reported-by: Peter Rosin Reported-by: Max Horn Helped-by: Eric Blake Signed-off-by: Stefano Lattarini --- configure.ac | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 49b008d..d49da6c 100644 --- a/configure.ac +++ b/configure.ac @@ -442,12 +442,23 @@ _AM_COMPILER_CAN_FAIL(dnl AS_IF([test x"$GCC" = x"yes"], [am_CC_is_GNU=yes], [am_CC_is_GNU=no]) +# On case-insensitive file systems (seen e.g. on Cygwin and Mac OS X) +# we must avoid looking for 'CC', because that would be the same as +# 'cc', and could cause $CXX to point to the C compiler, instead of +# to a C++ compiler as expected. See automake bugs #11893 and #10766. +if test -f /bIn/rMdIr || test -f /uSr/bIn/rMdIr; then + # Case-insensitive file system, don't look for CC. + am_CC= +else + am_CC=CC +fi + # The list of C++ compilers here has been copied, pasted and edited # from 'lib/autoconf/c.m4:AC_PROG_CXX' in the Autoconf distribution. # Keep it in sync, or better again, find out a way to avoid this code # duplication. _AM_COMPILER_CAN_FAIL([AC_PROG_CXX(dnl - [aCC CC FCC KCC RCC xlC_r xlC c++ cxx cc++ gpp g++])], + [aCC $am_CC FCC KCC RCC xlC_r xlC c++ cxx cc++ gpp g++])], [CXX=false; _AM_SKIP_COMP_TESTS([C++])]) AS_IF([test x"$GXX" = x"yes"], [am_CXX_is_GNU=yes], [am_CXX_is_GNU=no]) -- 1.7.9.5