Skip to content

Commit aa449e5

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 78f0584 commit aa449e5

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
@@ -6136,6 +6136,52 @@ fi
61366136
if test -n "$NOT_THE_CFLAGS"; then
61376137
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
61386138
fi
6139+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
6140+
# of warnings when building plperl because of Perl. Like previously, test
6141+
# for the positive form and add the negative form
6142+
NOT_THE_CFLAGS=""
6143+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
6144+
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
6145+
if ${pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro+:} false; then :
6146+
$as_echo_n "(cached) " >&6
6147+
else
6148+
pgac_save_CFLAGS=$CFLAGS
6149+
pgac_save_CC=$CC
6150+
CC=${CC}
6151+
CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
6152+
ac_save_c_werror_flag=$ac_c_werror_flag
6153+
ac_c_werror_flag=yes
6154+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6155+
/* end confdefs.h. */
6156+
6157+
int
6158+
main ()
6159+
{
6160+
6161+
;
6162+
return 0;
6163+
}
6164+
_ACEOF
6165+
if ac_fn_c_try_compile "$LINENO"; then :
6166+
pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro=yes
6167+
else
6168+
pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro=no
6169+
fi
6170+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6171+
ac_c_werror_flag=$ac_save_c_werror_flag
6172+
CFLAGS="$pgac_save_CFLAGS"
6173+
CC="$pgac_save_CC"
6174+
fi
6175+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" >&5
6176+
$as_echo "$pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" >&6; }
6177+
if test x"$pgac_cv_prog_CC_cflags__Wcompound_token_split_by_macro" = x"yes"; then
6178+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
6179+
fi
6180+
6181+
6182+
if test -n "$NOT_THE_CFLAGS"; then
6183+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
6184+
fi
61396185
# Similarly disable useless truncation warnings from gcc 8+
61406186
NOT_THE_CFLAGS=""
61416187
{ $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
@@ -521,6 +521,14 @@ if test "$GCC" = yes -a "$ICC" = no; then
521521
if test -n "$NOT_THE_CFLAGS"; then
522522
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
523523
fi
524+
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
525+
# of warnings when building plperl because of Perl. Like previously, test
526+
# for the positive form and add the negative form
527+
NOT_THE_CFLAGS=""
528+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
529+
if test -n "$NOT_THE_CFLAGS"; then
530+
CFLAGS="$CFLAGS -Wno-compound-token-split-by-macro"
531+
fi
524532
# Similarly disable useless truncation warnings from gcc 8+
525533
NOT_THE_CFLAGS=""
526534
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])

0 commit comments

Comments
 (0)