Intel Builtin Atomics--Odd problem

Johnny john@fayandjohn.com
Mon Dec 1 13:18:00 GMT 2008


Hello,

I've encountered an odd problem I'm hoping someone can help me out with.

In trying to do a standard build of a new version of a package which has 
always compiled for me in the past (djvulibre) and I get a failure.  The 
configure works fine.  The make fails with the following output at the 
failure point:

-----------------

g++ -o .libs/bzz -DHAVE_CONFIG_H -I.. -I.. -I../libdjvu -I. -DNDEBUG -Wall
-O3 -Wno-non-virtual-dtor -mtune=i686 -pthread -DTHREADMODEL=POSIXTHREADS
bzz.o ../libdjvu/.libs/libdjvulibre.so -ljpeg -lpthread -lm
../libdjvu/.libs/libdjvulibre.so: undefined reference to
`__sync_bool_compare_and_swap_4'
../libdjvu/.libs/libdjvulibre.so: undefined reference to
`__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [bzz] Error 1
make[1]: Leaving directory `/home/johnny/source/djvulibre-3.5.21/tools'
make: *** [all] Error 2

-----------------

I filed a bug report with the developer.

The developer is telling me that this problem is related to whether or 
not my system supports "Intel atomic builtins."  However, when checking 
my configure output, it reports that "yes" it does.  So the undefined 
reference error shouldn't be occurring.  The compilation is being run in 
a clean directory and the make and configure are being run on the same 
system.

The developer had me test a simple cpp file and compile it so see if the 
builtin atomic functions would compile properly--as apparently this is 
what the configure script tests for when it checks for atomic builtin 
support.

File Named: synctest.cpp
-------------------------------
static int volatile l;
int main ()
{
__sync_lock_test_and_set(&l,1);
__sync_lock_release(&l);
__sync_add_and_fetch(&l,1);
__sync_bool_compare_and_swap(&l,&l,1);
return 0;
}
-------------------------

Upon trying to compile with:
----
g++ -o synctest -Wall -O3 -Wno-non-virtual-dtor -mtune=i686 -pthread
synctest.cpp -lm
----

I get the following output:
-------------------------
/tmp/ccKAG8tR.o: In function `main':
synctest.cpp:(.text+0x46): undefined reference to
`__sync_bool_compare_and_swap_4'
collect2: ld returned 1 exit status
-------------------------

So, for whatever reason, the first three functions aren't an issue, but 
the __sync_bool_compare_and_swap function is.  Also odd to me is that in 
synctest.cpp the __sync_add_and_fetch function doesn't throw an error 
when compiling, but this is one of the failure errors given while 
compiling the djvulibre package (undefined reference).

Does this make any sense to anybody?  The developer tried on various 
debian and unbuntu machines using gcc 4.1.3 to 4.2.3 to reproduce 
without success.  My environment is a SuSE 10.3 and gcc 4.2.1 setup.  I 
also tried SuSE 11.0 and gcc 4.3.1 with the same problem.  Another user 
on a Fedora 8 system with gcc 4.1.2 is having the same problem.

The only thing which might be tangentially related to this problem is 
that both of us users which are having this problem are running under 
virtualized environments.  I'm running my SuSE under a VMWare 
Workstation Vista Host, and the Fedora user is running his OS under an 
Amazon EC2 virtualized environment.

Is it possible that somehow the virtualization could be messing with the 
  Intel atomic builtin functionality?  Is there a more appropriate forum 
or venue I could post this set of questions too?

The bug report at the developers site is: 
https://sourceforge.net/tracker2/?func=detail&aid=2299878&group_id=32953&atid=406583

Thanks for any feedback offered.

Johnny



More information about the Gcc-help mailing list