bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."


From: Paul Eggert
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Thu, 28 Dec 2006 23:11:08 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

> In that case, we should make the Autoconf change optional.
> I'll propose a further patch along those lines.

OK, here's that proposed patch to Autoconf.  Also, this patch attempts
to discuss the matter better in the documentation.  The documentation
was by far the hardest part of the patch to write, and I'd appreciate
any comments/reviews for it.

For those coming to this discussion late, the original version of the
patch and the followup thread are here:

http://lists.gnu.org/archive/html/autoconf-patches/2006-12/msg00091.html


2006-12-28  Paul Eggert  <address@hidden>

        * NEWS: AC_PROG_CC, AC_PROG_CXX, and AC_PROG_OBJC now take an
        optional second argument specifying the default optimization
        options for GCC.  These optimizations now default to "-O2 -fwrapv"
        instead of to "-O2".  This partly attacks the problem reported by
        Ralf Wildenhues in
        <http://lists.gnu.org/archive/html/bug-gnulib/2006-12/msg00084.html>
        and in <http://gcc.gnu.org/ml/gcc/2006-12/msg00459.html>.
        * doc/autoconf.texi (C Compiler, C++ Compiler):
        (Objective C Compiler): Mention -fwrapv.
        (Optimization and Wraparound, Signed Integer Divison):
        New sections.
        * lib/autoconf/c.m4 (_AC_PROG_CC_G, _AC_PROG_CXX_G):
        (_AC_PROG_OBJC_G): Default to -O2 -fwrapv if GCC and if -fwrapv
        is supported, not merely to -O2.
        * tests/c.at (AC_PROG_CC with GCC optimization flags): New test.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.422
diff -u -p -r1.422 NEWS
--- NEWS        19 Dec 2006 05:41:18 -0000      1.422
+++ NEWS        29 Dec 2006 06:53:23 -0000
@@ -1,5 +1,13 @@
 * Major changes in Autoconf 2.61b (????-??-??)

+** AC_PROG_CC, AC_PROG_CXX, and AC_PROG_OBJC now take an optional
+   2nd arg specifying the default optimization options for GCC.
+   If GCC supports -fwrapv, these optimizations now default to
+   "-O2 -fwrapv" instead of "-O2"; this better supports the
+   traditional C idiom where signed integer overflow wraps around.
+   If you know your C application's signed integers never overflow,
+   you can reinstitute the old default with AC_PROG_CC([], [-O2]).
+
 ** Warnings are now generated by default when an installer invokes
    'configure' with an unknown --enable-* or --with-* option.
    These warnings can be disabled with the new AC_DISABLE_OPTION_CHECKING
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1121
diff -u -p -r1.1121 autoconf.texi
--- doc/autoconf.texi   29 Dec 2006 06:44:42 -0000      1.1121
+++ doc/autoconf.texi   29 Dec 2006 06:53:24 -0000
@@ -6322,7 +6322,7 @@ makes this invalid.  That is why Autocon
 @code{#line} directives.
 @end table

address@hidden AC_PROG_CC (@ovar{compiler-search-list})
address@hidden AC_PROG_CC (@ovar{compiler-search-list}, 
@ovar{gcc-default-optimization})
 @acindex{PROG_CC}
 @ovindex CC
 @ovindex CFLAGS
@@ -6355,9 +6355,11 @@ variable

 If using the @acronym{GNU} C compiler, set shell variable @code{GCC} to
 @samp{yes}.  If output variable @code{CFLAGS} was not already set, set
-it to @option{-g -O2} for the @acronym{GNU} C compiler (@option{-O2} on systems
-where @acronym{GCC} does not accept @option{-g}), or @option{-g} for
-other compilers.
+it to @option{-g} if available, followed by the default @abbr{GCC}
+optimization options if using @abbr{GCC}.  These @abbr{GCC} default
+options are @var{gcc-default-optimization} if nonempty, otherwise
address@hidden -fwrapv} if @option{-fwrapv} is available, otherwise plain
address@hidden  @xref{Integer Overflow}, for more about @option{-fwrapv}.
 @end defmac

 @defmac AC_PROG_CC_C_O
