8000 Disable -faggressive-loop-optimizations in gcc 4.8+ for pre-9.2 branc… · percona/postgres@105f3ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 105f3ef

Browse files
committed
Disable -faggressive-loop-optimizations in gcc 4.8+ for pre-9.2 branches.
With this optimization flag enabled, recent versions of gcc can generate incorrect code that assumes variable-length arrays (such as oidvector) are actually fixed-length because they're embedded in some larger struct. The known instance of this problem was fixed in 9.2 and up by commit 8137f2c and followon work, which hides actually-variable-length catalog fields from the compiler altogether. And we plan to gradually convert variable-length fields to official "flexible array member" notation over time, which should prevent this type of bug from reappearing as gcc gets smarter. We're not going to try to back-port those changes into older branches, though, so apply this band-aid instead. Andres Freund This is a backpatch of commit 649839d to unsupported branches REL8_2_STABLE and REL8_3_STABLE, so that they work with newer toolsets.
1 parent 91a1e14 commit 105f3ef

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

configure

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,6 +3188,61 @@ else
31883188
echo "$as_me: failed program was:" >&5
31893189
sed 's/^/| /' conftest.$ac_ext >&5
31903190

3191+
CFLAGS="$pgac_save_CFLAGS"
3192+
echo "$as_me:$LINENO: result: no" >&5
3193+
echo "${ECHO_T}no" >&6
3194+
fi
3195+
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
3196+
3197+
# Disable loop optimizations that get confused by variable-length struct
3198+
# declarations in gcc 4.8+
3199+
echo "$as_me:$LINENO: checking if $CC supports -fno-aggressive-loop-optimizations" >&5
3200+
echo $ECHO_N "checking if $CC supports -fno-aggressive-loop-optimizations... $ECHO_C" >&6
3201+
pgac_save_CFLAGS=$CFLAGS
3202+
CFLAGS="$pgac_save_CFLAGS -fno-aggressive-loop-optimizations"
3203+
cat >conftest.$ac_ext <<_ACEOF
3204+
/* confdefs.h. */
3205+
_ACEOF
3206+
cat confdefs.h >>conftest.$ac_ext
3207+
cat >>conftest.$ac_ext <<_ACEOF
3208+
/* end confdefs.h. */
3209+
3210+
int
3211+
main ()
3212+
{
3213+
3214+
;
3215+
return 0;
3216+
}
3217+
_ACEOF
3218+
rm -f conftest.$ac_objext
3219+
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
3220+
(eval $ac_compile) 2>conftest.er1
3221+
ac_status=$?
3222+
grep -v '^ *+' conftest.er1 >conftest.err
3223+
rm -f conftest.er1
3224+
cat conftest.err >&5
3225+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3226+
(exit $ac_status); } &&
3227+
{ ac_try='test -z "$ac_c_werror_flag"
3228+
|| test ! -s conftest.err'
3229+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3230+
(eval $ac_try) 2>&5
3231+
ac_status=$?
3232+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3233+
(exit $ac_status); }; } &&
3234+
{ ac_try='test -s conftest.$ac_objext'
3235+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3236+
(eval $ac_try) 2>&5
3237+
ac_status=$?
3238+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3239+
(exit $ac_status); }; }; then
3240+
echo "$as_me:$LINENO: result: yes" >&5
3241+
echo "${ECHO_T}yes" >&6
3242+
else
3243+
echo "$as_me: failed program was:" >&5
3244+
sed 's/^/| /' conftest.$ac_ext >&5
3245+
31913246
CFLAGS="$pgac_save_CFLAGS"
31923247
echo "$as_me:$LINENO: result: no" >&5
31933248
echo "${ECHO_T}no" >&6

configure.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ choke me
294294
PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
295295
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
296296
PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
297+
# Disable loop optimizations that get confused by variable-length struct
298+
# declarations in gcc 4.8+
299+
PGAC_PROG_CC_CFLAGS_OPT([-fno-aggressive-loop-optimizations])
297300
elif test x"${CC}" = x"xlc"; then
298301
# AIX xlc has to have strict aliasing turned off too
299302
PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias])

0 commit comments

Comments
 (0)
0