Skip to content

Commit 5e8a0dc

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 f4ab856 commit 5e8a0dc

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
@@ -5824,6 +5824,52 @@ fi
58245824
if test -n "$NOT_THE_CFLAGS"; then
58255825
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
58265826
fi
5827+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
5828+
# of warnings when building plperl because of Perl. Like previously, test
5829+
# for the positive form and add the negative form
5830+
NOT_THE_CFLAGS=""
5831+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
5832+
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
5833+
if ${pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro+:} false; then :
5834+
$as_echo_n "(cached) " >&6
5835+
else
5836+
pgac_save_CFLAGS=$CFLAGS
5837+
pgac_save_CC=$CC
5838+
CC=${CC}
5839+
CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
5840+
ac_save_c_werror_flag=$ac_c_werror_flag
5841+
ac_c_werror_flag=yes
5842+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5843+
/* end confdefs.h. */
5844+
5845+
int
5846+
main ()
5847+
{
5848+
5849+
;
5850+
return 0;
5851+
}
5852+
_ACEOF
5853+
if ac_fn_c_try_compile "$LINENO"; then :
5854+
pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro=yes
5855+
else
5856+
pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro=no
5857+
fi
5858+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5859+
ac_c_werror_flag=$ac_save_c_werror_flag
5860+
CFLAGS="$pgac_save_CFLAGS"
5861+
CC="$pgac_save_CC"
5862+
fi
5863+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" >&5
5864+
$as_echo "$pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" >&6; }
5865+
if test x"$pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" = x"yes"; then
5866+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
5867+
fi
5868+
5869+
5870+
if test -n "$NOT_THE_CFLAGS"; then
5871+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
5872+
fi
58275873
# Similarly disable useless truncation warnings from gcc 8+
58285874
NOT_THE_CFLAGS=""
58295875
{ $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
@@ -504,6 +504,14 @@ if test "$GCC" = yes -a "$ICC" = no; then
504504
if test -n "$NOT_THE_CFLAGS"; then
505505
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
506506
fi
507+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
508+
# of warnings when building plperl because of Perl. Like previously, test
509+
# for the positive form and add the negative form
510+
NOT_THE_CFLAGS=""
511+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
512+
if test -n "$NOT_THE_CFLAGS"; then
513+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
514+
fi
507515
# Similarly disable useless truncation warnings from gcc 8+
508516
NOT_THE_CFLAGS=""
509517
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])

0 commit comments

Comments
 (0)