@@ -6664,7 +6666,7 @@ compiler fix the header files automatica
 @subsection C++ Compiler Characteristics


address@hidden AC_PROG_CXX (@ovar{compiler-search-list})
address@hidden AC_PROG_CXX (@ovar{compiler-search-list}, 
@ovar{gcc-default-optimization})
 @acindex{PROG_CXX}
 @ovindex CXX
 @ovindex CXXFLAGS
@@ -6690,9 +6692,11 @@ AC_PROG_CXX([gcc cl KCC CC cxx cc++ xlC 

 If using the @acronym{GNU} C++ compiler, set shell variable @code{GXX} to
 @samp{yes}.  If output variable @code{CXXFLAGS} was not already set, set
-it to @option{-g -O2} for the @acronym{GNU} C++ compiler (@option{-O2} on
-systems where G++ does not accept @option{-g}), or @option{-g} for other
-compilers.
+it to @option{-g} if available, followed by the default @abbr{GCC}
+optimization options if using @abbr{GCC}.  These @abbr{GCC} default
+options are @var{gcc-default-optimization} if nonempty, otherwise
address@hidden -fwrapv} if @option{-fwrapv} is available, otherwise plain
address@hidden  @xref{Integer Overflow}, for more about @option{-fwrapv}.
 @end defmac

 @defmac AC_PROG_CXXCPP
@@ -6723,7 +6727,7 @@ if it does not.
 @subsection Objective C Compiler Characteristics


address@hidden AC_PROG_OBJC (@ovar{compiler-search-list})
address@hidden AC_PROG_OBJC (@ovar{compiler-search-list}, 
@ovar{gcc-default-optimization})
 @acindex{PROG_OBJC}
 @ovindex OBJC
 @ovindex OBJCFLAGS
@@ -6744,9 +6748,12 @@ AC_PROG_OBJC([gcc objcc objc])

 If using the @acronym{GNU} Objective C compiler, set shell variable
 @code{GOBJC} to @samp{yes}.  If output variable @code{OBJCFLAGS} was not
-already set, set it to @option{-g -O2} for the @acronym{GNU} Objective C
-compiler (@option{-O2} on systems where @command{gcc} does not accept
address@hidden), or @option{-g} for other compilers.
+already set, set
+it to @option{-g} if available, followed by the default @abbr{GCC}
+optimization options if using @abbr{GCC}.  These default @abbr{GCC}
+options are @var{gcc-default-optimization} if nonempty, otherwise
address@hidden -fwrapv} if @option{-fwrapv} is available, otherwise plain
address@hidden  @xref{Integer Overflow}, for more about @option{-fwrapv}.
 @end defmac

 @defmac AC_PROG_OBJCCPP
@@ -14950,14 +14957,139 @@ the programs work well enough in practic
 @node Integer Overflow
 @section Integer Overflow
 @cindex overflow, arithmetic
address@hidden wraparound arithmetic
+
+In languages like C, unsigned integer overflow reliably wraps around
+modulo the word size.  This is guaranteed by the C standard and is
+portable in practice.  However, signed integer overflow leads to
+undefined behavior where a program can do anything, including dumping
+core or overrunning a buffer: the misbehavior can even precede the
+overflow.  Such an overflow can occur during addition, subtraction,
+multiplication, and left shift.

-In C, signed integer overflow leads to undefined behavior.  However,
-many programs and Autoconf tests assume that signed integer overflow after
-addition, subtraction, or multiplication silently
+Many programs and Autoconf tests assume that signed integer overflow silently
 wraps around modulo a power of two, using two's complement arithmetic,
 so long as you cast the resulting value
