Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZUyJg-0004MD-Pw for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Aug 2015 14:38:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZUyJg-0007zx-4g for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Aug 2015 14:38:12 +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 1ZUyIN-0006SY-BW for pgsql-hackers@postgreSQL.org; Thu, 27 Aug 2015 14:36:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZUyIK-0004UN-Ge for pgsql-hackers@postgreSQL.org; Thu, 27 Aug 2015 14:36:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t7REakAt014935 for ; Thu, 27 Aug 2015 10:36:46 -0400 From: Tom Lane To: pgsql-hackers@postgreSQL.org Subject: Re: [BUGS] Compile fails on AIX 6.1 In-reply-to: <1823346352.314711.1405443099463.open-xchange@oxbaltgw55.schlund.de> References: <1823346352.314711.1405443099463.open-xchange@oxbaltgw55.schlund.de> Comments: In-reply-to "Lars Ewald (web.de)" message dated "Tue, 15 Jul 2014 18:51:39 +0200" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <14893.1440686106.0@sss.pgh.pa.us> Date: Thu, 27 Aug 2015 10:36:46 -0400 Message-ID: <14934.1440686206@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14893.1440686106.1@sss.pgh.pa.us> A year ago we had a thread about assembler syntax errors on AIX, but it died off when the original complainant stopped responding. I was recently contacted off-list by Steve Underwood, who was seeing the same symptoms on AIX 7.1. After some investigation, we found that the problem is that IBM's assembler doesn't understand the "local symbol" notation supported by the GNU assembler ("bne 1f" referencing the next occurrence of "1:"). So s_lock.h's PowerPC assembly code works if you have gcc configured to use gas as backend, but not if it's configured to use the native AIX assembler. Steve says the latter configuration is pretty common. Curiously, our build goes through just fine if you use the gcc 4.2.0 build available from IBM's website. But it turns out it's using the "generic AIX" stanza of s_lock.h, ie _check_lock(), rather than the lwarx assembly code. AFAICS this must mean that that gcc build does not define __ppc__ --- very weird. But a bit offtopic. So now that we know what is happening, what do we want to do about it? AFAICS there are two plausible ways to fix it: 1. Add a configure-time test to see if the assembler supports local symbols. If not, don't try to use the lwarx assembly stanza, but let it fall through to using _check_lock(). This would be simple but there would presumably be some performance hit. 2. Don't rely on local symbols in the PPC spinlock assembly code. This is a bit ugly, because the only way to do that is to hard-code branch offsets, as in the attached draft patch. If there were any likelihood that we'd be changing the PPC spinlock code in future, I would regard this as unmaintainable ... but really, that code is pretty static. So I think this is a viable alternative. Comments? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="no-local-asm-symbols.patch"; charset="us-ascii" Content-ID: <14893.1440686106.2@sss.pgh.pa.us> Content-Description: no-local-asm-symbols.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index ef66644..9e709f8 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -447,6 +447,12 @@ typedef unsigned int slock_t; * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-20= 02, * an isync is a sufficient synchronization barrier after a lwarx/stwcx lo= op. * On newer machines, we can use lwsync instead for better performance. + * + * Ordinarily, we'd code the branches here using GNU-style local symbols, = that + * is "1f" referencing "1:" and so on. But some people run gcc on AIX with + * IBM's assembler as backend, and IBM's assembler doesn't do local symbol= s. + * So hand-code the branch offsets; fortunately, all PPC instructions are + * exactly 4 bytes each, so it's not too hard to count. */ static __inline__ int tas(volatile slock_t *lock) @@ -461,20 +467,18 @@ tas(volatile slock_t *lock) " lwarx %0,0,%3 \n" #endif " cmpwi %0,0 \n" -" bne 1f \n" +" bne .+16 \n" /* branch to li %1,1 */ " addi %0,%0,1 \n" " stwcx. %0,0,%3 \n" -" beq 2f \n" -"1: li %1,1 \n" -" b 3f \n" -"2: \n" +" beq .+12 \n" /* branch to lwsync/isync */ +" li %1,1 \n" +" b .+12 \n" /* branch to end of asm sequence */ #ifdef USE_PPC_LWSYNC " lwsync \n" #else " isync \n" #endif " li %1,0 \n" -"3: \n" =20 : "=3D&r"(_t), "=3Dr"(_res), "+m"(*lock) : "r"(lock) ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers ------- =_aaaaaaaaaa0--