This bug report might shed some light on this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47460

I wonder if I've misunderstood the GCC docs at https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins. My reading of the docs was that if the platform doesn't support the needed instructions then GCC will generated a call to e.g. __sync_fetch_and_add_1, where that function *is provided by GCC* as a fallback. Now I'm wondering if I'm supposed to supply that fallback.




On Wed, Jul 16, 2014 at 9:32 PM, Páli Gábor János <pali.gabor@gmail.com> wrote:
2014-07-16 20:57 GMT+02:00 Niklas Larsson <metaniklas@gmail.com>:
> I get the same failure when I try to build HEAD. Turns out the error occurs
> on the 32-bit Windows build, and my successful build was a 64-bit build. My
> 64-bit build still succeeds.

Perhaps you should specify -march=i586 for the C compiler?

I have tried Johan's test program (posted in this thread earlier) with
-march=i386 and it generates a function call for
__sync_fetch_and_add_1(). (No cmpxchg?)  In case of -march=i486,
__sync_fetch_and_add_8() is generated (this cpu type does have a
cmpxchg8b instruction).

I faced this error earlier because the FreeBSD/i386 builder has been
failing for a while [1] as it assumes -march=i486 by default.  With
-march=i586, everything builds just fine.  On GNU/Linux, it is not a
problem as it builds C code with -march=i686.

[1] http://haskell.inf.elte.hu/builders/freebsd-i386-head/317/10.html