-to an integer type or store it into an integer variable.  Such programs
-are portable to the vast majority of modern platforms.  However, signed
+to an integer type or store it into an integer variable.  If you use
+conservative optimization flags, such programs are generally portable to
+the vast majority of modern platforms, with one main exception: signed
+integer division.
+
address@hidden users should consider using the @option{-ftrapv} option if
+they are worried about porting their code to platforms where signed
+integer overflow does not reliably wrap around.
+
address@hidden
+* Optimization and Wraparound::  Optimizations that break uses of wraparaound
+* Signed Integer Division::      @code{INT_MIN / -1} and @code{INT_MIN % -1}
address@hidden menu
+
address@hidden Optimization and Wraparound
address@hidden Optimizations That Break Wraparound Arithmetic
address@hidden loop induction
+
+Compilers sometimes generate code that is incompatible with wraparound
+integer arithmetic.  A common case of this is loop induction
+optimizations that take advantage of signed overflow officially having
+undefined beahvior.
+
+For an example of loop induction, consider the following contrived
+function @code{sumc}:
+
address@hidden
+int
+sumc (int lo, int hi)
address@hidden
+  int sum = 0;
+  int i;
+  for (i = lo; i <= hi; i++)
+    sum ^= i * 100;
+  return sum;
address@hidden
address@hidden example
+
address@hidden
+To avoid multiplying by 100 each time through the loop, an optimizing
+compiler might internally transform @code{sumc} to the equivalent of the
+following:
+
address@hidden
+int
+transformed_sumc (int lo, int hi)
address@hidden
+  int sum = 0;
+  int hic = hi * 100;
+  int ic;
+  for (ic = lo * 100; ic <= hic; ic += 100)
+    sum ^= ic;
+  return sum;
address@hidden
address@hidden example
+
address@hidden
+If integer overflow is defined to wrap around modulo a power of two,
+this transformation is invalid when @code{INT_MAX / 100 < hi}, because
+then the overflow in computing expressions like @code{hi * 100} causes
+the expression @code{i <= hi} to yield a different value from the
+transformed expression @code{ic <= hic}.
+
+For this reason, compilers that use loop induction and similar
+techniques often do not support reliable wraparound arithmetic when a
+loop induction variable like @code{ic} is involved.  Since loop
+induction variables are generated by the compiler, and are not visible
+in the source code, it is not always trivial to say whether the problem
+affects your code.
+
+Hardly any code actually depends on wraparound arithmetic in cases like
+these, so in practice these loop induction optimizations are almost
+always useful.  However, @acronym{GCC} currently does not have an easy
+way to enable useful loop induction optimizations without also breaking
+common code that works on traditional C implementations.  For example:
+
address@hidden
+int j;
+for (j = 1; 0 < j; j *= 2)
+  test (j);
address@hidden example
+
address@hidden
+Here, the code is attempting to iterate through all powers of two that
address@hidden can represent, but @acronym{GCC}'s loop induction
+optimization can turn this into an infinite loop.
+
+To work around this problem, Autoconf-generated @command{configure}
+scripts by default compile with @option{-fwrapv} when using
address@hidden, assuming @acronym{GCC} is modern enough to support
address@hidden  The @option{-fwrapv} option requires @command{GCC}
+to implement wraparound arithmetic for signed integers.  In some cases
address@hidden makes code perform better and in some cases worse, but the
+important thing is that it leads to better-defined behavior that matches
+long-standing C tradition, so it is less likely to break existing code.
+
+A maintainer can override the default for @abbr{GCC} optimization flags
+by specifying the optional second operand of @code{AC_PROG_CC},
address@hidden, and @code{AC_PROG_OBJC}.  For example:
+
address@hidden
+# This package works even when integer overflow has
+# undefined behavior and floating point arithmetic
+# is nonstandard, so when using gcc don't default to
+# -fwrapv and do default to -ffast-math.
+AC_PROG_CC([], [-O2 -ffast-math])
address@hidden example
+
+Also, an installer can override the default by specifying @code{CFLAGS}
+when invoking @command{configure}.  For example:
+
address@hidden
+./configure CFLAGS='-g -O2 -ffast-math'
address@hidden example
+
address@hidden Signed Integer Division
address@hidden Signed Integer Division and Integer Overflow
address@hidden division, integer
+
+Overflow in signed
 integer division is not always harmless: for example, on CPUs of the
 i386 family, dividing @code{INT_MIN} by @code{-1} yields a SIGFPE signal
 which by default terminates the program.  Worse, taking the remainder
