Skip to content

Commit 109279e

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. Upstream perl has fixed this issue, but it is going to take some time before this is spread across the buildfarm, and we have noticed that some animals would be useful with an extra -Werror to help with the detection of incorrect placeholders (see b0cf544), dangomushi being one. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/YYr3qYa/R3Gw+Sbg@paquier.xyz Backpatch-through: 10
1 parent 886801d commit 109279e

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

configure

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6034,6 +6034,52 @@ fi
60346034
if test -n "$NOT_THE_CFLAGS"; then
60356035
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
60366036
fi
6037+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
6038+
# of warnings when building plperl because of Perl. Like previously, test
6039+
# for the positive form and add the negative form
6040+
NOT_THE_CFLAGS=""
6041+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
6042+
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
6043+
if ${pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro+:} false; then :
6044+
$as_echo_n "(cached) " >&6
6045+
else
6046+
pgac_save_CFLAGS=$CFLAGS
6047+
pgac_save_CC=$CC
6048+
CC=${CC}
6049+
CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
6050+
ac_save_c_werror_flag=$ac_c_werror_flag
6051+
ac_c_werror_flag=yes
6052+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6053+
/* end confdefs.h. */
6054+
6055+
int
6056+
main ()
6057+
{
6058+
6059+
;
6060+
return 0;
6061+
}
6062+
_ACEOF
6063+
if ac_fn_c_try_compile "$LINENO"; then :
6064+
pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro=yes
6065+
else
6066+
pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro=no
6067+
fi
6068+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6069+
ac_c_werror_flag=$ac_save_c_werror_flag
6070+
CFLAGS="$pgac_save_CFLAGS"
6071+
CC="$pgac_save_CC"
6072+
fi
6073+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" >&5
6074+
$as_echo "$pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" >&6; }
6075+
if test x"$pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" = x"yes"; then
6076+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
6077+
fi
6078+
6079+
6080+
if test -n "$NOT_THE_CFLAGS"; then
6081+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
6082+
fi
60376083
# Similarly disable useless truncation warnings from gcc 8+
60386084
NOT_THE_CFLAGS=""
60396085
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wformat-truncation, for NOT_THE_CFLAGS" >&5

configure.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,14 @@ if test "$GCC" = yes -a "$ICC" = no; then
515515
if test -n "$NOT_THE_CFLAGS"; then
516516
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
517517
fi
518+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
519+
# of warnings when building plperl because of Perl. Like previously, test
520+
# for the positive form and add the negative form
521+
NOT_THE_CFLAGS=""
522+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
523+
if test -n "$NOT_THE_CFLAGS"; then
524+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
525+
fi
518526
# Similarly disable useless truncation warnings from gcc 8+
519527
NOT_THE_CFLAGS=""
520528
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])

0 commit comments

Comments
 (0)