[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/14] Clobber global CFLAGS etc. when requiring GNU compilers.
From: |
Stefano Lattarini |
Subject: |
[PATCH 13/14] Clobber global CFLAGS etc. when requiring GNU compilers. |
Date: |
Fri, 2 Jul 2010 16:06:50 +0200 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; ) |
Currently, if a test script requires (say) "gcc", it will only get CC, not
CFLAGS, redefined in the environment. This way, if CFLAGS is set referring
to a non-GNU C compiler, its contents won't necessarly be understood by
gcc, and hence a spurious failure will be triggered.
This has already happened in practice, e.g.:
> > depcomp3.test fails since it requires gcc and the test therefore
> > changes CC from cl to gcc, but that's not enough since I also have
> > CFLAGS=-MD which means something completely different to these two
> > compilers. It seems fundamentally broken to assume that CFLAGS
> > remains sane while changing CC.
> Correct. Another testsuite issue.
(from a discussion between Peter Rosin and Ralf Wildenhues, see
<http://lists.gnu.org/archive/html/automake-patches/2010-06/msg00112.html>)
This patch aims at fixing it.
Regards,
Stefano
-*-*-*-
* tests/defs.in (require_compiler): Clobber global compiler flags
variables (e.g. CFLAGS, CXXFLAGS, ...) when requiring a GNU
compiler. But let the user override them with corresponding
`GNU_*' variables (e.g. GNU_CFLAGS for CFLAGS).
(icc in $required): Similarly, clobber global CFLAGS and redefine
it with with $INTEL_CFLAGS.
* tests/ansi3.test: Do not clobber user CFLAGS, it is no more
necessary.
* tests/ansi3b.test: Likewise.
... (other tests changed likewise) ....
From 735da2119912f94aa88fab5e10d0ef514fe6cc7f Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Fri, 2 Jul 2010 12:41:30 +0200
Subject: [PATCH 13/14] Clobber global CFLAGS etc. when requiring GNU compilers.
Before this change, if a test script required (say) "gcc", it would have
only got CC, not CFLAGS, redefined in the environment. This way, if
CFLAGS was already set referring to a non-GNU C compiler, its contents
would have not necessarly been understood by gcc, hence leading to a
spurious failure.
* tests/defs.in (require_compiler): Clobber global compiler flags
variables (e.g. CFLAGS, CXXFLAGS, ...) when requiring a GNU
compiler. But let the user override them with corresponding
`GNU_*' variables (e.g. GNU_CFLAGS for CFLAGS).
(icc in $required): Similarly, clobber global CFLAGS and redefine
it with with $INTEL_CFLAGS.
* tests/ansi3.test: Do not clobber user CFLAGS, it is no more
necessary.
* tests/ansi3b.test: Likewise.
* tests/ansi5.test: Likewise.
* tests/ccnoco.test: Likewise.
* tests/ccnoco3.test: Likewise.
* tests/cond16.test: Likewise.
* tests/cond18.test: Likewise.
* tests/cond19.test: Likewise.
* tests/cond4.test: Likewise.
* tests/depcomp2.test: Likewise.
* tests/depend2.test: Likewise.
* tests/lex3.test: Likewise.
* tests/pr87.test: Likewise.
* tests/subobj3.test: Likewise.
* tests/substref.test: Likewise.
---
ChangeLog | 24 ++++++++++++++++++++++++
tests/ansi3.test | 4 ----
tests/ansi3b.test | 4 ----
tests/ansi5.test | 4 +---
tests/ccnoco.test | 7 +------
tests/ccnoco3.test | 7 ++-----
tests/cond16.test | 4 ----
tests/cond18.test | 4 ----
tests/cond19.test | 4 ----
tests/cond4.test | 4 ----
tests/defs.in | 22 ++++++++++++++++++----
tests/depcomp2.test | 4 ----
tests/depend2.test | 4 ----
tests/lex3.test | 4 ----
tests/pr87.test | 4 ----
tests/subobj3.test | 4 ----
tests/substref.test | 4 ----
17 files changed, 46 insertions(+), 66 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0d1e536..889e85d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2010-07-02 Stefano Lattarini <address@hidden>
+ Clobber global CFLAGS etc. when requiring GNU compilers.
+ * tests/defs.in (require_compiler): Clobber global compiler flags
+ variables (e.g. CFLAGS, CXXFLAGS, ...) when requiring a GNU
+ compiler. But let the user override them with corresponding
+ `GNU_*' variables (e.g. GNU_CFLAGS for CFLAGS).
+ (icc in $required): Similarly, clobber global CFLAGS and redefine
+ it with with $INTEL_CFLAGS.
+ * tests/ansi3.test: Do not clobber user CFLAGS, it is no more
+ necessary.
+ * tests/ansi3b.test: Likewise.
+ * tests/ansi5.test: Likewise.
+ * tests/ccnoco.test: Likewise.
+ * tests/ccnoco3.test: Likewise.
+ * tests/cond16.test: Likewise.
+ * tests/cond18.test: Likewise.
+ * tests/cond19.test: Likewise.
+ * tests/cond4.test: Likewise.
+ * tests/depcomp2.test: Likewise.
+ * tests/depend2.test: Likewise.
+ * tests/lex3.test: Likewise.
+ * tests/pr87.test: Likewise.
+ * tests/subobj3.test: Likewise.
+ * tests/substref.test: Likewise.
+
Refactor code requiring compilers in testsuite.
* tests/defs.in (require_gnu_compilers): Removed, merged ...
(require_compiler): ... with this one, and added knowledge of
diff --git a/tests/ansi3.test b/tests/ansi3.test
index e1e0c42..2bff0e5 100755
--- a/tests/ansi3.test
+++ b/tests/ansi3.test
@@ -44,10 +44,6 @@ main (int argc, char *argv[])
}
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
# We use gcc and not gcc -traditional as the latter fails on some
# Linux boxes (Red Hat 5.1 in particular).
$ACLOCAL
diff --git a/tests/ansi3b.test b/tests/ansi3b.test
index ad222ff..8b50b29 100755
--- a/tests/ansi3b.test
+++ b/tests/ansi3b.test
@@ -45,10 +45,6 @@ main (int argc, char *argv[])
}
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
# We use gcc and not gcc -traditional as the latter fails on some
# Linux boxes (Red Hat 5.1 in particular).
$ACLOCAL
diff --git a/tests/ansi5.test b/tests/ansi5.test
index bbc9109..f607a0c 100755
--- a/tests/ansi5.test
+++ b/tests/ansi5.test
@@ -68,9 +68,7 @@ set -e
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
+
./configure
# This is ugly! If we set U at make time then the "wrong" file gets
diff --git a/tests/ccnoco.test b/tests/ccnoco.test
index d6ed136..a455d89 100755
--- a/tests/ccnoco.test
+++ b/tests/ccnoco.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2001, 2002, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2008, 2010 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
@@ -70,11 +70,6 @@ chmod +x Mycomp
set -e
-
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
for conf in configure.1 configure.3; do
cp $conf configure.in
diff --git a/tests/ccnoco3.test b/tests/ccnoco3.test
index 2e9cd37..0b27c09 100755
--- a/tests/ccnoco3.test
+++ b/tests/ccnoco3.test
@@ -1,5 +1,6 @@
#! /bin/sh
-# Copyright (C) 2001, 2002, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2008, 2009, 2010 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
@@ -58,10 +59,6 @@ END
chmod +x Mycomp
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
$ACLOCAL
$AUTOCONF
$AUTOMAKE --copy --add-missing
diff --git a/tests/cond16.test b/tests/cond16.test
index 950ab10..f333f43 100755
--- a/tests/cond16.test
+++ b/tests/cond16.test
@@ -48,10 +48,6 @@ echorule:
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
set -e
$ACLOCAL
diff --git a/tests/cond18.test b/tests/cond18.test
index 312b896..81cc3bb 100755
--- a/tests/cond18.test
+++ b/tests/cond18.test
@@ -53,10 +53,6 @@ echorule:
bin_PROGRAMS = helldl
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
set -e
$ACLOCAL
diff --git a/tests/cond19.test b/tests/cond19.test
index d820202..eced6f6 100755
--- a/tests/cond19.test
+++ b/tests/cond19.test
@@ -55,10 +55,6 @@ echorule:
bin_PROGRAMS = helldl
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
set -e
$ACLOCAL
diff --git a/tests/cond4.test b/tests/cond4.test
index 1d2910c..223f91f 100755
--- a/tests/cond4.test
+++ b/tests/cond4.test
@@ -53,10 +53,6 @@ test "`grep 'address@hidden@' Makefile.in | wc -l`" -eq 0
$AUTOCONF
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
CONDITION1=true CONDITION2=true ./configure
msgtt=`$MAKE --no-print-directory echo-objects`
CONDITION1=true CONDITION2=false ./configure
diff --git a/tests/defs.in b/tests/defs.in
index d34d425..89c06da 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -102,19 +102,24 @@ require_compiler()
case $1 in
c)
compiler_variable=CC
+ flags_variable=CFLAGS # FIXME: what about CPPFLAGS?
gnu_compiler_candidates=gcc;;
c++)
compiler_variable=CXX
+ flags_variable=CXXFLAGS # FIXME: what about CPPFLAGS?
gnu_compiler_candidates=g++;;
f77)
compiler_variable=F77
+ flags_variable=FFLAGS
# gfortran should be able to seamlessly compile Fortran 77 code
gnu_compiler_candidates='g77 gfortran';;
f9x)
compiler_variable=FC
+ flags_variable=FCLAGS
gnu_compiler_candidates=gfortran;;
gcj)
compiler_variable=GCJ
+ flags_variable='' # flags must be GNU-specific anyway
gnu_compiler_candidates=gcj;;
*)
echo "$me: $1: invalid compiler language" >&2; exit 99;;
@@ -148,10 +153,18 @@ require_compiler()
$have_gnu_compiler || exit 77
eval "$compiler_variable=\$compiler"
export $compiler_variable
+ if test x"$what_gnu" = x"force" && test -n "$flags_variable"; then
+ # Clobber compiler flags in the environment, so that they won't be
+ # passed to the GNU compiler; however, leave the user a way to
+ # specify flags for the GNU compiler, by using e.g. GNU_CFLAGS
+ # instead of CFLAGS, etcetera.
+ eval "$flags_variable=\$GNU_$flags_variable"
+ export $flags_variable
+ fi
fi
# Remove local variables.
- unset what_gnu compiler_variable compiler
+ unset what_gnu compiler_variable compiler flags_variables
unset gnu_compiler_candidates have_gnu_compiler
}
@@ -214,12 +227,13 @@ do
# required.
case " $required " in
*\ fortran77\ *);;
- *) F77=$FC; export F77;;
+ # Hmpf. Some code duplication here w.r.t. require_compiler().
+ *) F77=$FC; export F77; FFLAGS=${GNU_FFLAGS-}; export FFLAGS;;
esac
;;
icc)
- CC=icc
- export CC
+ CC=icc; export CC
+ CFLAGS=${INTEL_CFLAGS-}; export CFLAGS
# There is no way to ask *only* the compiler's version.
# This tool always wants to do something (by default
# it will try link *nothing* and complain it cannot find
diff --git a/tests/depcomp2.test b/tests/depcomp2.test
index 2dca558..5b3ccc3 100755
--- a/tests/depcomp2.test
+++ b/tests/depcomp2.test
@@ -42,10 +42,6 @@ END
: > subdir/foo.c
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
$ACLOCAL
$AUTOMAKE --add-missing
$AUTOCONF
diff --git a/tests/depend2.test b/tests/depend2.test
index 114664d..f14450f 100755
--- a/tests/depend2.test
+++ b/tests/depend2.test
@@ -51,10 +51,6 @@ $ACLOCAL
$AUTOCONF
$AUTOMAKE -a
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
./configure --disable-dependency-tracking
$MAKE
diff --git a/tests/lex3.test b/tests/lex3.test
index 6e5241b..c026d10 100755
--- a/tests/lex3.test
+++ b/tests/lex3.test
@@ -21,10 +21,6 @@
required='cc gzip flex GNUmake'
. ./defs || Exit 1
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
cat > configure.in << 'END'
AC_INIT
dnl Prevent automake from looking in .. and ../..
diff --git a/tests/pr87.test b/tests/pr87.test
index 634ca20..3e715a6 100755
--- a/tests/pr87.test
+++ b/tests/pr87.test
@@ -41,10 +41,6 @@ AC_PROG_CC
AC_OUTPUT(Makefile `echo $subdirs | sed 's|\([a-z][a-z]*\)|\1/Makefile|g'`)
EOF
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
touch README NEWS AUTHORS ChangeLog
mkdir build
diff --git a/tests/subobj3.test b/tests/subobj3.test
index a21c6a0..ff14c4e 100755
--- a/tests/subobj3.test
+++ b/tests/subobj3.test
@@ -51,10 +51,6 @@ main (int argc, char *argv[])
}
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
diff --git a/tests/substref.test b/tests/substref.test
index adc3c5c..8471c4f 100755
--- a/tests/substref.test
+++ b/tests/substref.test
@@ -46,10 +46,6 @@ got:
END
-# Ignore user CFLAGS.
-CFLAGS=
-export CFLAGS
-
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
--
1.6.5
- [PATCH 03/14] Do not SKIP a test on a command failing with `77' exit status., (continued)
- [PATCH 03/14] Do not SKIP a test on a command failing with `77' exit status., Stefano Lattarini, 2010/07/02
- [PATCH 04/14] Make sure all tests needing C compiler require it explicitly., Stefano Lattarini, 2010/07/02
- [PATCH 05/14] New requirement "c++" for tests using a C++ compiler., Stefano Lattarini, 2010/07/02
- [PATCH 06/14] Fix `silent*.test' for C++ compilers with "weird" names., Stefano Lattarini, 2010/07/02
- [PATCH 07/14] Make sure silent*.test work with non-GNU C compilers., Stefano Lattarini, 2010/07/02
- [PATCH 08/14] Fixes/renamings for "synced tests" among `silent*.test'., Stefano Lattarini, 2010/07/02
- [PATCH 09/14] Refactor code requiring compilers in testsuite., Stefano Lattarini, 2010/07/02
- [PATCH 10/14] Tests: new requirements "fortran" and "fortran77", Stefano Lattarini, 2010/07/02
- [PATCH 11/14] Fix code for requiring gfortran in tests., Stefano Lattarini, 2010/07/02
- [PATCH 12/14] Refactor code requiring compilers in testsuite., Stefano Lattarini, 2010/07/02
- [PATCH 13/14] Clobber global CFLAGS etc. when requiring GNU compilers.,
Stefano Lattarini <=
- Re: [PATCH 0/14] Fix/improve requirements declaration for test scripts., Stefano Lattarini, 2010/07/02
- [PATCH 14/14] Make sure all tests needing gzip require it explicitly., Stefano Lattarini, 2010/07/02