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

Commitf5e3fab

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 parent82bb97e commitf5e3fab

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
@@ -5229,7 +5229,7 @@ else
52295229
fi
52305230

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

59905990

5991-
# We want to suppress clang's unhelpful unused-command-line-argument warnings
5992-
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
5993-
# test for the positive form and if that works, add the negative form
5991+
#
5992+
# The following tests want to suppress various unhelpful warnings by adding
5993+
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
5994+
# switches, so we have to test for the positive form and if that works,
5995+
# add the negative form. Note that tests of this form typically need to
5996+
# be duplicated in the BITCODE_CFLAGS setup stanza below.
5997+
#
5998+
# Suppress clang's unhelpful unused-command-line-argument warnings.
59945999
NOT_THE_CFLAGS=""
59956000
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
59966001
$as_echo_n "checking whether ${CC} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
@@ -6035,8 +6040,7 @@ fi
60356040
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
60366041
fi
60376042
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
6038-
# of warnings when building plperl because of Perl. Like previously, test
6039-
# for the positive form and add the negative form
6043+
# of warnings when building plperl because of usages in the Perl headers.
60406044
NOT_THE_CFLAGS=""
60416045
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
60426046
$as_echo_n "checking whether ${CC} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
@@ -6635,9 +6639,12 @@ fi
66356639

66366640

66376641

6638-
# Determine flags used to emit bitcode for JIT inlining. Need to test
6639-
# for behaviour changing compiler flags, to keep compatibility with
6640-
# compiler used for normal postgres code.
6642+
# Determine flags used to emit bitcode for JIT inlining.
6643+
# 1. We must duplicate any behaviour-changing compiler flags used above,
6644+
# to keep compatibility with the compiler used for normal Postgres code.
6645+
# 2. We don't bother to duplicate extra-warnings switches --- seeing a
6646+
# warning in the main build is enough.
6647+
# 3. But we must duplicate -Wno-warning flags, else we'll see those anyway.
66416648
if test "$with_llvm" = yes ; then
66426649
CLANGXX="$CLANG -xc++"
66436650

@@ -6905,6 +6912,175 @@ if test x"$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" = x"yes";
69056912
BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -fexcess-precision=standard"
69066913
fi
69076914

