Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit378f599

Browse files
committed
Fix CFLAGS selection to actually work. Add test to detect whether gcc's
option -fno-strict-aliasing is available.
1 parent6db0a6b commit378f599

File tree

12 files changed

+144
-53
lines changed

12 files changed

+144
-53
lines changed

‎config/c-compiler.m4

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Macros to detect C compiler features
2-
# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.8 2003/04/24 21:16:42 tgl Exp $
2+
# $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.9 2003/10/25 15:32:11 petere Exp $
33

44

55
# PGAC_C_SIGNED
@@ -97,7 +97,7 @@ AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1),
9797

9898

9999
# PGAC_C_FUNCNAME_SUPPORT
100-
# -------------
100+
# -----------------------
101101
# Check if the C compiler understands __func__ (C99) or __FUNCTION__ (gcc).
102102
# Define HAVE_FUNCNAME__FUNC or HAVE_FUNCNAME__FUNCTION accordingly.
103103
AC_DEFUN([PGAC_C_FUNCNAME_SUPPORT],
@@ -120,3 +120,32 @@ AC_DEFINE(HAVE_FUNCNAME__FUNCTION, 1,
120120
[Define to 1 if your compiler understands __FUNCTION__.])
121121
fi
122122
fi])# PGAC_C_FUNCNAME_SUPPORT
123+
124+
125+
# PGAC_PROG_CC_NO_STRICT_ALIASING
126+
# -------------------------------
127+
# Find out how to turn off strict aliasing in the C compiler.
128+
AC_DEFUN([PGAC_PROG_CC_NO_STRICT_ALIASING],
129+
[AC_CACHE_CHECK([how to turn off strict aliasing in $CC],
130+
pgac_cv_prog_cc_no_strict_aliasing,
131+
[pgac_save_CFLAGS=$CFLAGS
132+
if test "$GCC" = yes; then
133+
pgac_try="-fno-strict-aliasing"
134+
else
135+
# Maybe fill in later...
136+
pgac_try=
137+
fi
138+
139+
for pgac_flag in $pgac_try; do
140+
CFLAGS="$pgac_save_CFLAGS $pgac_flag"
141+
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
142+
[pgac_cv_prog_cc_no_strict_aliasing=$pgac_try
143+
break])
144+
done
145+
146+
CFLAGS=$pgac_save_CFLAGS
147+
])
148+
149+
if test "$ac_env_CFLAGS_set" != set; then
150+
CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
151+
fi])# PGAC_PROG_CC_NO_STRICT_ALIASING

‎configure

Lines changed: 83 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ Optional Features:
841841
--enable-nls[=LANGUAGES] enable Native Language Support
842842
--disable-shared do not build shared libraries
843843
--disable-rpath do not embed shared library search path in executables
844-
--disable-spinlocks do not useSpinlocks
844+
--disable-spinlocks do not usespinlocks
845845
--enable-debug build with debugging symbols (-g)
846846
--enable-depend turn on automatic dependency tracking
847847
--enable-cassert enable assertion checks (for debugging)
@@ -2384,40 +2384,105 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
23842384
ac_compiler_gnu=$ac_cv_c_compiler_gnu
23852385

23862386

2387+
pgac_CFLAGS_before_template=$CFLAGS
2388+
23872389
#
23882390
# Read the template
23892391
#
23902392
. "$srcdir/src/template/$template" || exit
23912393

