From owner-freebsd-ports@FreeBSD.ORG Sat Oct 6 16:54:59 2012 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 779DB106566C; Sat, 6 Oct 2012 16:54:59 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay005.isp.belgacom.be (mailrelay005.isp.belgacom.be [195.238.6.171]) by mx1.freebsd.org (Postfix) with ESMTP id C695F8FC1B; Sat, 6 Oct 2012 16:54:58 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABxicFBbsRJX/2dsb2JhbABFu2GDQYEJgiABAQQBJy8iAQULCw4KCRYPCQMCAQIBJx4GDQEHAQGHewq5HotPhhADjm6BIJYLgm+BYQ Received: from 87.18-177-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.177.18.87]) by relay.skynet.be with ESMTP; 06 Oct 2012 18:54:48 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.5/8.14.5) with ESMTP id q96Gsl96003052; Sat, 6 Oct 2012 18:54:48 +0200 (CEST) (envelope-from tijl@coosemans.org) Message-ID: <50706251.7070801@coosemans.org> Date: Sat, 06 Oct 2012 18:54:41 +0200 From: Tijl Coosemans User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:15.0) Gecko/20120920 Thunderbird/15.0.1 MIME-Version: 1.0 To: Shane Ambler References: <506B3E9A.1000905@ShaneWare.Biz> <506EEA7C.2020307@coosemans.org> <507050BE.4050905@ShaneWare.Biz> In-Reply-To: <507050BE.4050905@ShaneWare.Biz> X-Enigmail-Version: 1.4.3 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigA5DF7AB869ED21B54E01D351" Cc: gerald@freebsd.org, FreeBSD-ports Subject: Re: Possible regression in i386 build with gcc 4.6 X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 16:54:59 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA5DF7AB869ED21B54E01D351 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 06-10-2012 17:39, Shane Ambler wrote: > On 05/10/2012 23:41, Tijl Coosemans wrote: >> On 02-10-2012 21:20, Shane Ambler wrote: >>> I found a situation where gcc v4.2 compiles a i386 working binary and= >>> v4.6 doesn't. (Currently 4.7 and 4.8 fail to build this code) I have >>> verified that this happens with 8.2/8.3/9.0 i386 systems. x86_64 >>> versions build without issue as does clang i386/x86_64. >>>=20 >>> It appears that the x86_64 target of gcc offers gcc atomics while the= >>> i386 target doesn't - and this appears to be a freebsd specific setup= , >>> the i386 targets then fall back to using tbb atomics. >>> >>> inline long long >>> atomic_exchange_and_add (volatile long long *at, long long x) >>> { >>> #ifdef USE_GCC_ATOMICS >>> return __sync_fetch_and_add (at, x); >>> #elif USE_TBB >>> atomic *a =3D (atomic *)at; >>> return a->fetch_and_add (x); >>> #elif defined(__APPLE__) >>> >>> #endif >>> } >> >> Atomic operations on long long require cmpxchg8b instruction which was= >> added to the i586, so if you add -march=3Di586 to CFLAGS you should be= >> able to use gcc atomics on FreeBSD/i386 as well. >=20 > The arch setting isn't the issue - gcc compiled on freebsd for 32bit > x86 target doesn't provide gcc atomics. So __sync_fetch_and_add > doesn't exist. While adding support for gcc atomics to the i386 > target would be good, I would assume there is a reason that it is > disabled on FreeBSD (that reason may or may not be resolved now). The __sync built-ins exist in both base and ports gcc, but __sync_fetch_and_add_8 needs at least -march=3Di586. > The point I wanted to make in this email is that for some reason > gcc46 compiles the tbb alternative in a way that causes a seg fault > when gcc42 can compile it fine. And to maybe get the gcc atomics > support re-evaluated. >=20 > But you did give me an idea or two - the first of adding some asm > code is beyond me but I then went and found that go-semacquire.c from > gcc46 source has code for __sync_fetch_and_add_4 (using pthread mutex > locks) so I used that to create a patch that gets the gcc46 build > working. --------------enigA5DF7AB869ED21B54E01D351 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iF4EAREIAAYFAlBwYlcACgkQfoCS2CCgtit5tAD/XZcG7f/jMQcCpQeHKLR40JR7 bymbZtEDHJNJfGAJDQEBAITB9WT4iwmU/4KfG1PzISh2eBCF5jJkVcMxkzYa08QC =1EA3 -----END PGP SIGNATURE----- --------------enigA5DF7AB869ED21B54E01D351--