Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6D9522BF81 for ; Fri, 16 Dec 2011 06:25:17 -0400 (AST) Received: from exprod7og112.obsmtp.com ([64.18.2.177]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RbUyY-0006lc-4b for pgsql-bugs@postgresql.org; Fri, 16 Dec 2011 10:25:17 +0000 Received: from mail-ee0-f44.google.com ([74.125.83.44]) (using TLSv1) by exprod7ob112.postini.com ([64.18.6.12]) with SMTP ID DSNKTuscexpUhW1hdBJRBkllCLwJv3fW6h5n@postini.com; Fri, 16 Dec 2011 02:25:13 PST Received: by eekc14 with SMTP id c14so1766164eek.31 for ; Fri, 16 Dec 2011 02:24:58 -0800 (PST) Received: by 10.14.48.194 with SMTP id v42mr2921885eeb.81.1324031098172; Fri, 16 Dec 2011 02:24:58 -0800 (PST) Received: from [192.168.1.101] (dsl-hkibrasgw2-ff6cc300-200.dhcp.inet.fi. [88.195.108.200]) by mx.google.com with ESMTPS id 76sm36351106eeh.0.2011.12.16.02.24.56 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Dec 2011 02:24:57 -0800 (PST) Message-ID: <4EEB1C77.1000309@enterprisedb.com> Date: Fri, 16 Dec 2011 12:24:55 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: PostgreSQL Bugs Subject: Re: TAS patch for building on armel/armhf thumb References: <20111216093646.GD2722@piware.de> In-Reply-To: <20111216093646.GD2722@piware.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/128 X-Sequence-Number: 31939 On 16.12.2011 11:36, Martin Pitt wrote: > if you build postgresql (tested all releases from 8.4 up to trunk) for > ARM with the -mthumb instruction set (much better performance), it > fails with > > gcc -g -O2 -g -Wall -O2 -fPIC -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -g -I../../../../src/include -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.5 -c -o xlog.o xlog.c > /tmp/cc8Wkglp.s: Assembler messages: > /tmp/cc8Wkglp.s:1456: Error: selected processor does not support `swpb r3,r3,[r0]' > /tmp/cc8Wkglp.s:1587: Error: selected processor does not support `swpb r2,r2,[r0]' > > A fair while ago, Alexander Sack from Linaro applied a patch to our > packages to drop the Assembler bits and instead use gcc's atomic > builtins [1], which provide a proper implementation for thumb, too. > > The original patch spectacularly failed on our slightly newer Panda > boards (our old builders were Freescale Babbage boards), but I got > that to work yesterday. Now it's working on Babbage, Panda, both with > and without hard float (armhf) enabled. > > I'm not sure how appropriate it is for upstream to have GCC-isms in > the code, but even if it can't land upstream, perhaps it is useful for > other porters/packagers. Should be ok, as long as it's within #ifdef __GNUC__. An even better approach would be to have a configure test for __sync_lock_test_and_set. A quick google search suggests that Intel C Compiler version >= 11.0 also supports __sync_lock_test_and_set, for example. It probably makes sense to use it on any platform where it's defined. Presumably an implementation provided by the compiler is always going to be at least as good as any magic assembler incantations we can come up with. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com