Skip to Main Content

Programming Languages & Frameworks

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Forte C Compiler option -Xa makes intrinsic functions unavailable

Consider this simple C code:

cat sync_bool.c
#include <stdio.h>
long n;
int main(void) {
if (!__sync_bool_compare_and_swap(&n, 0, 1)) {
fprintf(stderr, "__sync_bool_compare_and_swap() failed\n");
}
if (__sync_bool_compare_and_swap(&n, (long)0, 1)) {
fprintf(stderr, "__sync_bool_compare_and_swap() succeeded\n");
}
fprintf(stderr, "all clear\n");
}

If I build it a usual way it builds and runs fine:

$ cc -m64 sync_bool.c
./a.out
__sync_bool_compare_and_swap() failed
__sync_bool_compare_and_swap() succeeded
all clear

But if I use the -Xa parameter which must extend C features it stops linking properly:
$ cc -m64 -Xa sync_bool.c
"sync_bool.c", line 4: warning: implicit function declaration: __sync_bool_compare_and_swap
sync_bool.o: In function `main':
**sync_bool.c:(.text+0x1f): undefined reference to `__sync_bool_compare_and_swap'**
**sync_bool.c:(.text+0x5b): undefined reference to `__sync_bool_compare_and_swap'**
postopt: error: ld failed to link the binary
cc: postopt failed for a.out

The compiler help message describes the -Xa parameter so:

$ cc -flags | grep Xa
-Xa Compile assuming ANSI C conformance, allow K & R extensions

Forte compiler reference does not say anything that -Xa disables intrinsic functions for C code.

My environment:

  1. OS: Redhat 7 x86_64
  2. Compiler: Studio 12.6 Sun C 5.15 Linux_i386 2017/05/30
Comments
Post Details
Added on Jan 14 2025
0 comments
127 views