@@ -14965,14 +15097,6 @@ of these two values typically yields the
 even though the C standard requires @code{INT_MIN % -1} to yield zero
 because the expression does not overflow.

address@hidden users might consider using the
address@hidden option if they are worried about porting their code to
-the rare platforms where signed integer overflow does not wrap around
-after addition, subtraction, or multiplication.
-
-Unsigned integer overflow reliably wraps around modulo the word size.
-This is guaranteed by the C standard and is portable in practice.
-
 @node Null Pointers
 @section Properties of Null Pointers
 @cindex null pointers
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.242
diff -u -p -r1.242 c.m4
--- lib/autoconf/c.m4   7 Dec 2006 06:39:40 -0000       1.242
+++ lib/autoconf/c.m4   29 Dec 2006 06:53:24 -0000
@@ -513,11 +513,14 @@ AU_DEFUN([ac_cv_prog_gcc],
 [ac_cv_c_compiler_gnu])


-# AC_PROG_CC([COMPILER ...])
-# --------------------------
+# AC_PROG_CC([COMPILER ...], [GCC OPTIMIZATION OPTIONS ...])
+# ----------------------------------------------------------
 # COMPILER ... is a space separated list of C compilers to search for.
 # This just gives the user an opportunity to specify an alternative
 # search list for the C compiler.
+# GCC OPTIMIZATION OPTIONS is a space separated list of GCC
+# optimization options to default to.  The default is -O2 with -fwrapv
+# appended if supported.
 AN_MAKEVAR([CC],  [AC_PROG_CC])
 AN_PROGRAM([cc],  [AC_PROG_CC])
 AN_PROGRAM([gcc], [AC_PROG_CC])
@@ -566,52 +569,64 @@ if test $ac_compiler_gnu = yes; then
 else
   GCC=
 fi
-_AC_PROG_CC_G
+_AC_PROG_COMPILER_G([CFLAGS], [CC], [cc], [c], [GCC], [$2])
 _AC_PROG_CC_C89
 AC_LANG_POP(C)dnl
 ])# AC_PROG_CC


-# _AC_PROG_CC_G
-# -------------
+# _AC_PROG_COMPILER_G(CFLAGS, CC, cc, c, GCC, [GCC-OPTIONS])
+# ----------------------------------------------------------
 # Check whether -g works, even if CFLAGS is set, in case the package
 # plays around with CFLAGS (such as to build both debugging and normal
 # versions of a library), tasteless as that idea is.
 # Don't consider -g to work if it generates warnings when plain compiles don't.
-m4_define([_AC_PROG_CC_G],
-[ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
-  [ac_save_c_werror_flag=$ac_c_werror_flag
-   ac_c_werror_flag=yes
-   ac_cv_prog_cc_g=no
-   CFLAGS="-g"
+# The compiler is $CC; cache variables use the strings 'cc' for the compiler
+# and 'c' for the language, and $GCC says whether the compiler is GCC.
+# Use GCC-OPTIONS if GCC is detected; if GCC-OPTIONS is empty
+# default to -O2 -fwrapv if supported, -O2 otherwise.
+m4_define([_AC_PROG_COMPILER_G],
+[ac_test_$1=${$1+set}
+ac_save_$1=$$1
+AC_CACHE_CHECK(whether $$2 accepts -g, ac_cv_prog_$3_g,
+  [ac_save_$4_werror_flag=$ac_$4_werror_flag
+   ac_$4_werror_flag=yes
+   ac_cv_prog_$3_g=no
+   $1="-g"
    _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-     [ac_cv_prog_cc_g=yes],
-     [CFLAGS=""
+     [ac_cv_prog_$3_g=yes],
+     [$1=""
       _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
        [],
-       [ac_c_werror_flag=$ac_save_c_werror_flag
-        CFLAGS="-g"
+       [ac_$4_werror_flag=$ac_save_$4_werror_flag
+        $1="-g"
         _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-          [ac_cv_prog_cc_g=yes])])])
-   ac_c_werror_flag=$ac_save_c_werror_flag])
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
+          [ac_cv_prog_$3_g=yes])])])
+   ac_$4_werror_flag=$ac_save_$4_werror_flag])
+if test "$ac_test_$1" = set; then
+  $1=$ac_save_$1
 else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
