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

Commit857e210

Browse files
author
Neil Conway
committed
When using GCC, change the default CFLAGS to:
-O2 -Wall -Wmissing-prototypes -Wpointer-arithCheck whether the version of GCC we are using supports any of: -Wdeclaration-after-statement -Wendif-labels -Wold-style-definitionAnd add the supported flags to CFLAGS.
1 parenta1bc728 commit857e210

File tree

4 files changed

+173
-58
lines changed

4 files changed

+173
-58
lines changed

‎config/c-compiler.m4

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Macros to detect C compiler features
2-
# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.12 2004/02/02 04:07:18 tgl Exp $
2+
# $PostgreSQL: pgsql/config/c-compiler.m4,v 1.13 2004/10/20 02:12:07 neilc Exp $
33

44

55
# PGAC_C_SIGNED
@@ -121,35 +121,19 @@ AC_DEFINE(HAVE_FUNCNAME__FUNCTION, 1,
121121
fi
122122
fi])# PGAC_C_FUNCNAME_SUPPORT
123123

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 x"$pgac_cv_prog_cc_no_strict_aliasing" != x""; then
150-
CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
151-
fi])# PGAC_PROG_CC_NO_STRICT_ALIASING
152-
124+
# PGAC_PROG_CC_CFLAGS_OPT
125+
# -----------------------
126+
# Given a string, check if the compiler supports the string as a
127+
# command-line option. If it does, add the string to CFLAGS.
128+
AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT],
129+
[AC_MSG_CHECKING([if $CC supports$1])
130+
pgac_save_CFLAGS=$CFLAGS
131+
CFLAGS="$pgac_save_CFLAGS$1"
132+
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
133+
AC_MSG_RESULT(yes),
134+
[CFLAGS="$pgac_save_CFLAGS"
135+
AC_MSG_RESULT(no)])
136+
])# PGAC_PROG_CC_CFLAGS_OPT
153137

154138
# The below backpatches the following Autoconf change:
155139
#

‎configure

Lines changed: 145 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,23 +2432,61 @@ else
24322432
fi
24332433
fi
24342434

2435-
# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
2436-
echo "$as_me:$LINENO: checking how to turn off strict aliasing in $CC" >&5
2437-
echo $ECHO_N "checking how to turn off strict aliasing in $CC... $ECHO_C" >&6
2438-
if test "${pgac_cv_prog_cc_no_strict_aliasing+set}" = set; then
2439-
echo $ECHO_N "(cached) $ECHO_C" >&6
2440-
else
2441-
pgac_save_CFLAGS=$CFLAGS
24422435
if test "$GCC" = yes; then
2443-
pgac_try="-fno-strict-aliasing"
2436+
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
2437+
2438+
# Some versions of GCC support some additional useful warning flags.
2439+
# Check whether they are supported, and add them to CFLAGS if so.
2440+
echo "$as_me:$LINENO: checking if $CC supports -Wdeclaration-after-statement" >&5
2441+
echo $ECHO_N "checking if $CC supports -Wdeclaration-after-statement... $ECHO_C" >&6
2442+
pgac_save_CFLAGS=$CFLAGS
2443+
CFLAGS="$pgac_save_CFLAGS -Wdeclaration-after-statement"
2444+
cat >conftest.$ac_ext <<_ACEOF
2445+
#line $LINENO "configure"
2446+
#include "confdefs.h"
2447+
2448+
#ifdef F77_DUMMY_MAIN
2449+
# ifdef __cplusplus
2450+
extern "C"
2451+
# endif
2452+
int F77_DUMMY_MAIN() { return 1; }
2453+
#endif
2454+
int
2455+
main ()
2456+
{
2457+
2458+
;
2459+
return 0;
2460+
}
2461+
_ACEOF
2462+
rm -f conftest.$ac_objext
2463+
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2464+
(eval $ac_compile) 2>&5
2465+
ac_status=$?
2466+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2467+
(exit $ac_status); } &&
2468+
{ ac_try='test -s conftest.$ac_objext'
2469+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2470+
(eval $ac_try) 2>&5
2471+
ac_status=$?
2472+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2473+
(exit $ac_status); }; }; then
2474+
echo "$as_me:$LINENO: result: yes" >&5
2475+
echo "${ECHO_T}yes" >&6
24442476
else
2445-
# Maybe fill in later...
2446-
pgac_try=
2477+
echo "$as_me: failed program was:" >&5
2478+
cat conftest.$ac_ext >&5
2479+
CFLAGS="$pgac_save_CFLAGS"
2480+
echo "$as_me:$LINENO: result: no" >&5
2481+
echo "${ECHO_T}no" >&6
24472482
fi
2483+
rm -f conftest.$ac_objext conftest.$ac_ext
24482484

