Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77c8892

Browse files
committed
Use appropriate -Wno-warning switches when compiling bitcode.
We use "clang" to compile bitcode files for LLVM inlining. That mightbe different from the build's main C compiler, so it needs its own setof compiler flags. To simplify configure, we don't bother adding any-W switches to that flag set; there's little need since the main buildwill show us any warnings. However, if we don't want to see unwantedwarnings, we still have to add any -Wno-warning switches we'd normallyuse with clang.This escaped notice before commit9ff47ea, which tried to add-Wno-compound-token-split-by-macro; buildfarm animals using mismatchedCC and CLANG still showed those warnings. I'm not sure why we neversaw any effects from the lack of -Wno-unused-command-line-argument(maybe that's only activated by -Wall?). clang does not currentlysupport -Wno-format-truncation or -Wno-stringop-truncation, althoughin the interests of future-proofing and consistency I included testsfor those.Back-patch to v11 where we started building bitcode files.Discussion:https://postgr.es/m/2921539.1637254619@sss.pgh.pa.us
1 parent49f2b11 commit77c8892

File tree

2 files changed

+222
-18
lines changed

2 files changed

+222
-18
lines changed

‎configure

Lines changed: 185 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5240,7 +5240,7 @@ else
52405240
fi
52415241

52425242
# When generating bitcode (for inlining) we always want to use -O2
5243-
# even when --enable-debug is specified. The bitcodeit's not going to
5243+
# even when --enable-debug is specified. The bitcodeis not going to
52445244
# be used for line-by-line debugging, and JIT inlining doesn't work
52455245
# without at least -O1 (otherwise clang will emit 'noinline'
52465246
# attributes everywhere), which is bad for testing. Still allow the
@@ -6090,9 +6090,14 @@ if test x"$pgac_cv_prog_CC_cflags__ftree_vectorize" = x"yes"; then
60906090
fi
60916091

60926092

6093-
# We want to suppress clang's unhelpful unused-command-line-argument warnings
6094-
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
6095-
# test for the positive form and if that works, add the negative form
6093+
#
6094+
# The following tests want to suppress various unhelpful warnings by adding
6095+
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
6096+
# switches, so we have to test for the positive form and if that works,
6097+
# add the negative form. Note that tests of this form typically need to
6098+
# be duplicated in the BITCODE_CFLAGS setup stanza below.
6099+
#
6100+
# Suppress clang's unhelpful unused-command-line-argument warnings.
60966101
NOT_THE_CFLAGS=""
60976102
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
60986103
$as_echo_n "checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
@@ -6137,8 +6142,7 @@ fi
61376142
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
61386143
fi
61396144
# 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
6145+
# of warnings when building plperl because of usages in the Perl headers.
61426146
NOT_THE_CFLAGS=""
61436147
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
61446148
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
@@ -6737,9 +6741,12 @@ fi
67376741

67386742

67396743

6740-
# Determine flags used to emit bitcode for JIT inlining. Need to test
6741-
# for behaviour changing compiler flags, to keep compatibility with
6742-
# compiler used for normal postgres code.
6744+
# Determine flags used to emit bitcode for JIT inlining.
6745+
# 1. We must duplicate any behaviour-changing compiler flags used above,
6746+
# to keep compatibility with the compiler used for normal Postgres code.
6747+
# 2. We don't bother to duplicate extra-warnings switches --- seeing a
6748+
# warning in the main build is enough.
6749+
# 3. But we must duplicate -Wno-warning flags, else we'll see those anyway.
67436750
if test "$with_llvm" = yes ; then
67446751
CLANGXX="$CLANG -xc++"
67456752

@@ -7007,6 +7014,175 @@ if test x"$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" = x"yes";
70077014
BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -fexcess-precision=standard"
70087015
fi
70097016

7017+
7018+
NOT_THE_CFLAGS=""
7019+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
7020+
$as_echo_n "checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
7021+
if ${pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument+:} false; then :
7022+
$as_echo_n "(cached) " >&6
7023+
else
7024+
pgac_save_CFLAGS=$CFLAGS
7025+
pgac_save_CC=$CC
7026+
CC=${CLANG}
7027+
CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
7028+
ac_save_c_werror_flag=$ac_c_werror_flag
7029+
ac_c_werror_flag=yes
7030+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7031+
/* end confdefs.h. */
7032+
7033+
int
7034+
main ()
7035+
{
7036+
7037+
;
7038+
return 0;
7039+
}
7040+
_ACEOF
7041+
if ac_fn_c_try_compile "$LINENO"; then :
7042+
pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument=yes
7043+
else
7044+
pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument=no
7045+
fi
7046+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7047+
ac_c_werror_flag=$ac_save_c_werror_flag
7048+
CFLAGS="$pgac_save_CFLAGS"
7049+
CC="$pgac_save_CC"
7050+
fi
7051+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" >&5
7052+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" >&6; }
7053+
if test x"$pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" = x"yes"; then
7054+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
7055+
fi
7056+
7057+
if test -n "$NOT_THE_CFLAGS"; then
7058+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-unused-command-line-argument"
7059+
fi
7060+
NOT_THE_CFLAGS=""
7061+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
7062+
$as_echo_n "checking whether ${CLANG} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
7063+
if ${pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro+:} false; then :
7064+
$as_echo_n "(cached) " >&6
7065+
else
7066+
pgac_save_CFLAGS=$CFLAGS
7067+
pgac_save_CC=$CC
7068+
CC=${CLANG}
7069+
CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
7070+
ac_save_c_werror_flag=$ac_c_werror_flag
7071+
ac_c_werror_flag=yes
7072+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7073+
/* end confdefs.h. */
7074+
7075+
int
7076+
main ()
7077+
{
7078+
7079+
;
7080+
return 0;
7081+
}
7082+
_ACEOF
7083+
if ac_fn_c_try_compile "$LINENO"; then :
7084+
pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro=yes
7085+
else
7086+
pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro=no
7087+
fi
7088+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7089+
ac_c_werror_flag=$ac_save_c_werror_flag
7090+
CFLAGS="$pgac_save_CFLAGS"
7091+
CC="$pgac_save_CC"
7092+
fi
7093+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" >&5
7094+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" >&6; }
7095+
if test x"$pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" = x"yes"; then
7096+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
7097+
fi
7098+
7099+
if test -n "$NOT_THE_CFLAGS"; then
7100+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-compound-token-split-by-macro"
7101+
fi
7102+
NOT_THE_CFLAGS=""
7103+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wformat-truncation, for NOT_THE_CFLAGS" >&5
7104+
$as_echo_n "checking whether ${CLANG} supports -Wformat-truncation, for NOT_THE_CFLAGS... " >&6; }
7105+
if ${pgac_cv_prog_CLANG_cflags__Wformat_truncation+:} false; then :
7106+
$as_echo_n "(cached) " >&6
7107+
else
7108+
pgac_save_CFLAGS=$CFLAGS
7109+
pgac_save_CC=$CC
7110+
CC=${CLANG}
7111+
CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
7112+
ac_save_c_werror_flag=$ac_c_werror_flag
7113+
ac_c_werror_flag=yes
7114+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7115+
/* end confdefs.h. */
7116+
7117+
int
7118+
main ()
7119+
{
7120+
7121+
;
7122+
return 0;
7123+
}
7124+
_ACEOF
7125+
if ac_fn_c_try_compile "$LINENO"; then :
7126+
pgac_cv_prog_CLANG_cflags__Wformat_truncation=yes
7127+
else
7128+
pgac_cv_prog_CLANG_cflags__Wformat_truncation=no
7129+
fi
7130+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7131+
ac_c_werror_flag=$ac_save_c_werror_flag
7132+
CFLAGS="$pgac_save_CFLAGS"
7133+
CC="$pgac_save_CC"
7134+
fi
7135+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wformat_truncation" >&5
7136+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wformat_truncation" >&6; }
7137+
if test x"$pgac_cv_prog_CLANG_cflags__Wformat_truncation" = x"yes"; then
7138+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
7139+
fi
7140+
7141+
if test -n "$NOT_THE_CFLAGS"; then
7142+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-format-truncation"
7143+
fi
7144+
NOT_THE_CFLAGS=""
7145+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wstringop-truncation, for NOT_THE_CFLAGS" >&5
7146+
$as_echo_n "checking whether ${CLANG} supports -Wstringop-truncation, for NOT_THE_CFLAGS... " >&6; }
7147+
if ${pgac_cv_prog_CLANG_cflags__Wstringop_truncation+:} false; then :
7148+
$as_echo_n "(cached) " >&6
7149+
else
7150+
pgac_save_CFLAGS=$CFLAGS
7151+
pgac_save_CC=$CC
7152+
CC=${CLANG}
7153+
CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
7154+
ac_save_c_werror_flag=$ac_c_werror_flag
7155+
ac_c_werror_flag=yes
7156+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7157+
/* end confdefs.h. */
7158+
7159+
int
7160+
main ()
7161+
{
7162+
7163+
;
7164+
return 0;
7165+
}
7166+
_ACEOF
7167+
if ac_fn_c_try_compile "$LINENO"; then :
7168+
pgac_cv_prog_CLANG_cflags__Wstringop_truncation=yes
7169+
else
7170+
pgac_cv_prog_CLANG_cflags__Wstringop_truncation=no
7171+
fi
7172+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7173+
ac_c_werror_flag=$ac_save_c_werror_flag
7174+
CFLAGS="$pgac_save_CFLAGS"
7175+
CC="$pgac_save_CC"
7176+
fi
7177+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wstringop_truncation" >&5
7178+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wstringop_truncation" >&6; }
7179+
if test x"$pgac_cv_prog_CLANG_cflags__Wstringop_truncation" = x"yes"; then
7180+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
7181+
fi
7182+
7183+
if test -n "$NOT_THE_CFLAGS"; then
7184+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-stringop-truncation"
7185+
fi
70107186
fi
70117187

