Skip to content

Commit d13f41d

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 1b7f516 commit d13f41d

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
@@ -3172,6 +3172,57 @@ echo "${ECHO_T}no" >&6
31723172
fi
31733173
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
31743174

3175+
# Disable loop optimizations that get confused by variable-length struct
3176+
# declarations in gcc 4.8+
3177+
{ echo "$as_me:$LINENO: checking if $CC supports -fno-aggressive-loop-optimizations" >&5
3178+
echo $ECHO_N "checking if $CC supports -fno-aggressive-loop-optimizations... $ECHO_C" >&6; }
3179+
pgac_save_CFLAGS=$CFLAGS
3180+
CFLAGS="$pgac_save_CFLAGS -fno-aggressive-loop-optimizations"
3181+
cat >conftest.$ac_ext <<_ACEOF
3182+
/* confdefs.h. */
3183+
_ACEOF
3184+
cat confdefs.h >>conftest.$ac_ext
3185+
cat >>conftest.$ac_ext <<_ACEOF
3186+
/* end confdefs.h. */
3187+
3188+
int
3189+
main ()
3190+
{
3191+
3192+
;
3193+
return 0;
3194+
}
3195+
_ACEOF
3196+
rm -f conftest.$ac_objext
3197+
if { (ac_try="$ac_compile"
3198+
case "(($ac_try" in
3199+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3200+
*) ac_try_echo=$ac_try;;
3201+
esac
3202+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3203+
(eval "$ac_compile") 2>conftest.er1
3204+
ac_status=$?
3205+
grep -v '^ *+' conftest.er1 >conftest.err
3206+
rm -f conftest.er1
3207+
cat conftest.err >&5
3208+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3209+
(exit $ac_status); } && {
3210+
test -z "$ac_c_werror_flag" ||
3211+
test ! -s conftest.err
3212+
} && test -s conftest.$ac_objext; then
3213+
{ echo "$as_me:$LINENO: result: yes" >&5
3214+
echo "${ECHO_T}yes" >&6; }
3215+
else
3216+
echo "$as_me: failed program was:" >&5
3217+
sed 's/^/| /' conftest.$ac_ext >&5
3218+
3219+
CFLAGS="$pgac_save_CFLAGS"
3220+
{ echo "$as_me:$LINENO: result: no" >&5
3221+
echo "${ECHO_T}no" >&6; }
3222+
fi
3223+
3224+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3225+
31753226
elif test "$ICC" = yes; then
31763227
# Intel's compiler has a bug/misoptimization in checking for
31773228
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

configure.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ if test "$GCC" = yes -a "$ICC" = no; then
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 "$ICC" = yes; then
298301
# Intel's compiler has a bug/misoptimization in checking for
299302
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy