Johnny wrote: > g++ -o synctest -Wall -O3 -Wno-non-virtual-dtor -mtune=i686 -pthread > synctest.cpp -lm > ... < > 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. You probably meant -march=i686 not -mtune=i686. The arch setting controls the instruction set available, while the tune setting only controls choice of instructions within that set and scheduling. Without any arch option specified the default is 386, the lowest common denominator. The 386 did not have the cmpxchg instruction necessary to implement the atomic compare and swap operation. It's not a compile time error because when a suitable instruction isn't available the compiler emits a call to a library function instead, as in theory it is possible to implement atomic operations with aid from the kernel or operating system if the cpu doesn't support it as a single instruction. In this case since cmpxchg is available for the 486 and later architectures there's really no point in doing this and there's so such implementation, hence the link error. Brian