pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: hlinnaka@iki.fi
Cc: pgsql-committers@postgresql.org
Subject: Re: pgsql: Replace our hacked version of ax_pthread.m4 with latest upstream
Date: Sat, 25 Jul 2015 17:19:16 -0400
Message-ID: <25767.1437859156@sss.pgh.pa.us> (raw)
In-Reply-To: <559D917C.6030201@iki.fi>
References: <E1ZCtMW-0001iM-BK@gemulon.postgresql.org>
	<10166.1436386332@sss.pgh.pa.us>
	<11970.1436386843@sss.pgh.pa.us>
	<559D8887.6020005@iki.fi>
	<13340.1436387986@sss.pgh.pa.us>
	<559D917C.6030201@iki.fi>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

I've located another problem in the new improved ax_pthread.m4 script:
prairiedog is now concluding that it should use -pthread, which leads
to a whole bunch of build warnings along the lines of

powerpc-apple-darwin8-gcc-4.0.1: unrecognized option '-pthread'

Previously it concluded that it didn't need any special switch.

As near as I can tell, the problem is that this bit of ax_pthread.m4
is backwards:

# Clang doesn't consider unrecognized options an error unless we specify
# -Werror. We throw in some extra Clang-specific options to ensure that
# this doesn't happen for GCC, which also accepts -Werror.

AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
save_CFLAGS="$CFLAGS"
ax_pthread_extra_flags="-Werror"
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
                  [AC_MSG_RESULT([yes])],
                  [ax_pthread_extra_flags=
                   AC_MSG_RESULT([no])])
CFLAGS="$save_CFLAGS"

AFAICS, the only way that ax_pthread_extra_flags ends up containing -Werror
is if this compile attempt *succeeds*, which surely ought not happen ever
with any compiler; it certainly won't on any of mine.  Thus, we never
actually apply -Werror and so the subsequent thread-switch testing
completely fails to notice if the compiler merely emits warnings.

Moreover, this check is logically unsound even if it weren't accidentally
backwards, because it cannot distinguish whether the error (if there was
one) required -Werror to happen or would have happened anyway.

And on top of that, at least with the versions of gcc I have laying about,
an unknown or misspelled -p option does not result in nonzero exit status,
whether or not you say -Werror:

$ touch foo.c
$ gcc -pthread -c foo.c
$ gcc -pzthread -c foo.c
gcc: unrecognized option '-pzthread'
gcc: unrecognized option '-pzthread'
$ echo $?
0
$ gcc -Werror -pzthread -c foo.c
gcc: unrecognized option '-pzthread'
gcc: unrecognized option '-pzthread'
$ echo $?
0

(same results on gcc 4.0.1 or 4.4.7)

Therefore, adding -Werror would fail to produce the desired results in the
subsequent thread-flag checks even if the check about whether to add it
had been done correctly.

I realize this is verbatim from upstream autoconf, but that doesn't mean
it's not utterly broken.

			regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



view thread (16+ messages)  latest in thread

Message-ID: <25767.1437859156@sss.pgh.pa.us>
Permalink:  ../25767.1437859156@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25767.1437859156@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, hlinnaka@iki.fi
  Subject: Re: pgsql: Replace our hacked version of ax_pthread.m4 with latest upstream
  In-Reply-To: <25767.1437859156@sss.pgh.pa.us>
  References: <E1ZCtMW-0001iM-BK@gemulon.postgresql.org> <10166.1436386332@sss.pgh.pa.us> <11970.1436386843@sss.pgh.pa.us> <559D8887.6020005@iki.fi> <13340.1436387986@sss.pgh.pa.us> <559D917C.6030201@iki.fi> <25767.1437859156@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox