Use appropriate -Wno-warning switches when compiling bitcode.
We use "clang" to compile bitcode files for LLVM inlining. That might be different from the build's main C compiler, so it needs its own set of compiler flags. To simplify configure, we don't bother adding any -W switches to that flag set; there's little need since the main build will show us any warnings. However, if we don't want to see unwanted warnings, we still have to add any -Wno-warning switches we'd normally use with clang. This escaped notice before commit 9ff47ea41, which tried to add -Wno-compound-token-split-by-macro; buildfarm animals using mismatched CC and CLANG still showed those warnings. I'm not sure why we never saw any effects from the lack of -Wno-unused-command-line-argument (maybe that's only activated by -Wall?). clang does not currently support -Wno-format-truncation or -Wno-stringop-truncation, although in the interests of future-proofing and consistency I included tests for those. Back-patch to v11 where we started building bitcode files. Discussion: https://postgr.es/m/2921539.1637254619@sss.pgh.pa.us
This commit is contained in:
parent
a414eb850d
commit
dff01e4049
194
configure
vendored
194
configure
vendored
@ -5068,7 +5068,7 @@ else
|
||||
fi
|
||||
|
||||
# When generating bitcode (for inlining) we always want to use -O2
|
||||
# even when --enable-debug is specified. The bitcode it's not going to
|
||||
# even when --enable-debug is specified. The bitcode is not going to
|
||||
# be used for line-by-line debugging, and JIT inlining doesn't work
|
||||
# without at least -O1 (otherwise clang will emit 'noinline'
|
||||
# attributes everywhere), which is bad for testing. Still allow the
|
||||
@ -5778,9 +5778,14 @@ if test x"$pgac_cv_prog_CC_cflags__ftree_vectorize" = x"yes"; then
|
||||
fi
|
||||
|
||||
|
||||
# We want to suppress clang's unhelpful unused-command-line-argument warnings
|
||||
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
|
||||
# test for the positive form and if that works, add the negative form
|
||||
#
|
||||
# The following tests want to suppress various unhelpful warnings by adding
|
||||
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
|
||||
# switches, so we have to test for the positive form and if that works,
|
||||
# add the negative form. Note that tests of this form typically need to
|
||||
# be duplicated in the BITCODE_CFLAGS setup stanza below.
|
||||
#
|
||||
# Suppress clang's unhelpful unused-command-line-argument warnings.
|
||||
NOT_THE_CFLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
|
||||
$as_echo_n "checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
|
||||
@ -5825,8 +5830,7 @@ fi
|
||||
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
|
||||
fi
|
||||
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
|
||||
# of warnings when building plperl because of Perl. Like previously, test
|
||||
# for the positive form and add the negative form
|
||||
# of warnings when building plperl because of usages in the Perl headers.
|
||||
NOT_THE_CFLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
|
||||
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
|
||||
@ -6425,9 +6429,12 @@ fi
|
||||
|
||||
|
||||
|
||||
# Determine flags used to emit bitcode for JIT inlining. Need to test
|
||||
# for behaviour changing compiler flags, to keep compatibility with
|
||||
# compiler used for normal postgres code.
|
||||
# Determine flags used to emit bitcode for JIT inlining.
|
||||
# 1. We must duplicate any behaviour-changing compiler flags used above,
|
||||
# to keep compatibility with the compiler used for normal Postgres code.
|
||||
# 2. We don't bother to duplicate extra-warnings switches --- seeing a
|
||||
# warning in the main build is enough.
|
||||
# 3. But we must duplicate -Wno-warning flags, else we'll see those anyway.
|
||||
if test "$with_llvm" = yes ; then
|
||||
CLANGXX="$CLANG -xc++"
|
||||
|
||||
@ -6695,6 +6702,175 @@ if test x"$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" = x"yes";
|
||||
BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -fexcess-precision=standard"
|
||||
fi
|
||||
|
||||
|
||||
NOT_THE_CFLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
|
||||
$as_echo_n "checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
|
||||
if ${pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
pgac_save_CFLAGS=$CFLAGS
|
||||
pgac_save_CC=$CC
|
||||
CC=${CLANG}
|
||||
CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
|
||||
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||
ac_c_werror_flag=yes
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument=yes
|
||||
else
|
||||
pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||
CFLAGS="$pgac_save_CFLAGS"
|
||||
CC="$pgac_save_CC"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" >&5
|
||||
$as_echo "$pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" >&6; }
|
||||
if test x"$pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" = x"yes"; then
|
||||
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
|
||||
fi
|
||||
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-unused-command-line-argument"
|
||||
fi
|
||||
NOT_THE_CFLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
|
||||
$as_echo_n "checking whether ${CLANG} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
|
||||
if ${pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
pgac_save_CFLAGS=$CFLAGS
|
||||
pgac_save_CC=$CC
|
||||
CC=${CLANG}
|
||||
CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
|
||||
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||
ac_c_werror_flag=yes
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro=yes
|
||||
else
|
||||
pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||
CFLAGS="$pgac_save_CFLAGS"
|
||||
CC="$pgac_save_CC"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" >&5
|
||||
$as_echo "$pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" >&6; }
|
||||
if test x"$pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" = x"yes"; then
|
||||
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
|
||||
fi
|
||||
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-compound-token-split-by-macro"
|
||||
fi
|
||||
NOT_THE_CFLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wformat-truncation, for NOT_THE_CFLAGS" >&5
|
||||
$as_echo_n "checking whether ${CLANG} supports -Wformat-truncation, for NOT_THE_CFLAGS... " >&6; }
|
||||
if ${pgac_cv_prog_CLANG_cflags__Wformat_truncation+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
pgac_save_CFLAGS=$CFLAGS
|
||||
pgac_save_CC=$CC
|
||||
CC=${CLANG}
|
||||
CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
|
||||
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||
ac_c_werror_flag=yes
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
pgac_cv_prog_CLANG_cflags__Wformat_truncation=yes
|
||||
else
|
||||
pgac_cv_prog_CLANG_cflags__Wformat_truncation=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||
CFLAGS="$pgac_save_CFLAGS"
|
||||
CC="$pgac_save_CC"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wformat_truncation" >&5
|
||||
$as_echo "$pgac_cv_prog_CLANG_cflags__Wformat_truncation" >&6; }
|
||||
if test x"$pgac_cv_prog_CLANG_cflags__Wformat_truncation" = x"yes"; then
|
||||
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
|
||||
fi
|
||||
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-format-truncation"
|
||||
fi
|
||||
NOT_THE_CFLAGS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wstringop-truncation, for NOT_THE_CFLAGS" >&5
|
||||
$as_echo_n "checking whether ${CLANG} supports -Wstringop-truncation, for NOT_THE_CFLAGS... " >&6; }
|
||||
if ${pgac_cv_prog_CLANG_cflags__Wstringop_truncation+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
pgac_save_CFLAGS=$CFLAGS
|
||||
pgac_save_CC=$CC
|
||||
CC=${CLANG}
|
||||
CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
|
||||
ac_save_c_werror_flag=$ac_c_werror_flag
|
||||
ac_c_werror_flag=yes
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
pgac_cv_prog_CLANG_cflags__Wstringop_truncation=yes
|
||||
else
|
||||
pgac_cv_prog_CLANG_cflags__Wstringop_truncation=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
ac_c_werror_flag=$ac_save_c_werror_flag
|
||||
CFLAGS="$pgac_save_CFLAGS"
|
||||
CC="$pgac_save_CC"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wstringop_truncation" >&5
|
||||
$as_echo "$pgac_cv_prog_CLANG_cflags__Wstringop_truncation" >&6; }
|
||||
if test x"$pgac_cv_prog_CLANG_cflags__Wstringop_truncation" = x"yes"; then
|
||||
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
|
||||
fi
|
||||
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-stringop-truncation"
|
||||
fi
|
||||
fi
|
||||
|
||||
# supply -g if --enable-debug
|
||||
|
46
configure.in
46
configure.in
@ -435,7 +435,7 @@ else
|
||||
fi
|
||||
|
||||
# When generating bitcode (for inlining) we always want to use -O2
|
||||
# even when --enable-debug is specified. The bitcode it's not going to
|
||||
# even when --enable-debug is specified. The bitcode is not going to
|
||||
# be used for line-by-line debugging, and JIT inlining doesn't work
|
||||
# without at least -O1 (otherwise clang will emit 'noinline'
|
||||
# attributes everywhere), which is bad for testing. Still allow the
|
||||
@ -496,17 +496,21 @@ if test "$GCC" = yes -a "$ICC" = no; then
|
||||
# Optimization flags for specific files that benefit from vectorization
|
||||
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
|
||||
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
|
||||
# We want to suppress clang's unhelpful unused-command-line-argument warnings
|
||||
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
|
||||
# test for the positive form and if that works, add the negative form
|
||||
#
|
||||
# The following tests want to suppress various unhelpful warnings by adding
|
||||
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
|
||||
# switches, so we have to test for the positive form and if that works,
|
||||
# add the negative form. Note that tests of this form typically need to
|
||||
# be duplicated in the BITCODE_CFLAGS setup stanza below.
|
||||
#
|
||||
# Suppress clang's unhelpful unused-command-line-argument warnings.
|
||||
NOT_THE_CFLAGS=""
|
||||
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
|
||||
fi
|
||||
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
|
||||
# of warnings when building plperl because of Perl. Like previously, test
|
||||
# for the positive form and add the negative form
|
||||
# of warnings when building plperl because of usages in the Perl headers.
|
||||
NOT_THE_CFLAGS=""
|
||||
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
@ -546,9 +550,12 @@ fi
|
||||
|
||||
AC_SUBST(CFLAGS_VECTOR)
|
||||
|
||||
# Determine flags used to emit bitcode for JIT inlining. Need to test
|
||||
# for behaviour changing compiler flags, to keep compatibility with
|
||||
# compiler used for normal postgres code.
|
||||
# Determine flags used to emit bitcode for JIT inlining.
|
||||
# 1. We must duplicate any behaviour-changing compiler flags used above,
|
||||
# to keep compatibility with the compiler used for normal Postgres code.
|
||||
# 2. We don't bother to duplicate extra-warnings switches --- seeing a
|
||||
# warning in the main build is enough.
|
||||
# 3. But we must duplicate -Wno-warning flags, else we'll see those anyway.
|
||||
if test "$with_llvm" = yes ; then
|
||||
CLANGXX="$CLANG -xc++"
|
||||
|
||||
@ -558,6 +565,27 @@ if test "$with_llvm" = yes ; then
|
||||
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fwrapv])
|
||||
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
|
||||
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])
|
||||
|
||||
NOT_THE_CFLAGS=""
|
||||
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wunused-command-line-argument])
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-unused-command-line-argument"
|
||||
fi
|
||||
NOT_THE_CFLAGS=""
|
||||
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-compound-token-split-by-macro"
|
||||
fi
|
||||
NOT_THE_CFLAGS=""
|
||||
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wformat-truncation])
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-format-truncation"
|
||||
fi
|
||||
NOT_THE_CFLAGS=""
|
||||
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wstringop-truncation])
|
||||
if test -n "$NOT_THE_CFLAGS"; then
|
||||
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-stringop-truncation"
|
||||
fi
|
||||
fi
|
||||
|
||||
# supply -g if --enable-debug
|
||||
|
Loading…
x
Reference in New Issue
Block a user