10000 Disable -faggressive-loop-optimizations in gcc 4.8+ for pre-9.2 branc… · sqlparser/postgres@8396d23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8396d23

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
1 parent de27c29 commit 8396d23

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

configure

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,6 +4104,57 @@ sed 's/^/| /' conftest.$ac_ext >&5
41044104
echo "${ECHO_T}no" >&6; }
41054105
fi
41064106

4107+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4108+
4109+
# Disable loop optimizations that get confused by variable-length struct
4110+
# declarations in gcc 4.8+
4111+
{ echo "$as_me:$LINENO: checking if $CC supports -fno-aggressive-loop-optimizations" >&5
4112+
echo $ECHO_N "checking if $CC supports -fno-aggressive-loop-optimizations... $ECHO_C" >&6; }
4113+
pgac_save_CFLAGS=$CFLAGS
4114+
CFLAGS="$pgac_save_CFLAGS -fno-aggressive-loop-optimizations"
4115+
cat >conftest.$ac_ext <<_ACEOF
4116+
/* confdefs.h. */
4117+
_ACEOF
4118+
cat confdefs.h >>conftest.$ac_ext
4119+
cat >>conftest.$ac_ext <<_ACEOF
4120+
/* end confdefs.h. */
4121+
4122+
int
4123+
main ()
4124+
{
4125+
4126+
;
4127+
return 0;
4128+
}
4129+
_ACEOF
4130+
rm -f conftest.$ac_objext
4131+
if { (ac_try="$ac_compile"
4132+
case "(($ac_try" in
4133+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4134+
*) ac_try_echo=$ac_try;;
4135+
esac
4136+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
4137+
(eval "$ac_compile") 2>conftest.er1
4138+
ac_status=$?
4139+
grep -v '^ *+' conftest.er1 >conftest.err
4140+
rm -f conftest.er1
4141+
cat conftest.err >&5
4142+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
4143+
(exit $ac_status); } && {
4144+
test -z "$ac_c_werror_flag" ||
4145+
test ! -s conftest.err
4146+
} && test -s conftest.$ac_objext; then
D538 4147+
{ echo "$as_me:$LINENO: result: yes" >&5
4148+
echo "${ECHO_T}yes" >&6; }
4149+
else
4150+
echo "$as_me: failed program was:" >&5
4151+
sed 's/^/| /' conftest.$ac_ext >&5
4152+
4153+
CFLAGS="$pgac_save_CFLAGS"
4154+
{ echo "$as_me:$LINENO: result: no" >&5
4155+
echo "${ECHO_T}no" >&6; }
4156+
fi
4157+
41074158
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
41084159

41094160
elif test "$ICC" = yes; then

configure.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ if test "$GCC" = yes -a "$ICC" = no; then
435435
PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
436436
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
437437
PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
438+
# Disable loop optimizations that get confused by variable-length struct
439+
# declarations in gcc 4.8+
440+
PGAC_PROG_CC_CFLAGS_OPT([-fno-aggressive-loop-optimizations])
438441
elif test "$ICC" = yes; then
439442
# Intel's compiler has a bug/misoptimization in checking for
440443
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)
0