6915+
6916+
NOT_THE_CFLAGS=""
6917+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
6918+
$as_echo_n "checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
6919+
if ${pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument+:} false; then :
6920+
$as_echo_n "(cached) " >&6
6921+
else
6922+
pgac_save_CFLAGS=$CFLAGS
6923+
pgac_save_CC=$CC
6924+
CC=${CLANG}
6925+
CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
6926+
ac_save_c_werror_flag=$ac_c_werror_flag
6927+
ac_c_werror_flag=yes
6928+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6929+
/* end confdefs.h. */
6930+
6931+
int
6932+
main ()
6933+
{
6934+
6935+
;
6936+
return 0;
6937+
}
6938+
_ACEOF
6939+
if ac_fn_c_try_compile "$LINENO"; then :
6940+
pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument=yes
6941+
else
6942+
pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument=no
6943+
fi
6944+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6945+
ac_c_werror_flag=$ac_save_c_werror_flag
6946+
CFLAGS="$pgac_save_CFLAGS"
6947+
CC="$pgac_save_CC"
6948+
fi
6949+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" >&5
6950+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" >&6; }
6951+
if test x"$pgac_cv_prog_CLANG_cflags__Wunused_command_line_argument" = x"yes"; then
6952+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
6953+
fi
6954+
6955+
if test -n "$NOT_THE_CFLAGS"; then
6956+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-unused-command-line-argument"
6957+
fi
6958+
NOT_THE_CFLAGS=""
6959+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS" >&5
6960+
$as_echo_n "checking whether ${CLANG} supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... " >&6; }
6961+
if ${pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro+:} false; then :
6962+
$as_echo_n "(cached) " >&6
6963+
else
6964+
pgac_save_CFLAGS=$CFLAGS
6965+
pgac_save_CC=$CC
6966+
CC=${CLANG}
6967+
CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
6968+
ac_save_c_werror_flag=$ac_c_werror_flag
6969+
ac_c_werror_flag=yes
6970+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6971+
/* end confdefs.h. */
6972+
6973+
int
6974+
main ()
6975+
{
6976+
6977+
;
6978+
return 0;
6979+
}
6980+
_ACEOF
6981+
if ac_fn_c_try_compile "$LINENO"; then :
6982+
pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro=yes
6983+
else
6984+
pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro=no
6985+
fi
6986+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6987+
ac_c_werror_flag=$ac_save_c_werror_flag
6988+
CFLAGS="$pgac_save_CFLAGS"
6989+
CC="$pgac_save_CC"
6990+
fi
6991+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" >&5
6992+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" >&6; }
6993+
if test x"$pgac_cv_prog_CLANG_cflags__Wcompound_token_split_by_macro" = x"yes"; then
6994+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wcompound-token-split-by-macro"
6995+
fi
6996+
6997+
if test -n "$NOT_THE_CFLAGS"; then
6998+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-compound-token-split-by-macro"
6999+
fi
7000+
NOT_THE_CFLAGS=""
7001+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wformat-truncation, for NOT_THE_CFLAGS" >&5
7002+
$as_echo_n "checking whether ${CLANG} supports -Wformat-truncation, for NOT_THE_CFLAGS... " >&6; }
7003+
if ${pgac_cv_prog_CLANG_cflags__Wformat_truncation+:} false; then :
7004+
$as_echo_n "(cached) " >&6
7005+
else
7006+
pgac_save_CFLAGS=$CFLAGS
7007+
pgac_save_CC=$CC
7008+
CC=${CLANG}
7009+
CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
7010+
ac_save_c_werror_flag=$ac_c_werror_flag
7011+
ac_c_werror_flag=yes
7012+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7013+
/* end confdefs.h. */
7014+
7015+
int
7016+
main ()
7017+
{
7018+
7019+
;
7020+
return 0;
7021+
}
7022+
_ACEOF
7023+
if ac_fn_c_try_compile "$LINENO"; then :
7024+
pgac_cv_prog_CLANG_cflags__Wformat_truncation=yes
7025+
else
7026+
pgac_cv_prog_CLANG_cflags__Wformat_truncation=no
7027+
fi
7028+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7029+
ac_c_werror_flag=$ac_save_c_werror_flag
7030+
CFLAGS="$pgac_save_CFLAGS"
7031+
CC="$pgac_save_CC"
7032+
fi
7033+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wformat_truncation" >&5
7034+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wformat_truncation" >&6; }
7035+
if test x"$pgac_cv_prog_CLANG_cflags__Wformat_truncation" = x"yes"; then
7036+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
7037+
fi
7038+
7039+
if test -n "$NOT_THE_CFLAGS"; then
7040+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-format-truncation"
7041+
fi
7042+
NOT_THE_CFLAGS=""
7043+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wstringop-truncation, for NOT_THE_CFLAGS" >&5
7044+
$as_echo_n "checking whether ${CLANG} supports -Wstringop-truncation, for NOT_THE_CFLAGS... " >&6; }
7045+
if ${pgac_cv_prog_CLANG_cflags__Wstringop_truncation+:} false; then :
7046+
$as_echo_n "(cached) " >&6
7047+
else
7048+
pgac_save_CFLAGS=$CFLAGS
7049+
pgac_save_CC=$CC
7050+
CC=${CLANG}
7051+
CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
7052+
ac_save_c_werror_flag=$ac_c_werror_flag
7053+
ac_c_werror_flag=yes
7054+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7055+
/* end confdefs.h. */
7056+
7057+
int
7058+
main ()
7059+
{
7060+
7061+
;
7062+
return 0;
7063+
}
7064+
_ACEOF
7065+
if ac_fn_c_try_compile "$LINENO"; then :
7066+
pgac_cv_prog_CLANG_cflags__Wstringop_truncation=yes
7067+
else
7068+
pgac_cv_prog_CLANG_cflags__Wstringop_truncation=no
7069+
fi
7070+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7071+
ac_c_werror_flag=$ac_save_c_werror_flag
7072+
CFLAGS="$pgac_save_CFLAGS"
7073+
CC="$pgac_save_CC"
7074+
fi
7075+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Wstringop_truncation" >&5
7076+
$as_echo "$pgac_cv_prog_CLANG_cflags__Wstringop_truncation" >&6; }
7077+
if test x"$pgac_cv_prog_CLANG_cflags__Wstringop_truncation" = x"yes"; then
7078+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
7079+
fi
7080+
7081+
if test -n "$NOT_THE_CFLAGS"; then
7082+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-stringop-truncation"
7083+
fi
69087084
fi
69097085

69107086
# supply -g if --enable-debug

‎configure.in

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ else
436436
fi
437437

438438
# When generating bitcode (for inlining) we always want to use -O2
439-
# even when --enable-debug is specified. The bitcodeit's not going to
439+
# even when --enable-debug is specified. The bitcodeis not going to
440440
# be used for line-by-line debugging, and JIT inlining doesn't work
441441
# without at least -O1 (otherwise clang will emit 'noinline'
442442
# attributes everywhere), which is bad for testing. Still allow the
@@ -507,17 +507,21 @@ if test "$GCC" = yes -a "$ICC" = no; then
507507
# Optimization flags for specific files that benefit from vectorization
508508
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
509509
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
510-
# We want to suppress clang's unhelpful unused-command-line-argument warnings
511-
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
512-
# test for the positive form and if that works, add the negative form
510+
#
511+
# The following tests want to suppress various unhelpful warnings by adding
512+
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
513+
# switches, so we have to test for the positive form and if that works,
514+
# add the negative form. Note that tests of this form typically need to
515+
# be duplicated in the BITCODE_CFLAGS setup stanza below.
516+
#
517+
# Suppress clang's unhelpful unused-command-line-argument warnings.
513518
NOT_THE_CFLAGS=""
514519
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
515520
if test -n "$NOT_THE_CFLAGS"; then
516521
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
517522
fi
518523
# Remove clang 12+'s compound-token-split-by-macro, as this causes a lot
519-
# of warnings when building plperl because of Perl. Like previously, test
520-
# for the positive form and add the negative form
524+
# of warnings when building plperl because of usages in the Perl headers.
521525
NOT_THE_CFLAGS=""
522526
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
523527
if test -n "$NOT_THE_CFLAGS"; then
@@ -557,9 +561,12 @@ fi
557561

558562
AC_SUBST(CFLAGS_VECTOR)
559563

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

@@ -569,6 +576,27 @@ if test "$with_llvm" = yes ; then
569576
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fwrapv])
570577
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
571578
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])
579+
580+
NOT_THE_CFLAGS=""
581+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wunused-command-line-argument])
582+
if test -n "$NOT_THE_CFLAGS"; then
583+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-unused-command-line-argument"
584+
fi
585+
NOT_THE_CFLAGS=""
586+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wcompound-token-split-by-macro])
587+
if test -n "$NOT_THE_CFLAGS"; then
588+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-compound-token-split-by-macro"
589+
fi
590+
NOT_THE_CFLAGS=""
591+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wformat-truncation])
592+
if test -n "$NOT_THE_CFLAGS"; then
593+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-format-truncation"
594+
fi
595+
NOT_THE_CFLAGS=""
596+
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wstringop-truncation])
597+
if test -n "$NOT_THE_CFLAGS"; then
598+
BITCODE_CFLAGS="$BITCODE_CFLAGS -Wno-stringop-truncation"
599+
fi
572600
fi
573601

574602
# supply -g if --enable-debug

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp