Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6347bdb

Browse files
committed
Suppress clang's unhelpful gripes about -pthread switch being unused.
Considering the number of cases in which "unused" command line arguments are silently ignored by compilers, it's fairly astonishing that anybody thought this warning was useful; it's certainly nothing but an annoyance when building Postgres. One such case is that neither gcc nor clang complain about unrecognized -Wno-foo switches, making it more difficult to figure out whether the switch does anything than one could wish. Back-patch to 9.3, which is as far back as the patch applies conveniently (we'd have to back-patch PGAC_PROG_CC_VAR_OPT to go further, and it doesn't seem worth that).
1 parent e105df2 commit 6347bdb

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

configure

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4503,6 +4503,72 @@ if test x"$pgac_cv_prog_cc_cflags__ftree_vectorize" = x"yes"; then
45034503
CFLAGS_VECTOR="${CFLAGS_VECTOR} -ftree-vectorize"
45044504
fi
45054505

4506+
# We want to suppress clang's unhelpful unused-command-line-argument warnings
4507+
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
4508+
# test for the positive form and if that works, add the negative form
4509+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wunused-command-line-argument" >&5
4510+
$as_echo_n "checking whether $CC supports -Wunused-command-line-argument... " >&6; }
4511+
if test "${pgac_cv_prog_cc_cflags__Wunused_command_line_argument+set}" = set; then
4512+
$as_echo_n "(cached) " >&6
4513+
else
4514+
pgac_save_CFLAGS=$CFLAGS
4515+
CFLAGS="$pgac_save_CFLAGS -Wunused-command-line-argument"
4516+
ac_save_c_werror_flag=$ac_c_werror_flag
4517+
ac_c_werror_flag=yes
4518+
cat >conftest.$ac_ext <<_ACEOF
4519+
/* confdefs.h. */
4520+
_ACEOF
4521+
cat confdefs.h >>conftest.$ac_ext
4522+
cat >>conftest.$ac_ext <<_ACEOF
4523+
/* end confdefs.h. */
4524+
4525+
int
4526+
main ()
4527+
{
4528+
4529+
;
4530+
return 0;
4531+
}
4532+
_ACEOF
4533+
rm -f conftest.$ac_objext
4534+
if { (ac_try="$ac_compile"
4535+
case "(($ac_try" in
4536+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4537+
*) ac_try_echo=$ac_try;;
4538+
esac
4539+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4540+
$as_echo "$ac_try_echo") >&5
4541+
(eval "$ac_compile") 2>conftest.er1
4542+
ac_status=$?
4543+
grep -v '^ *+' conftest.er1 >conftest.err
4544+
rm -f conftest.er1
4545+
cat conftest.err >&5
4546+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4547+
(exit $ac_status); } && {
4548+
test -z "$ac_c_werror_flag" ||
4549+
test ! -s conftest.err
4550+
} && test -s conftest.$ac_objext; then
4551+
pgac_cv_prog_cc_cflags__Wunused_command_line_argument=yes
4552+
else
4553+
$as_echo "$as_me: failed program was:" >&5
4554+
sed 's/^/| /' conftest.$ac_ext >&5
4555+
4556+
pgac_cv_prog_cc_cflags__Wunused_command_line_argument=no
4557+
fi
4558+
4559+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4560+
ac_c_werror_flag=$ac_save_c_werror_flag
4561+
CFLAGS="$pgac_save_CFLAGS"
4562+
fi
4563+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wunused_command_line_argument" >&5
4564+
$as_echo "$pgac_cv_prog_cc_cflags__Wunused_command_line_argument" >&6; }
4565+
if test x"$pgac_cv_prog_cc_cflags__Wunused_command_line_argument" = x"yes"; then
4566+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wunused-command-line-argument"
4567+
fi
4568+
4569+
if test -n "$NOT_THE_CFLAGS"; then
4570+
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
4571+
fi
45064572
elif test "$ICC" = yes; then
45074573
# Intel's compiler has a bug/misoptimization in checking for
45084574
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

configure.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,13 @@ if test "$GCC" = yes -a "$ICC" = no; then
427427
# Optimization flags for specific files that benefit from vectorization
428428
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
429429
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
430+
# We want to suppress clang's unhelpful unused-command-line-argument warnings
431+
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
432+
# test for the positive form and if that works, add the negative form
433+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
434+
if test -n "$NOT_THE_CFLAGS"; then
435+
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
436+
fi
430437
elif test "$ICC" = yes; then
431438
# Intel's compiler has a bug/misoptimization in checking for
432439
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)