gmp-4.3.2 and 5.0.1 on i386-apple-darwin10 link-fails cxx tests

David Fang fang at
Thu Mar 10 02:05:36 CET 2011

 	For gmp-4.3.2 and gmp-5.0.1, I've received reports of the 
following cxx-test link failure on Intel Macs where gmp's config.guess 
reports: i386-apple-darwin10.*

fang at fangbook 31> make -j1 check
make  t-assign t-binary t-cast t-constr t-headers t-istream t-locale 
t-misc t-ops t-ostream t-prec t-rand t-ternary t-unary
/bin/sh ../../libtool --mode=link ccache g++  -m32 -O2 -pedantic 
-fomit-frame-pointer -mtune=i386 -march=i386   -o t-assign  t-assign.o 
-L../../.libs ../../tests/ ../../ ../../
ccache g++ -m32 -O2 -pedantic -fomit-frame-pointer -mtune=i386 -march=i386 
-o .libs/t-assign t-assign.o -Wl,-bind_at_load 
../../tests/.libs/libtests.a ../../.libs/libgmpxx.dylib 
Undefined symbols:
   "___sync_fetch_and_add_4", referenced from:
       check_mpq()    in t-assign.o

The same versions of gmp, however, pass all their tests on my Macbook, a 
core2-apple-darwin10; I was not able to reproduce this problem on a stock 
build with just --enable-cxx as my only configure option. On my 
core2-apple-darwin10, I was able to reproduce the above failures by 
explicitly configuring: --host=i386-apple-darwin10.6.0 

I've seen this report once on this (or a sibling) mailing list, to which 
there was no resolution.

All of the reporters of this problem, and myself are using the same 

fang at fangbook 34> gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking 
--enable-werror --prefix=/usr --mandir=/share/man 
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib 
--build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- 
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10 
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)

Does anyone know why this link failure occurs on the older pre-core2 Intel 
Macs?  (Can anyone else confirm this on pre-core2?)  Is this an issue that 
can possibly be worked around?  I've searched include headers and system 
libraries for this symbol, only to find:


   static inline _Atomic_word
   __exchange_and_add(volatile _Atomic_word* __mem, int __val)
   { return __sync_fetch_and_add(__mem, __val); }

   static inline void
   __atomic_add(volatile _Atomic_word* __mem, int __val)
   { __sync_fetch_and_add(__mem, __val); }
   __attribute__ ((__unused__))
   __exchange_and_add(volatile _Atomic_word*, int);

   __attribute__ ((__unused__))
   __atomic_add(volatile _Atomic_word*, int);

Thanks for any insight on this.


David Fang

More information about the gmp-bugs mailing list