Description of problem: Programs using __sync_fetch_and_and() fail to build with a link error: # make sync_fetch_and_and cc -c -o sync_fetch_and_and.o sync_fetch_and_and.c cc sync_fetch_and_and.o -o sync_fetch_and_and sync_fetch_and_and.o: In function `f': sync_fetch_and_and.c:(.text+0x15): undefined reference to `__sync_fetch_and_add_4' collect2: ld returned 1 exit status make: *** [sync_fetch_and_and] Error 1 Version-Release number of selected component (if applicable): gcc-4.1.2-48.el5 How reproducible: Always Steps to Reproduce: 1. 'make sync_fetch_and_and' with the following program: int f(unsigned *p) { return __sync_fetch_and_and(p, 0); } int main(int ac, char **av) { unsigned v = 3; f(&v); return v; } Actual results: /tmp/ccsXNXmr.o: In function `f': sync_fetch_and_and.c:(.text+0x15): undefined reference to `__sync_fetch_and_and_4' collect2: ld returned 1 exit status Expected results: Clean build Additional info: Works as expected with gcc44.
Only i486 and up supports that, so you need to compile with -march=i486 or above. In RHEL6 we default to -march=i686, so you don't need to pass anything special, but in RHEL5 we default to -march=i386.