2392-
# The template may have supplied a default setting for CFLAGS.
2393-
# Override this if CFLAGS was set in the original environment.
2394+
# CFLAGS are selected so:
2395+
# If the user specifies something in the environment, that is used.
2396+
# else: If the template file set something, that is used.
2397+
# else: If the compiler is GCC, then we use -O2.
2398+
# else: If the compiler is something else, then we use -0.
2399+
23942400
if test "$ac_env_CFLAGS_set" = set; then
23952401
CFLAGS=$ac_env_CFLAGS_value
2402+
elif test "$pgac_CFLAGS_before_template" != "$CFLAGS"; then
2403+
: # (keep what template set)
2404+
elif test "$GCC" = yes; then
2405+
CFLAGS="-O2"
23962406
else
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"
2401-
fi
2407+
CFLAGS="-O"
2408+
fi
2409+
2410+
# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
2411+
echo "$as_me:$LINENO: checking how to turn off strict aliasing in $CC" >&5
2412+
echo $ECHO_N "checking how to turn off strict aliasing in $CC... $ECHO_C" >&6
2413+
if test "${pgac_cv_prog_cc_no_strict_aliasing+set}" = set; then
2414+
echo $ECHO_N "(cached) $ECHO_C" >&6
2415+
else
2416+
pgac_save_CFLAGS=$CFLAGS
2417+
if test "$GCC" = yes; then
2418+
pgac_try="-fno-strict-aliasing"
2419+
else
2420+
# Maybe fill in later...
2421+
pgac_try=
2422+
fi
2423+
2424+
for pgac_flag in $pgac_try; do
2425+
CFLAGS="$pgac_save_CFLAGS $pgac_flag"
2426+
cat >conftest.$ac_ext <<_ACEOF
2427+
#line $LINENO "configure"
2428+
#include "confdefs.h"
2429+
2430+
#ifdef F77_DUMMY_MAIN
2431+
# ifdef __cplusplus
2432+
extern "C"
2433+
# endif
2434+
int F77_DUMMY_MAIN() { return 1; }
2435+
#endif
2436+
int
2437+
main ()
2438+
{
2439+
2440+
;
2441+
return 0;
2442+
}
2443+
_ACEOF
2444+
rm -f conftest.$ac_objext
2445+
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2446+
(eval $ac_compile) 2>&5
2447+
ac_status=$?
2448+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2449+
(exit $ac_status); } &&
2450+
{ ac_try='test -s conftest.$ac_objext'
2451+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2452+
(eval $ac_try) 2>&5
2453+
ac_status=$?
2454+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2455+
(exit $ac_status); }; }; then
2456+
pgac_cv_prog_cc_no_strict_aliasing=$pgac_try
2457+
break
2458+
else
2459+
echo "$as_me: failed program was:" >&5
2460+
cat conftest.$ac_ext >&5
2461+
fi
2462+
rm -f conftest.$ac_objext conftest.$ac_ext
2463+
done
2464+
2465+
CFLAGS=$pgac_save_CFLAGS
2466+
24022467
fi
2468+
echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_no_strict_aliasing" >&5
2469+
echo "${ECHO_T}$pgac_cv_prog_cc_no_strict_aliasing" >&6
2470+
2471+
if test "$ac_env_CFLAGS_set" != set; then
2472+
CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
2473+
fi
2474+
24032475
# supply -g if --enable-debug
24042476
if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
24052477
CFLAGS="$CFLAGS -g"
24062478
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
2479+
24142480
{ echo "$as_me:$LINENO: using CFLAGS=$CFLAGS" >&5
24152481
echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
24162482

24172483
# We already have this in Makefile.win32, but configure needs it too
2418-
if test "$PORTNAME" = "win32"
2419-
then
2420-
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
2484+
if test "$PORTNAME" = "win32"; then
2485+
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
24212486
fi
24222487

24232488
# Check if the compiler still works with the template settings

‎configure.in

Lines changed: 22 additions & 19 deletions
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.297 2003/10/22 04:16:39 pgsql Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.298 2003/10/25 15:32:11 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -203,7 +203,7 @@ AC_SUBST(enable_rpath)
203203
# Spinlocks
204204
#
205205
PGAC_ARG_BOOL(enable, spinlocks, yes,
206-
[ --disable-spinlocks do not useSpinlocks])
206+
[ --disable-spinlocks do not usespinlocks])
207207

208208
#
209209
# --enable-debug adds -g to compiler flags
@@ -229,39 +229,42 @@ esac
229229

230230
AC_PROG_CC([$pgac_cc_list])
231231

232+
pgac_CFLAGS_before_template=$CFLAGS
233+
232234
#
233235
# Read the template
234236
#
235237
. "$srcdir/src/template/$template" || exit
236238

237-
# The template may have supplied a default setting for CFLAGS.
238-
# Override this if CFLAGS was set in the original environment.
239+
# CFLAGS are selected so:
240+
# If the user specifies something in the environment, that is used.
241+
# else: If the template file set something, that is used.
242+
# else: If the compiler is GCC, then we use -O2.
243+
# else: If the compiler is something else, then we use -0.
244+
239245
if test "$ac_env_CFLAGS_set" = set; then
240246
CFLAGS=$ac_env_CFLAGS_value
247+
elif test "$pgac_CFLAGS_before_template" != "$CFLAGS"; then
248+
: # (keep what template set)
249+
elif test "$GCC" = yes; then
250+
CFLAGS="-O2"
241251
else
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"
246-
fi
252+
CFLAGS="-O"
247253
fi
254+
255+
# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
256+
PGAC_PROG_CC_NO_STRICT_ALIASING
257+
248258
# supply -g if --enable-debug
249259
if test "$enable_debug" = yes -a "$ac_cv_prog_cc_g" = yes; then
250260
CFLAGS="$CFLAGS -g"
251261
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
262+
259263
AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
260264

261265
# We already have this in Makefile.win32, but configure needs it too
262-
if test "$PORTNAME" = "win32"
263-
then
264-
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
266+
if test "$PORTNAME" = "win32"; then
267+
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
265268
fi
266269

267270
# Check if the compiler still works with the template settings

‎src/template/aix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if test "$GCC" != yes ; then
22
case $host_os in
33
aix3.2.5 | aix4.1*) ;;
4-
*) CFLAGS="$CFLAGS-O2 -qlonglong";;
4+
*) CFLAGS="-O2 -qlonglong";;
55
esac
6-
CFLAGS="$CFLAGS -qmaxmem=16384 -qsrcmsg"
6+
CFLAGS="-O -qmaxmem=16384 -qsrcmsg"
77
fi

‎src/template/bsdi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
case $host_cpu in
2-
i?86) CFLAGS="$CFLAGS -m486";;
3-
esac
4-
51
case $host_os in
62
bsdi2.0 | bsdi2.1 | bsdi3*) CC=gcc2;;
73
esac

‎src/template/freebsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
case $host_cpu in
2-
alpha*) CFLAGS="$CFLAGS-O";; # alpha has problems with -O2
2+
alpha*) CFLAGS="-O";; # alpha has problems with -O2
33
esac
44

55
THREAD_SUPPORT=yes

‎src/template/hpux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED"
22

33
if test "$GCC" != yes ; then
44
CC="$CC -Ae"
5-
CFLAGS="$CFLAGS+O2"
5+
CFLAGS="+O2"
66
fi

‎src/template/osf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if test "$GCC" != yes ; then
22
CC="$CC -std"
3-
CFLAGS="$CFLAGS-O4 -Olimit 2000"
3+
CFLAGS="-O4 -Olimit 2000"
44
fi
55

66
THREAD_SUPPORT=yes

‎src/template/qnx4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
CFLAGS="$CFLAGS -I/usr/local/include"
21
LIBS="-lunix"

‎src/template/solaris

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
if test "$GCC" != yes ; then
22
CC="$CC -Xa"# relaxed ISO C mode
3-
CFLAGS="$CFLAGS-O -v"# -v is like gcc -Wall
3+
CFLAGS="-O -v"# -v is like gcc -Wall
44
fi
55

66
THREAD_SUPPORT=yes
77
NEED_REENTRANT_FUNCS=yes# 5.6 2003-09-13
88
THREAD_LIBS="-pthread"
9-

‎src/template/univel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
CFLAGS="$CFLAGS-v -O -K i486,host,inline,loop_unroll -Dsvr4"
1+
CFLAGS="-v -O -K i486,host,inline,loop_unroll -Dsvr4"
22
LIBS="-lc89"

‎src/template/unixware

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ else
44
# the -Kno_host is temporary for a bug in the compiler. See -hackers
55
# discussion on 7-8/Aug/2003.
66
# when the 7.1.3UP3 or later compiler is out, we can do a version check.
7-
CFLAGS="$CFLAGS-O -Kinline,no_host"
7+
CFLAGS="-O -Kinline,no_host"
88
THREAD_CPPFLAGS="-K pthread"
99
fi
1010

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp