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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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

Add EVENT_10842=15

You can also set this as an environment variable with the same name & value.

Sheeraz Majeed May 10 2024 — edited on May 10 2024

Hi, Thanks for reply.

But still no trace or log files to check used oci functions

Works for me.

cjones@cjones-mac:~$ rm -rf $HOME/instantclient/log/diag/clients && mkdir -p $HOME/instantclient/log/diag/clients
cjones@cjones-mac:~$ export EVENT_10842=15
cjones@cjones-mac:~$ sqlplus cj/cj@localhost/orclpdb1

...

SQL> select * from dual;

D
-
X

SQL> exit

And then a file like /Users/cjones/instantclient/log/diag/clients/user_cjones/host_nnnnnn_nn/trace/ora_nnn_nnnnn.trc will contain lines like:

# 2024-06-06 07:26:54.520 # Thread ID 8547126272 # Entry - OCIServerAttach(srvhp = 0x128030068, errhp = 0x13580a410, dblink_hash = H:0x9bf0f8e9ee161fdf, mode = OCI_DEFAULT(000000000), dblink = localhost/orclpdb1, dblink_len = 18 );
1 - 3

Post Details

Added on Jan 14 2025
0 comments
38 views