+  if test $ac_cv_prog_$3_g = yes; then
+    ac_$1='-g' ac_sep=' '
   else
-    CFLAGS=
+    ac_$1=     ac_sep=
+  fi
+  $1=$ac_$1
+  if test "$$5" = yes; then
+    m4_ifval([$6],
+      [$1="$$1$ac_sep$6"],
+      [$1="$$1$ac_sep-O2 -fwrapv"
+       _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+        [if test -s conftest.err; then
+           # Disable -O2 if the compiler warns about -fwrapv but succeeds.
+           # That is how icc behaves, and icc -O2 does not support
+           # wraparound semantics for signed integer overflow.
+           $1=$ac_$1
+         fi],
+        [$1="$ac_$1$ac_sep-O2"])])
   fi
 fi[]dnl
-])# _AC_PROG_CC_G
+])# _AC_PROG_COMPILER_G


 # AC_PROG_GCC_TRADITIONAL
@@ -750,12 +765,15 @@ AU_DEFUN([ac_cv_prog_gxx],
 [ac_cv_cxx_compiler_gnu])


-# AC_PROG_CXX([LIST-OF-COMPILERS])
-# --------------------------------
+# AC_PROG_CXX([LIST-OF-COMPILERS], [GCC OPTIMIZATION OPTIONS ...])
+# ----------------------------------------------------------------
 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
 # for (if not specified, a default list is used).  This just gives the
 # user an opportunity to specify an alternative search list for the C++
 # compiler.
+# GCC OPTIMIZATION OPTIONS is a space separated list of GCC
+# optimization options to default to.  The default is -O2 with -fwrapv
+# appended if supported.
 # aCC  HP-UX C++ compiler much better than `CC', so test before.
 # FCC   Fujitsu C++ compiler
 # KCC  KAI C++ compiler
@@ -800,53 +818,11 @@ if test $ac_compiler_gnu = yes; then
 else
   GXX=
 fi
-_AC_PROG_CXX_G
+_AC_PROG_COMPILER_G([CXXFLAGS], [CXX], [cxx], [cxx], [GXX], [$2])
 AC_LANG_POP(C++)dnl
 ])# AC_PROG_CXX


-# _AC_PROG_CXX_G
-# --------------
-# Check whether -g works, even if CXXFLAGS is set, in case the package
-# plays around with CXXFLAGS (such as to build both debugging and
-# normal versions of a library), tasteless as that idea is.
-# Don't consider -g to work if it generates warnings when plain compiles don't.
-m4_define([_AC_PROG_CXX_G],
-[ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
-  [ac_save_cxx_werror_flag=$ac_cxx_werror_flag
-   ac_cxx_werror_flag=yes
-   ac_cv_prog_cxx_g=no
-   CXXFLAGS="-g"
-   _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-     [ac_cv_prog_cxx_g=yes],
-     [CXXFLAGS=""
-      _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-       [],
-       [ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-        CXXFLAGS="-g"
-        _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-          [ac_cv_prog_cxx_g=yes])])])
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag])
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi[]dnl
-])# _AC_PROG_CXX_G
-
-
 # AC_PROG_CXX_C_O
 # ---------------
 # Test if the C++ compiler accepts the options `-c' and `-o'
