Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZJGhQ-0006hZ-Dq for pgsql-committers@arkaria.postgresql.org; Sun, 26 Jul 2015 07:50:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZJGhP-0002rJ-9X for pgsql-committers@arkaria.postgresql.org; Sun, 26 Jul 2015 07:50:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZJGhC-0002aG-4p for pgsql-committers@postgresql.org; Sun, 26 Jul 2015 07:50:06 +0000 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZJGgq-0001Dt-6a for pgsql-committers@postgresql.org; Sun, 26 Jul 2015 07:50:05 +0000 Received: by wibud3 with SMTP id ud3so78495046wib.0 for ; Sun, 26 Jul 2015 00:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=d0aS0Qn+y6Mxml/2CRn9JvzI3u84bI6Pa5MxS3fKhsM=; b=EF+x9yHcQz4KwzPnymH677G1V/bsatxlnbDc7Ys9PBwJXF9W4NZ9XycSw2YuBVIHdh PTVXX8Nk2IGHM5gxL07j9VkxgN1cVl8RSEpkocO6ZizgSc1FK4UX8FEjMg9eMWSLAjNO DPnT1PaaGFkMBqwu7H88yDdgWiTs7+35saJv+qKTo9uTFxLpMyREhCZ0EGb9WzkS3/3M eL3wZ8XILd8gJ6Zy+hO4WYm2DeMW4XMrwNCLPbg+cmsVUpgl4eUqVS+Y+MJVndxTeEn4 YNDzy+0ESi8uraWsdOg2sBRNUMgV03hq9ZDnnJBZZUAIr1ztGIxcbSfUSMFIxqrM8Nfk WEhQ== X-Received: by 10.181.13.109 with SMTP id ex13mr13087313wid.39.1437896981820; Sun, 26 Jul 2015 00:49:41 -0700 (PDT) Received: from [192.168.1.105] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id ma4sm21258931wjb.38.2015.07.26.00.49.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 00:49:40 -0700 (PDT) Message-ID: <55B49111.9010508@iki.fi> Date: Sun, 26 Jul 2015 10:49:37 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-committers@postgresql.org Subject: Re: pgsql: Replace our hacked version of ax_pthread.m4 with latest upstream References: <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> In-Reply-To: <25767.1437859156@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 07/26/2015 12:19 AM, Tom Lane wrote: > 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. Hmm. I don't think that's backwards. It's a strange way of testing "does the compiler understand -Werror, and is it not GCC?". It succeeds on clang, as the comment says: ~$ clang a.c -c -Werror -Wunknown-warning-option -Wsizeof-array-argument [success] The problem it's trying to work-around is that allegedly clang does not throw an error if -pthread is given on command-line on a platform where it's not required, merely a warning. That workaround is too narrow, as we have the exact same problem on prairiedog, with gcc. (But as you noted, -Werror wouldn't help with older gcc versions anyway) Googling around, I found a ticket in the autoconf bug tracker for this: https://savannah.gnu.org/patch/?8186. The discussion died out in 2013, but it seems that the latest idea there was to change the order the flags are tested on Darwin, so that "none" is tested before "-pthread". That should fix the issue, and hopefully not create other problems on other Darwin variants. So I suggest that we do: @@ -160,7 +165,7 @@ case ${host_os} in ;; darwin*) - ax_pthread_flags="-pthread $ax_pthread_flags" + ax_pthread_flags="none -pthread $ax_pthread_flags" ;; esac It's sad that we have to hack this script again, I hoped we could use the upstream version as is. I'll comment on the upstream ticket, let's see if we can get the upstream version fixed too. > 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. This was fixed somewhere between 4.4 and 4.6. But yeah, it means that we cannot rely on it. - Heikki -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers