summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-11-18 14:50:13 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-11-18 14:50:13 -0500
commited1c261a00e51f7f216911df2278827ba8cc211f (patch)
tree0bea38b6ab53d3c569fb55da2a0452c58f213b24 /configure
parent048f3ee618552790125a5412b5c8a4b48a36a480 (diff)
downloadpostgresql-ed1c261a00e51f7f216911df2278827ba8cc211f.tar.gz
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
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure194
1 files changed, 185 insertions, 9 deletions
diff --git a/configure b/configure
index f7ef743945..c493735a8b 100755
--- a/configure
+++ b/configure
@@ -5251,7 +5251,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
@@ -6288,9 +6288,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; }
@@ -6335,8 +6340,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; }
@@ -6936,9 +6940,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++"
@@ -7206,6 +7213,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