From owner-freebsd-ports@FreeBSD.ORG Fri Oct 5 14:12:26 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 1A745106566B; Fri, 5 Oct 2012 14:12:26 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay002.isp.belgacom.be (mailrelay002.isp.belgacom.be [195.238.6.175]) by mx1.freebsd.org (Postfix) with ESMTP id 681868FC16; Fri, 5 Oct 2012 14:12:25 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EADbpblBbsRJX/2dsb2JhbABFu1yDQ4EJgiABAQUnLyIBEAsOCgkWDwkDAgECASceBg0BBwEBiAW4KYs+hgkDjm6BIJYLgm8 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; 05 Oct 2012 16:11:15 +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 q95EBDi0002952; Fri, 5 Oct 2012 16:11:14 +0200 (CEST) (envelope-from tijl@coosemans.org) Message-ID: <506EEA7C.2020307@coosemans.org> Date: Fri, 05 Oct 2012 16:11:08 +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> In-Reply-To: <506B3E9A.1000905@ShaneWare.Biz> X-Enigmail-Version: 1.4.3 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig14D90F358845505602CBF7E9" 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: Fri, 05 Oct 2012 14:12:26 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig14D90F358845505602CBF7E9 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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. >=20 > Is this some subtle bug I'm missing? can it be alleviated with compiler= > flags/more universal code? >=20 > I have tried to cut this down to just the call that triggers a > segmentation fault but the one call itself isn't enough. >=20 > The issue can be found in graphics/openimageio. The easiest way I know > to cause the segmentation fault is with the image viewer that is part o= f > the port (it is a Qt app) it seg faults during startup. There is no nee= d > to open any images just starting iv with an empty window is fine. >=20 > The makefile is setup to USE_GCC=3D4.6+ for i386/8.2 - this is a leftov= er > from earlier versions that will be removed next update. >=20 > cd /usr/ports/graphics/openimageio > make > ./work/.build/iv/iv >=20 > The error appears to stem from line 193 of src/libutil/ustring.cpp >=20 > atomic_exchange_and_add (&ustring_stats_constructed, 1); >=20 > Commenting this line prevents the crash but isn't a valid fix. > the relevant function it calls is -- src/include/thread.h:283 > which uses the atomic class template from tbb for the i386 build. >=20 > 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. --------------enig14D90F358845505602CBF7E9 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) iF4EAREIAAYFAlBu6oEACgkQfoCS2CCgtivlZgD+NY/uNU3qgi//14Bh8OBTkut8 wqCn2KWqsCr9DPtb9KcA/icIr/c7WKaP78eclx8aA4v1SAU+wWpDB5OwvGQxlA4V =Uk7J -----END PGP SIGNATURE----- --------------enig14D90F358845505602CBF7E9--