@@ -929,12 +905,15 @@ AC_DEFUN([AC_LANG_COMPILER(Objective C)]



-# AC_PROG_OBJC([LIST-OF-COMPILERS])
-# ---------------------------------
+# AC_PROG_OBJC([LIST-OF-COMPILERS], [GCC OPTIMIZATION OPTIONS ...])
+# -----------------------------------------------------------------
 # LIST-OF-COMPILERS is a space separated list of Objective C compilers to
 # search for (if not specified, a default list is used).  This just gives
 # the user an opportunity to specify an alternative search list for the
 # Objective C compiler.
+# GCC OPTIMIZATION OPTIONS is a space separated list of GCC
+# optimization options to default to.  The default is -O2 with -fwrapv
+# appended if supported.
 # objcc StepStone Objective-C compiler (also "standard" name for OBJC)
 # objc  David Stes' POC.  If you installed this, you likely want it.
 # cc    Native C compiler (for instance, Apple).
@@ -970,52 +949,11 @@ else
   GOBJC=
 fi
 _AC_PROG_OBJC_G
+_AC_PROG_COMPILER_G([OBJCFLAGS], [OBJC], [objc], [objc], [GOBC], [$2])
 AC_LANG_POP(Objective C)dnl
 ])# AC_PROG_OBJC


-# _AC_PROG_OBJC_G
-# ---------------
-# Check whether -g works, even if OBJCFLAGS is set, in case the package
-# plays around with OBJCFLAGS (such as to build both debugging and
-# normal versions of a library), tasteless as that idea is.
-# Don't consider -g to work if it generates warnings when plain compiles don't.
-m4_define([_AC_PROG_OBJC_G],
-[ac_test_OBJCFLAGS=${OBJCFLAGS+set}
-ac_save_OBJCFLAGS=$OBJCFLAGS
-AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
-  [ac_save_objc_werror_flag=$ac_objc_werror_flag
-   ac_objc_werror_flag=yes
-   ac_cv_prog_objc_g=no
-   OBJCFLAGS="-g"
-   _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-     [ac_cv_prog_objc_g=yes],
-     [OBJCFLAGS=""
-      _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-       [],
-       [ac_objc_werror_flag=$ac_save_objc_werror_flag
-        OBJCFLAGS="-g"
-        _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-          [ac_cv_prog_objc_g=yes])])])
-   ac_objc_werror_flag=$ac_save_objc_werror_flag])
-if test "$ac_test_OBJCFLAGS" = set; then
-  OBJCFLAGS=$ac_save_OBJCFLAGS
-elif test $ac_cv_prog_objc_g = yes; then
-  if test "$GOBJC" = yes; then
-    OBJCFLAGS="-g -O2"
-  else
-    OBJCFLAGS="-g"
-  fi
-else
-  if test "$GOBJC" = yes; then
-    OBJCFLAGS="-O2"
-  else
-    OBJCFLAGS=
-  fi
-fi[]dnl
-])# _AC_PROG_OBJC_G
-
-



Index: tests/c.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/c.at,v
retrieving revision 1.10
diff -u -p -r1.10 c.at
--- tests/c.at  17 Nov 2006 21:04:54 -0000      1.10
+++ tests/c.at  29 Dec 2006 06:53:24 -0000
@@ -70,6 +70,23 @@ AT_CHECK_CONFIGURE([], 77, ignore, ignor
 AT_CLEANUP


+
+## -------------------- ##
+## Optimization flags.  ##
+## -------------------- ##
+
+AT_CHECK_MACRO([AC_PROG_CC with GCC optimization flags],
+[[if test "${CFLAGS+set}" != set; then
+    AC_PROG_CC([], [-O -O])
+    case $GCC,$CFLAGS in
+    yes,'-g -O -O') ;;
+    yes,*) AC_MSG_ERROR([CFLAGS='$CFLAGS'; should be '-g -O -O']);;
+    esac
+  fi
+]])
+
+
+
 ## ------------ ##
 ## C keywords.  ##
 ## ------------ ##




reply via email to

[Prev in Thread] Current Thread [Next in Thread]