2449-
for pgac_flag in $pgac_try; do
2450-
CFLAGS="$pgac_save_CFLAGS $pgac_flag"
2451-
cat >conftest.$ac_ext <<_ACEOF
2485+
echo "$as_me:$LINENO: checking if $CC supports -Wold-style-definition" >&5
2486+
echo $ECHO_N "checking if $CC supports -Wold-style-definition... $ECHO_C" >&6
2487+
pgac_save_CFLAGS=$CFLAGS
2488+
CFLAGS="$pgac_save_CFLAGS -Wold-style-definition"
2489+
cat >conftest.$ac_ext <<_ACEOF
24522490
#line $LINENO "configure"
24532491
#include "confdefs.h"
24542492

@@ -2478,23 +2516,109 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
24782516
ac_status=$?
24792517
echo "$as_me:$LINENO: \$? = $ac_status" >&5
24802518
(exit $ac_status); }; }; then
2481-
pgac_cv_prog_cc_no_strict_aliasing=$pgac_try
2482-
break
2519+
echo "$as_me:$LINENO: result: yes" >&5
2520+
echo "${ECHO_T}yes" >&6
24832521
else
24842522
echo "$as_me: failed program was:" >&5
24852523
cat conftest.$ac_ext >&5
2524+
CFLAGS="$pgac_save_CFLAGS"
2525+
echo "$as_me:$LINENO: result: no" >&5
2526+
echo "${ECHO_T}no" >&6
24862527
fi
24872528
rm -f conftest.$ac_objext conftest.$ac_ext
2488-
done
24892529

