Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 37278c0

Browse files
committed
Cause the default CFLAGS to be -O2 -fno-strict-aliasing when using gcc,
per recent pghackers discussions. Also ensure that explicitly setting CFLAGS in the configure environment will be honored.
1 parent 3992f1c commit 37278c0

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

configure

+18-8
Original file line numberDiff line numberDiff line change
@@ -2389,18 +2389,28 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
23892389
#
23902390
. "$srcdir/src/template/$template" || exit
23912391

2392-
# adjust CFLAGS per template
2392+
# The template may have supplied a default setting for CFLAGS.
2393+
# Override this if CFLAGS was set in the original environment.
23932394
if test "$ac_env_CFLAGS_set" = set; then
23942395
CFLAGS=$ac_env_CFLAGS_value
2395-
fi
2396-
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
2397-
CFLAGS="$CFLAGS -g"
23982396
else
2399-
# configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc
2400-
if test x"$CFLAGS" = x""; then
2401-
CFLAGS="-O"
2397+
# autoconf already set the default CFLAGS for gcc to be -O2, but we
2398+
# need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
2399+
if test "$GCC" = yes; then
2400+
CFLAGS="$CFLAGS -fno-strict-aliasing"
24022401
fi
24032402
fi
2403+
# supply -g if --enable-debug
2404+
if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
2405+
CFLAGS="$CFLAGS -g"
2406+
fi
2407+
# default to -O rather than empty CFLAGS; this path will not be taken for
2408+
# gcc (since autoconf supplies -O2), nor if --enable-debug (because -O -g
2409+
# doesn't work on most non-gcc compilers), nor if the template provided
2410+
# some CFLAGS.
2411+
if test "$ac_env_CFLAGS_set" != set -a x"$CFLAGS" = x""; then
2412+
CFLAGS="-O"
2413+
fi
24042414
{ echo "$as_me:$LINENO: using CFLAGS=$CFLAGS" >&5
24052415
echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
24062416

@@ -2457,7 +2467,7 @@ echo "$as_me: error: cannot proceed" >&2;}
24572467
fi
24582468
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
24592469

2460-
# Defend against gcc -ffastmath
2470+
# Defend against gcc -ffast-math
24612471
if test "$GCC" = yes; then
24622472
cat >conftest.$ac_ext <<_ACEOF
24632473
#line $LINENO "configure"

configure.in

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.295 2003/10/14 00:48:09 momjian Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.296 2003/10/15 22:23:56 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -234,18 +234,28 @@ AC_PROG_CC([$pgac_cc_list])
234234
#
235235
. "$srcdir/src/template/$template" || exit
236236

237-
# adjust CFLAGS per template
237+
# The template may have supplied a default setting for CFLAGS.
238+
# Override this if CFLAGS was set in the original environment.
238239
if test "$ac_env_CFLAGS_set" = set; then
239240
CFLAGS=$ac_env_CFLAGS_value
240-
fi
241-
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
242-
CFLAGS="$CFLAGS -g"
243241
else
244-
# configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc
245-
if test x"$CFLAGS" = x""; then
246-
CFLAGS="-O"
242+
# autoconf already set the default CFLAGS for gcc to be -O2, but we
243+
# need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
244+
if test "$GCC" = yes; then
245+
CFLAGS="$CFLAGS -fno-strict-aliasing"
247246
fi
248247
fi
248+
# supply -g if --enable-debug
249+
if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
250+
CFLAGS="$CFLAGS -g"
251+
fi
252+
# default to -O rather than empty CFLAGS; this path will not be taken for
253+
# gcc (since autoconf supplies -O2), nor if --enable-debug (because -O -g
254+
# doesn't work on most non-gcc compilers), nor if the template provided
255+
# some CFLAGS.
256+
if test "$ac_env_CFLAGS_set" != set -a x"$CFLAGS" = x""; then
257+
CFLAGS="-O"
258+
fi
249259
AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
250260

251261
# We already have this in Makefile.win32, but configure needs it too
@@ -261,7 +271,7 @@ AC_TRY_LINK([], [return 0;],
261271
[AC_MSG_RESULT(no)
262272
AC_MSG_ERROR([cannot proceed])])
263273

264-
# Defend against gcc -ffastmath
274+
# Defend against gcc -ffast-math
265275
if test "$GCC" = yes; then
266276
AC_TRY_COMPILE([], [@%:@ifdef __FAST_MATH__
267277
choke me

0 commit comments

Comments
 (0)