From: Stefano Lattarini Date: Tue, 8 Jan 2013 19:19:04 +0000 (+0100) Subject: coverage: compile rules used "-c -o" also with losing compilers X-Git-Tag: v1.13b~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=v1.13.1-34-g744cd57;p=thirdparty%2Fautomake.git coverage: compile rules used "-c -o" also with losing compilers If the 'subdir-objects' option is used, Automake-generated rules for C compilation pass both the "-c" and "-o" options to the C compiler, *unconditionally*. There are some compilers that choke on such an usage, but the AM_PROG_CC_C_O macro takes care of them (it does so by redefining $CC to use the Automake-provided 'compile' wrapper script automatically, if a losing compiler is detected at configure runtime). Unfortunately, in case the 'subdir-objects' option is specified in a Makefile.am, but all the source files resided anyway in the top-level directory (relative to the Makefile.am), Automake do *not* complain if AM_PROG_CC_C_O wasn't invoked in 'configure.ac' -- all the while still passing "-c -o" to the compiler invocations. This could cause compilation failures with losing compilers if the user forget to call AM_PROG_CC_C_O in 'configure.ac' (and Automake would not warn him of the issue). Expose this bug in the testsuite. Issue identified by Nick Bowler in the discussion on automake bug#13378: * t/ccnoco4.sh: New test. * t/list-of-tests.mk (XFAIL_TESTS, handwritten_TESTS): List it. Signed-off-by: Stefano Lattarini --- diff --git a/t/ccnoco4.sh b/t/ccnoco4.sh new file mode 100755 index 000000000..54b857a8e --- /dev/null +++ b/t/ccnoco4.sh @@ -0,0 +1,70 @@ +#! /bin/sh +# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that Automake doesn't pass "-c -o" to losing compiler when +# the 'subdir-objects' is used but sources are only present in the +# top-level directory. Reported by Nick Bowler in the discussion on +# automake bug#13378: +# +# + +required=gcc +. test-init.sh + +# We deliberately do not call AM_PROG_CC_C_O here. +cat >> configure.ac << 'END' +AC_PROG_CC +$CC --version; $CC -v; # For debugging. +AC_OUTPUT +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects +bin_PROGRAMS = foo bar +bar_SOURCES = foo.c +END + +echo 'int main (void) { return 0; }' > foo.c + +cat > Mycomp << END +#!/bin/sh + +case " \$* " in + *\ -c*\ -o* | *\ -o*\ -c*) + exit 1 + ;; +esac + +# Use '$CC', not 'gcc', to honour the compiler chosen +# by the testsuite setup. +exec $CC "\$@" +END + +chmod +x Mycomp + +# Make sure the compiler doesn't understand '-c -o'. +CC=$(pwd)/Mycomp +export CC + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --copy --add-missing + +./configure +$MAKE +$MAKE distcheck + +: diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index f3e996325..aef3730e2 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -30,6 +30,7 @@ t/pm/Version3.pl XFAIL_TESTS = \ t/all.sh \ +t/ccnoco4.sh \ t/cond17.sh \ t/gcj6.sh \ t/override-conditional-2.sh \ @@ -209,6 +210,7 @@ t/canon-name.sh \ t/ccnoco.sh \ t/ccnoco2.sh \ t/ccnoco3.sh \ +t/ccnoco4.sh \ t/check.sh \ t/check2.sh \ t/check4.sh \