2490-
CFLAGS=$pgac_save_CFLAGS
2530+
echo "$as_me:$LINENO: checking if $CC supports -Wendif-labels" >&5
2531+
echo $ECHO_N "checking if $CC supports -Wendif-labels... $ECHO_C" >&6
2532+
pgac_save_CFLAGS=$CFLAGS
2533+
CFLAGS="$pgac_save_CFLAGS -Wendif-labels"
2534+
cat >conftest.$ac_ext <<_ACEOF
2535+
#line $LINENO "configure"
2536+
#include "confdefs.h"
2537+
2538+
#ifdef F77_DUMMY_MAIN
2539+
# ifdef __cplusplus
2540+
extern "C"
2541+
# endif
2542+
int F77_DUMMY_MAIN() { return 1; }
2543+
#endif
2544+
int
2545+
main ()
2546+
{
24912547

2548+
;
2549+
return 0;
2550+
}
2551+
_ACEOF
2552+
rm -f conftest.$ac_objext
2553+
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2554+
(eval $ac_compile) 2>&5
2555+
ac_status=$?
2556+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2557+
(exit $ac_status); } &&
2558+
{ ac_try='test -s conftest.$ac_objext'
2559+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2560+
(eval $ac_try) 2>&5
2561+
ac_status=$?
2562+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2563+
(exit $ac_status); }; }; then
2564+
echo "$as_me:$LINENO: result: yes" >&5
2565+
echo "${ECHO_T}yes" >&6
2566+
else
2567+
echo "$as_me: failed program was:" >&5
2568+
cat conftest.$ac_ext >&5
2569+
CFLAGS="$pgac_save_CFLAGS"
2570+
echo "$as_me:$LINENO: result: no" >&5
2571+
echo "${ECHO_T}no" >&6
2572+
fi
2573+
rm -f conftest.$ac_objext conftest.$ac_ext
2574+
2575+
2576+
# Disable strict-aliasing rules; needed for gcc 3.3+
2577+
echo "$as_me:$LINENO: checking if $CC supports -fno-strict-aliasing" >&5
2578+
echo $ECHO_N "checking if $CC supports -fno-strict-aliasing... $ECHO_C" >&6
2579+
pgac_save_CFLAGS=$CFLAGS
2580+
CFLAGS="$pgac_save_CFLAGS -fno-strict-aliasing"
2581+
cat >conftest.$ac_ext <<_ACEOF
2582+
#line $LINENO "configure"
2583+
#include "confdefs.h"
2584+
2585+
#ifdef F77_DUMMY_MAIN
2586+
# ifdef __cplusplus
2587+
extern "C"
2588+
# endif
2589+
int F77_DUMMY_MAIN() { return 1; }
2590+
#endif
2591+
int
2592+
main ()
2593+
{
2594+
2595+
;
2596+
return 0;
2597+
}
2598+
_ACEOF
2599+
rm -f conftest.$ac_objext
2600+
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
2601+
(eval $ac_compile) 2>&5
2602+
ac_status=$?
2603+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2604+
(exit $ac_status); } &&
2605+
{ ac_try='test -s conftest.$ac_objext'
2606+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
2607+
(eval $ac_try) 2>&5
2608+
ac_status=$?
2609+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
2610+
(exit $ac_status); }; }; then
2611+
echo "$as_me:$LINENO: result: yes" >&5
2612+
echo "${ECHO_T}yes" >&6
2613+
else
2614+
echo "$as_me: failed program was:" >&5
2615+
cat conftest.$ac_ext >&5
2616+
CFLAGS="$pgac_save_CFLAGS"
2617+
echo "$as_me:$LINENO: result: no" >&5
2618+
echo "${ECHO_T}no" >&6
24922619
fi
2493-
echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_no_strict_aliasing" >&5
2494-
echo "${ECHO_T}$pgac_cv_prog_cc_no_strict_aliasing" >&6
2620+
rm -f conftest.$ac_objext conftest.$ac_ext
24952621

2496-
if test x"$pgac_cv_prog_cc_no_strict_aliasing" != x""; then
2497-
CFLAGS="$CFLAGS $pgac_cv_prog_cc_no_strict_aliasing"
24982622
fi
24992623

25002624
# supply -g if --enable-debug

‎configure.in

Lines changed: 13 additions & 3 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 $PostgreSQL: pgsql/configure.in,v 1.381 2004/10/15 05:10:59 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.382 2004/10/20 02:12:06 neilc Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -250,8 +250,18 @@ else
250250
fi
251251
fi
252252

253-
# Need to specify -fno-strict-aliasing too in case it's gcc 3.3 or later.
254-
PGAC_PROG_CC_NO_STRICT_ALIASING
253+
if test "$GCC" = yes; then
254+
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
255+
256+
# Some versions of GCC support some additional useful warning flags.
257+
# Check whether they are supported, and add them to CFLAGS if so.
258+
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
259+
PGAC_PROG_CC_CFLAGS_OPT([-Wold-style-definition])
260+
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
261+
262+
# Disable strict-aliasing rules; needed for gcc 3.3+
263+
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
264+
fi
255265

256266
# supply -g if --enable-debug
257267
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then

‎src/Makefile.global.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.203 2004/10/15 17:10:58 momjian Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.204 2004/10/20 02:12:07 neilc Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -184,9 +184,6 @@ endif # not PGXS
184184
CC = @CC@
185185
GCC = @GCC@
186186
CFLAGS = @CFLAGS@
187-
ifeq ($(GCC), yes)
188-
CFLAGS += -Wall -Wmissing-prototypes -Wmissing-declarations
189-
endif
190187

191188
# Kind-of compilers
192189

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp