[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] {maint} tests: can fake a compiler not grasping "-c -o" -- globall
From: |
Stefano Lattarini |
Subject: |
[FYI] {maint} tests: can fake a compiler not grasping "-c -o" -- globally in all tests |
Date: |
Fri, 11 Jan 2013 18:43:22 +0100 |
The ability to easily do so will be quite important in upcoming changes
about C compilation handling and semantics of the 'subdir-objects'
option. Refer to the extensive discussion about automake bug#13378 for
more details: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378>.
See also commit 'v1.13.1-34-g744cd57' of 2013-01-08, "coverage: compile
rules used "-c -o" also with losing compilers".
* t/ax/cc-no-c-o.in: New, a "C compiler" that chokes when the '-c' and
'-o' options are passed together to it on the command line.
* Makefile.am (t/ax/cc-no-c-o): Generate this script from it.
(noinst_SCRIPTS, CLEANFILES): Add it.
(EXTRA_DIST): Add 't/ax/cc-no-c-o.in'.
(check-cc-no-c-o): New target, runs the whole testsuite with 'cc-no-c-o'
as the C compiler (bot GNU and non-GNU).
* .gitignore: Update.
* t/ccnoco.sh: Use the new script instead of duplicating it.
* t/ccnoco3.sh: Likewise.
* t/ccnoco4.sh: Likewise.
* t/self-check-cc-no-c-o.sh: New testsuite self-check.
* t/list-of-tests.mk: Adjust.
Signed-off-by: Stefano Lattarini <address@hidden>
---
.gitignore | 1 +
Makefile.am | 22 ++++++++++++++++++++++
t/ax/cc-no-c-o.in | 29 +++++++++++++++++++++++++++++
t/ccnoco.sh | 21 ++-------------------
t/ccnoco3.sh | 21 ++-------------------
t/ccnoco4.sh | 23 +++--------------------
t/list-of-tests.mk | 1 +
t/self-check-cc-no-c-o.sh | 35 +++++++++++++++++++++++++++++++++++
8 files changed, 95 insertions(+), 58 deletions(-)
create mode 100644 t/ax/cc-no-c-o.in
create mode 100755 t/self-check-cc-no-c-o.sh
diff --git a/.gitignore b/.gitignore
index a32310e..dd55add 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@
/t/wrap/automake-1.*
/t/ax/test-defs.sh
/t/ax/shell-no-trail-bslash
+/t/ax/cc-no-c-o
/t/testsuite-part.am
/t/*-w.tap
/t/*-w.sh
diff --git a/Makefile.am b/Makefile.am
index ab98df7..8a6a578 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -446,6 +446,17 @@ EXTRA_DIST += t/ax/shell-no-trail-bslash.in
CLEANFILES += t/ax/shell-no-trail-bslash
noinst_SCRIPTS += t/ax/shell-no-trail-bslash
+t/ax/cc-no-c-o: t/ax/cc-no-c-o.in Makefile
+ $(AM_V_at)rm -f $@ address@hidden
+ $(AM_V_GEN)in=t/ax/cc-no-c-o.in \
+ && $(MKDIR_P) t/ax \
+ && $(do_subst) <$(srcdir)/$$in >address@hidden \
+ && chmod a+x address@hidden
+ $(generated_file_finalize)
+EXTRA_DIST += t/ax/cc-no-c-o.in
+CLEANFILES += t/ax/cc-no-c-o
+noinst_SCRIPTS += t/ax/cc-no-c-o
+
runtest: t/ax/runtest.in Makefile
$(AM_V_at)rm -f $@ address@hidden
$(AM_V_GEN)in=t/ax/runtest.in \
@@ -518,6 +529,17 @@ check-no-trailing-backslash-in-recipes:
CONFIG_SHELL='$(abs_top_builddir)/t/ax/shell-no-trail-bslash'
.PHONY: check-no-trailing-backslash-in-recipes
+# Some compilers out there (hello, MSVC) still choke on "-c -o" being
+# passed together on the command line. Run the whole testsuite faking
+# the presence of such a compiler, to help catchregression that would
+# otherwise only present themselves later "in the wild". See also the
+# long discussion about automake bug#13378.
+check-cc-no-c-o:
+ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) check \
+ CC='$(abs_top_builddir)/t/ax/cc-no-c-o' \
+ GNU_CC='$(abs_top_builddir)/t/ax/cc-no-c-o'
+.PHONY: check-cc-no-c-o
+
## Checking the list of tests.
test_subdirs = t t/pm contrib/t
include $(srcdir)/t/CheckListOfTests.am
diff --git a/t/ax/cc-no-c-o.in b/t/ax/cc-no-c-o.in
new file mode 100644
index 0000000..c18f9b9
--- /dev/null
+++ b/t/ax/cc-no-c-o.in
@@ -0,0 +1,29 @@
+#! @AM_TEST_RUNNER_SHELL@
+# Copyright (C) 2012-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 <http://www.gnu.org/licenses/>.
+
+# A "C compiler" that chokes when the '-c' and '-o' options are passed
+# together to it on the command line. See also automake bug#13378.
+
+am_CC=${AM_TESTSUITE_GNU_CC-'@GNU_CC@'}
+
+case " $* " in
+ *\ -c*\ -o* | *\ -o*\ -c*)
+ echo "$0: both '-o' and '-c' seen on the command line" >&2
+ exit 2
+ ;;
+esac
+
+exec $am_CC "$@"
diff --git a/t/ccnoco.sh b/t/ccnoco.sh
index cffabd7..c6af797 100755
--- a/t/ccnoco.sh
+++ b/t/ccnoco.sh
@@ -17,7 +17,7 @@
# Test to make sure we can compile when the compiler doesn't
# understand '-c -o'.
-required=gcc
+required=gcc # For cc-no-c-o.
. test-init.sh
cat >> configure.ac << 'END'
@@ -44,25 +44,8 @@ int main ()
}
END
-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
+CC=$am_testaux_builddir/cc-no-c-o; export CC
$ACLOCAL
$AUTOCONF
diff --git a/t/ccnoco3.sh b/t/ccnoco3.sh
index 7ad5b3b..b8dd77c 100755
--- a/t/ccnoco3.sh
+++ b/t/ccnoco3.sh
@@ -16,7 +16,7 @@
# Test to make sure 'compile' doesn't call 'mv SRC SRC'.
-required=gcc
+required=gcc # For cc-no-c-o.
. test-init.sh
cat >> configure.ac << 'END'
@@ -43,25 +43,8 @@ int main ()
}
END
-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
+CC=$am_testaux_builddir/cc-no-c-o; export CC
$ACLOCAL
$AUTOCONF
diff --git a/t/ccnoco4.sh b/t/ccnoco4.sh
index 73dce9f..b317fb5 100755
--- a/t/ccnoco4.sh
+++ b/t/ccnoco4.sh
@@ -22,7 +22,7 @@
# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#35>
# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378#44>
-required=gcc
+required=gcc # For cc-no-c-o.
. test-init.sh
# We deliberately do not call AM_PROG_CC_C_O here.
@@ -40,25 +40,8 @@ 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
+# Make sure the compiler doesn't understand '-c -o'
+CC=$am_testaux_builddir/cc-no-c-o; export CC
$ACLOCAL
$AUTOCONF
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 63e098d..2052bd8 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -954,6 +954,7 @@ t/remake-timing-bug-pr8365.sh \
t/reqd2.sh \
t/repeated-options.sh \
t/rulepat.sh \
+t/self-check-cc-no-c-o.sh \
t/self-check-configure-help.sh \
t/self-check-dir.tap \
t/self-check-exit.tap \
diff --git a/t/self-check-cc-no-c-o.sh b/t/self-check-cc-no-c-o.sh
new file mode 100755
index 0000000..2cf4702
--- /dev/null
+++ b/t/self-check-cc-no-c-o.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2012-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 <http://www.gnu.org/licenses/>.
+
+# Check that our fake "C compiler" that doesn't grasp the '-c' and
+# '-o' command-line options passed together, used to enhance testsuite
+# coverage.
+
+required=gcc # Our fake compiler uses gcc.
+am_create_testdir=empty
+. test-init.sh
+
+CC=$am_testaux_builddir/cc-no-c-o; export CC
+
+echo 'int main (void) { return 0; }' > foo.c
+$CC -c foo.c
+test -f foo.o || test -f foo.obj
+$CC -c -o bar.o foo.c 2>stderr && { cat stderr >&2; exit 1; }
+cat stderr >&2
+grep "both '-o' and '-c' seen on the command line" stderr
+test ! -e bar.o
+
+:
--
1.8.1.rc3.192.g2d0029e
- [FYI] {maint} tests: can fake a compiler not grasping "-c -o" -- globally in all tests,
Stefano Lattarini <=