Skip to content

Commit 5802618

Browse files
committed
Clean up compilation warnings coming from PL/Perl with clang-12~
clang-12 has introduced -Wcompound-token-split-by-macro, that is causing a large amount of warnings when building PL/Perl because of its interactions with upstream Perl. This commit adds one -Wno to CFLAGS at ./configure time if the flag is supported by the compiler to silence all those warnings. This back-patches commit 9ff47ea into out-of-support branches, pursuant to newly-established project policy. The point is to suppress scary-looking warnings so that people building these branches needn't expend brain cells verifying that it's safe to ignore the warnings. Discussion: https://postgr.es/m/d0316012-ece7-7b7e-2d36-9c38cb77cb3b@enterprisedb.com
1 parent b30e23f commit 5802618

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

configure

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4574,6 +4574,73 @@ fi
45744574
if test -n "$NOT_THE_CFLAGS"; then
45754575
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
45764576
fi
4577+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
4578+
# of warnings when building plperl because of Perl. Like previously, test
4579+
# for the positive form and add the negative form
4580+
NOT_THE_CFLAGS=""
4581+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wcompound-token-split-by-macro" >&5
4582+
$as_echo_n "checking whether $CC supports -Wcompound-token-split-by-macro... " >&6; }
4583+
if test "${pgac_cv_prog_cc_cflags__Wcompound_token_split_by_macro+set}" = set; then
4584+
$as_echo_n "(cached) " >&6
4585+
else
4586+
pgac_save_CFLAGS=$CFLAGS
4587+
CFLAGS="$pgac_save_CFLAGS -Wcompound-token-split-by-macro"
4588+
ac_save_c_werror_flag=$ac_c_werror_flag
4589+
ac_c_werror_flag=yes
4590+
cat >conftest.$ac_ext <<_ACEOF
4591+
/* confdefs.h. */
4592+
_ACEOF
4593+
cat confdefs.h >>conftest.$ac_ext
4594+
cat >>conftest.$ac_ext <<_ACEOF
4595+
/* end confdefs.h. */
4596+
4597+
int
4598+
main ()
4599+
{
4600+
4601+
;
4602+
return 0;
4603+
}
4604+
_ACEOF
4605+
rm -f conftest.$ac_objext
4606+
if { (ac_try="$ac_compile"
4607+
case "(($ac_try" in
4608+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4609+
*) ac_try_echo=$ac_try;;
4610+
esac
4611+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4612+
$as_echo "$ac_try_echo") >&5
4613+
(eval "$ac_compile") 2>conftest.er1
4614+
ac_status=$?
4615+
grep -v '^ *+' conftest.er1 >conftest.err
4616+
rm -f conftest.er1
4617+
cat conftest.err >&5
4618+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4619+
(exit $ac_status); } && {
4620+
test -z "$ac_c_werror_flag" ||
4621+
test ! -s conftest.err
4622+
} && test -s conftest.$ac_objext; then
4623+
pgac_cv_prog_cc_cflags__Wcompound_token_split_by_macro=yes
4624+
else
4625+
$as_echo "$as_me: failed program was:" >&5
4626+
sed 's/^/| /' conftest.$ac_ext >&5
4627+
4628+
pgac_cv_prog_cc_cflags__Wcompound_token_split_by_macro=no
4629+
fi
4630+
4631+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4632+
ac_c_werror_flag=$ac_save_c_werror_flag
4633+
CFLAGS="$pgac_save_CFLAGS"
4634+
fi
4635+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wcompound_token_split_by_macro" >&5
4636+
$as_echo "$pgac_cv_prog_cc_cflags__Wcompound_token_split_by_macro" >&6; }
4637+
if test x"$pgac_cv_prog_cc_cflags__Wcompound_token_split_by_macro" = x"yes"; then
4638+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
4639+
fi
4640+
4641+
if test -n "$NOT_THE_CFLAGS"; then
4642+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
4643+
fi
45774644
# Similarly disable useless truncation warnings from gcc 8+
45784645
NOT_THE_CFLAGS=""
45794646
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wformat-truncation" >&5

configure.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ if test "$GCC" = yes -a "$ICC" = no; then
435435
if test -n "$NOT_THE_CFLAGS"; then
436436
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
437437
fi
438+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
439+
# of warnings when building plperl because of Perl. Like previously, test
440+
# for the positive form and add the negative form
441+
NOT_THE_CFLAGS=""
442+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
443+
if test -n "$NOT_THE_CFLAGS"; then
444+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
445+
fi
438446
# Similarly disable useless truncation warnings from gcc 8+
439447
NOT_THE_CFLAGS=""
440448
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])

0 commit comments

Comments
 (0)