70127188
# supply -g if --enable-debug

‎configure.in

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ else
440440
fi
441441

442442
# When generating bitcode (for inlining) we always want to use -O2
443-
# even when --enable-debug is specified. The bitcodeit's not going to
443+
# even when --enable-debug is specified. The bitcodeis not going to
444444
# be used for line-by-line debugging, and JIT inlining doesn't work
445445
# without at least -O1 (otherwise clang will emit 'noinline'
446446
# attributes everywhere), which is bad for testing. Still allow the
@@ -513,17 +513,21 @@ if test "$GCC" = yes -a "$ICC" = no; then
513513
# Optimization flags for specific files that benefit from vectorization
514514
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
515515
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
516-
# We want to suppress clang's unhelpful unused-command-line-argument warnings
517-
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
518-
# test for the positive form and if that works, add the negative form
516+
#
517+
# The following tests want to suppress various unhelpful warnings by adding
518+
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
519+
# switches, so we have to test for the positive form and if that works,
520+
# add the negative form. Note that tests of this form typically need to
521+
# be duplicated in the BITCODE_CFLAGS setup stanza below.
522+
#
523+
# Suppress clang's unhelpful unused-command-line-argument warnings.
519524
NOT_THE_CFLAGS=""
520525
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
521526
if test -n "$NOT_THE_CFLAGS"; then
522527
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
523528
fi
524529
# 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
530+
# of warnings when building plperl because of usages in the Perl headers.
527531
NOT_THE_CFLAGS=""
528532
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
529533
if test -n "$NOT_THE_CFLAGS"; then
@@ -563,9 +567,12 @@ fi
563567

