https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368
Bug ID: 63368 Summary: undefined reference to `__sync_val_compare_and_swap_8' Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mathieu.malaterre at gmail dot com If I am reading the online documentation properly: https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins __sync_val_compare_and_swap on some targets will result in a function call (where direct code generation is not available or not yet implemented). It seems to be happening in my testcase, however __sync_val_compare_and_swap_8 does not seems to be defined anywhere else. Steps: $ cat t.c #include <stdint.h> int main() { int64_t x = 0, y = 1; y = __sync_val_compare_and_swap(&x, x, y); return 0; } $ gcc t.c /tmp/cc6JIpFx.o: In function `main': t.c:(.text+0x64): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status $ gcc t.c -lgcc_s /tmp/ccu3ReMZ.o: In function `main': t.c:(.text+0x64): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status $ gcc t.c -lgcc /tmp/ccO8gyeR.o: In function `main': t.c:(.text+0x64): undefined reference to `__sync_val_compare_and_swap_8' collect2: ld returned 1 exit status