On 07/12/2012 07:06 PM, Eric Blake wrote: > On 07/12/2012 10:23 AM, Stefano Lattarini wrote: > >>> Other than that, the only supported method in existing POSIX for >>> checking for equal files is by parsing 'ls -i' output; but I don't know >>> if 'ls -i' is portable to ancient hosts. >>> >> I was fearing this would have got quickly complex and messy ... >> >> So I think I'll stick to my dumber and safer "test -f /bin/RMDIR" as a >> way to detect case-insensible filesystems. > > Assuming it was intentional, I like your re-wording of > "case-insensible", as an apt description of the pain case-insensitive > systems cause on portability :) > Sorry, no deliberate pun, just a lexical error. But I can keep it if you like it :-)
> That said, /bin/RMDIR is probably not completely portable, but seems > like it would be reliable in practice. > That is my impression. And anyway, there aren't too many people running the Automake testsuite on Mac OS X or Cygwin, so if the patch manages to fix Peter's and Max's issue, it is good enough for me (at least until somebody else reports a similar issue). Finally, consider that the result of a botch-up of this new configure check would simple be one or two spurious testsuite failures -- so just a small annoyance, nothing to really worry about. > POSIX doesn't reqiure /bin/rmdir to > exist (about the only files that you can guarantee with POSIX are /tmp, > /dev/null, /dev/tty, and /dev/console). Since /dev/ generally doesn't > exist on mingw, that almost limits you to just testing if /tmp and /TMP > are the same directory to detect a case-insensitive system. But I don't > know of any systems that lack /bin/rmdir on a default installation, nor > do I suspect many users intentionally create /bin/RMDIR (or even better, > /bIn/rMdIr), > Good idea for an improved test; I've implemented it in my patch. > so using it as a hueristic seems okay for a first cut at > the problem at hand. Or, maybe you should just create a file in /tmp > under one spelling and check existence of the file by another spelling. > In the light of our discussion, attached is the patch I'd finally like to push. WDYT? Thanks, Stefano
>From 1bc5acb2df2fdf297bc101f36589ab9f932647bf Mon Sep 17 00:00:00 2001 Message-Id: <1bc5acb2df2fdf297bc101f36589ab9f932647bf.1342118547.git.stefano.lattar...@gmail.com> From: Stefano Lattarini <stefano.lattar...@gmail.com> 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 <p...@lysator.liu.se> Reported-by: Max Horn <m...@quendi.de> Helped-by: Eric Blake <ebl...@redhat.com> Signed-off-by: Stefano Lattarini <stefano.lattar...@gmail.com> --- 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