564568
AC_SUBST(CFLAGS_VECTOR)
565569

566-
# Determine flags used to emit bitcode for JIT inlining. Need to test
567-
# for behaviour changing compiler flags, to keep compatibility with
568-
# compiler used for normal postgres code.
570+
# Determine flags used to emit bitcode for JIT inlining.
571+
# 1. We must duplicate any behaviour-changing compiler flags used above,
572+
# to keep compatibility with the compiler used for normal Postgres code.
573+
# 2. We don't bother to duplicate extra-warnings switches --- seeing a
574+
# warning in the main build is enough.
575+
# 3. But we must duplicate -Wno-warning flags, else we'll see those anyway.
569576
if test "$with_llvm" = yes ; then
570577
CLANGXX="$CLANG -xc++"
571578

@@ -575,6 +582,27 @@ if test "$with_llvm" = yes ; then
575582
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fwrapv])
576583
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
577584
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])
585+
586+
NOT_THE_CFLAGS=""
587+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wunused-command-line-argument])
588+
if test -n "$NOT_THE_CFLAGS"; then
589+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-unused-command-line-argument"
590+
fi
591+
NOT_THE_CFLAGS=""
592+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
593+
if test -n "$NOT_THE_CFLAGS"; then
594+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-compound-token-split-by-macro"
595+
fi
596+
NOT_THE_CFLAGS=""
597+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wformat-truncation])
598+
if test -n "$NOT_THE_CFLAGS"; then
599+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-format-truncation"
600+
fi
601+
NOT_THE_CFLAGS=""
602+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wstringop-truncation])
603+
if test -n "$NOT_THE_CFLAGS"; then
604+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-stringop-truncation"
605+
fi
578606
fi
579607

580608
# supply -g if --enable-debug

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp