mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
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:
46
configure.ac
46
configure.ac
@ -440,7 +440,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
|
||||
@ -522,17 +522,21 @@ if test "$GCC" = yes -a "$ICC" = no; then
|
||||
PGAC_PROG_CC_VAR_OPT(CFLAGS_UNROLL_LOOPS, [-funroll-loops])
|
||||
# Optimization flags for specific files that benefit from vectorization
|
||||
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTORIZE, [-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
|
||||
@ -573,9 +577,12 @@ fi
|
||||
AC_SUBST(CFLAGS_UNROLL_LOOPS)
|
||||
AC_SUBST(CFLAGS_VECTORIZE)
|
||||
|
||||
# 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++"
|
||||
|
||||
@ -585,6 +592,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
|
||||
|
Reference in New Issue
Block a user