Skip to content

Commit ec5547e

Browse files
committed
Use -Wno-format-truncation and -Wno-stringop-truncation, if available.
gcc 8 has started emitting some warnings that are largely useless for our purposes, particularly since they complain about code following the project-standard coding convention that path names are assumed to be shorter than MAXPGPATH. Even if we make the effort to remove that assumption in some future release, the changes wouldn't get back-patched. Hence, just suppress these warnings, on compilers that have these switches. Backpatch to all supported branches. Discussion: https://postgr.es/m/1524563856.26306.9.camel@gunduz.org
1 parent 537d7f3 commit ec5547e

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed

configure

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4508,6 +4508,7 @@ fi
45084508
# We want to suppress clang's unhelpful unused-command-line-argument warnings
45094509
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
45104510
# test for the positive form and if that works, add the negative form
4511+
NOT_THE_CFLAGS=""
45114512
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wunused-command-line-argument" >&5
45124513
$as_echo_n "checking whether $CC supports -Wunused-command-line-argument... " >&6; }
45134514
if test "${pgac_cv_prog_cc_cflags__Wunused_command_line_argument+set}" = set; then
@@ -4571,6 +4572,135 @@ fi
45714572
if test -n "$NOT_THE_CFLAGS"; then
45724573
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
45734574
fi
4575+
# Similarly disable useless truncation warnings from gcc 8+
4576+
NOT_THE_CFLAGS=""
4577+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wformat-truncation" >&5
4578+
$as_echo_n "checking whether $CC supports -Wformat-truncation... " >&6; }
4579+
if test "${pgac_cv_prog_cc_cflags__Wformat_truncation+set}" = set; then
4580+
$as_echo_n "(cached) " >&6
4581+
else
4582+
pgac_save_CFLAGS=$CFLAGS
4583+
CFLAGS="$pgac_save_CFLAGS -Wformat-truncation"
4584+
ac_save_c_werror_flag=$ac_c_werror_flag
4585+
ac_c_werror_flag=yes
4586+
cat >conftest.$ac_ext <<_ACEOF
4587+
/* confdefs.h. */
4588+
_ACEOF
4589+
cat confdefs.h >>conftest.$ac_ext
4590+
cat >>conftest.$ac_ext <<_ACEOF
4591+
/* end confdefs.h. */
4592+
4593+
int
4594+
main ()
4595+
{
4596+
4597+
;
4598+
return 0;
4599+
}
4600+
_ACEOF
4601+
rm -f conftest.$ac_objext
4602+
if { (ac_try="$ac_compile"
4603+
case "(($ac_try" in
4604+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4605+
*) ac_try_echo=$ac_try;;
4606+
esac
4607+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4608+
$as_echo "$ac_try_echo") >&5
4609+
(eval "$ac_compile") 2>conftest.er1
4610+
ac_status=$?
4611+
grep -v '^ *+' conftest.er1 >conftest.err
4612+
rm -f conftest.er1
4613+
cat conftest.err >&5
4614+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4615+
(exit $ac_status); } && {
4616+
test -z "$ac_c_werror_flag" ||
4617+
test ! -s conftest.err
4618+
} && test -s conftest.$ac_objext; then
4619+
pgac_cv_prog_cc_cflags__Wformat_truncation=yes
4620+
else
4621+
$as_echo "$as_me: failed program was:" >&5
4622+
sed 's/^/| /' conftest.$ac_ext >&5
4623+
4624+
pgac_cv_prog_cc_cflags__Wformat_truncation=no
4625+
fi
4626+
4627+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4628+
ac_c_werror_flag=$ac_save_c_werror_flag
4629+
CFLAGS="$pgac_save_CFLAGS"
4630+
fi
4631+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wformat_truncation" >&5
4632+
$as_echo "$pgac_cv_prog_cc_cflags__Wformat_truncation" >&6; }
4633+
if test x"$pgac_cv_prog_cc_cflags__Wformat_truncation" = x"yes"; then
4634+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
4635+
fi
4636+
4637+
if test -n "$NOT_THE_CFLAGS"; then
4638+
CFLAGS="$CFLAGS -Wno-format-truncation"
4639+
fi
4640+
NOT_THE_CFLAGS=""
4641+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wstringop-truncation" >&5
4642+
$as_echo_n "checking whether $CC supports -Wstringop-truncation... " >&6; }
4643+
if test "${pgac_cv_prog_cc_cflags__Wstringop_truncation+set}" = set; then
4644+
$as_echo_n "(cached) " >&6
4645+
else
4646+
pgac_save_CFLAGS=$CFLAGS
4647+
CFLAGS="$pgac_save_CFLAGS -Wstringop-truncation"
4648+
ac_save_c_werror_flag=$ac_c_werror_flag
4649+
ac_c_werror_flag=yes
4650+
cat >conftest.$ac_ext <<_ACEOF
4651+
/* confdefs.h. */
4652+
_ACEOF
4653+
cat confdefs.h >>conftest.$ac_ext
4654+
cat >>conftest.$ac_ext <<_ACEOF
4655+
/* end confdefs.h. */
4656+
4657+
int
4658+
main ()
4659+
{
4660+
4661+
;
4662+
return 0;
4663+
}
4664+
_ACEOF
4665+
rm -f conftest.$ac_objext
4666+
if { (ac_try="$ac_compile"
4667+
case "(($ac_try" in
4668+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4669+
*) ac_try_echo=$ac_try;;
4670+
esac
4671+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4672+
$as_echo "$ac_try_echo") >&5
4673+
(eval "$ac_compile") 2>conftest.er1
4674+
ac_status=$?
4675+
grep -v '^ *+' conftest.er1 >conftest.err
4676+
rm -f conftest.er1
4677+
cat conftest.err >&5
4678+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4679+
(exit $ac_status); } && {
4680+
test -z "$ac_c_werror_flag" ||
4681+
test ! -s conftest.err
4682+
} && test -s conftest.$ac_objext; then
4683+
pgac_cv_prog_cc_cflags__Wstringop_truncation=yes
4684+
else
4685+
$as_echo "$as_me: failed program was:" >&5
4686+
sed 's/^/| /' conftest.$ac_ext >&5
4687+
4688+
pgac_cv_prog_cc_cflags__Wstringop_truncation=no
4689+
fi
4690+
4691+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4692+
ac_c_werror_flag=$ac_save_c_werror_flag
4693+
CFLAGS="$pgac_save_CFLAGS"
4694+
fi
4695+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wstringop_truncation" >&5
4696+
$as_echo "$pgac_cv_prog_cc_cflags__Wstringop_truncation" >&6; }
4697+
if test x"$pgac_cv_prog_cc_cflags__Wstringop_truncation" = x"yes"; then
4698+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
4699+
fi
4700+
4701+
if test -n "$NOT_THE_CFLAGS"; then
4702+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
4703+
fi
45744704
elif test "$ICC" = yes; then
45754705
# Intel's compiler has a bug/misoptimization in checking for
45764706
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

configure.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,22 @@ if test "$GCC" = yes -a "$ICC" = no; then
430430
# We want to suppress clang's unhelpful unused-command-line-argument warnings
431431
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
432432
# test for the positive form and if that works, add the negative form
433+
NOT_THE_CFLAGS=""
433434
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
434435
if test -n "$NOT_THE_CFLAGS"; then
435436
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
436437
fi
438+
# Similarly disable useless truncation warnings from gcc 8+
439+
NOT_THE_CFLAGS=""
440+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])
441+
if test -n "$NOT_THE_CFLAGS"; then
442+
CFLAGS="$CFLAGS -Wno-format-truncation"
443+
fi
444+
NOT_THE_CFLAGS=""
445+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation])
446+
if test -n "$NOT_THE_CFLAGS"; then
447+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
448+
fi
437449
elif test "$ICC" = yes; then
438450
# Intel's compiler has a bug/misoptimization in checking for
439451
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)