You can choose to use either the Oracle Developer Studio atomics library (libstatomic.so) or the GCC atomics library (libatomic.so), but it is important to make this consistent among executables and libraries that are linked together. Only one atomics library should be used in a running process.
To control which library is used at link time, use the –xatomic option. To link to Oracle Developer Studio's library libstatomic, use –xatomic=studio and to link to GCC's library libatomic, use –xatomic=gcc. To prevent linking with a library, use –xatomic=none.
As an aid to porting existing Makefiles or source code that uses GCC compilers, if –latomic is passed to the compiler, the option is converted to –xatomic=studio.
For C++ programs, the atomic support library is linked by default, when needed.
The bundled atomics library libstatomic.so is fully supported as a part of the Oracle Developer Studio product. You can deploy an application that uses the library, but you need to include the library unless the application will run on a system where Oracle Developer Studio is installed.
For example:
./lib
For example:
build-path/import/libstatomic.so
For example:
–R runtime-path build-path-to-atomics/libstatomic.so.1
The following example deploys an application on a 64-bit SPARC platform that does not have Oracle Developer Studio installed.
Before the application is built on the build machine, decide where libstatomic will be located relative to the executable. For example, if your application is located at app_root, and the libstatomic library is in app_root/lib, the relative directory of the library is ./lib.
bash-4.1$ ls app_root/ lib myprog bash-4.1$ ls app_root/lib/ libstatomic.so libstatomic.so.1
On the build machine, determine where libstatomic.so is located. For example, if Oracle Developer Studio is installed in install-dir/, then libstatomic.so is located at install-dir/lib/compilers/atomic/sparcv9/libstatomic.so.
Compile the program, using the following command:
$ install-dir/bin/CC -m64 [compiler-options] -xatomic=none myprog.cc -o myprog -R./lib install-dir/lib/compilers/atomic/sparcv9/libstatomic.so
On the deployment machine, create the package directories.
Then copy the 64-bit libstatomic.so library to app_root/lib.
$ cp install-dir/lib/compilers/atomic/sparcv9/libstatomic.so app_root/lib
Copy the resulting executable for myprog to the app_root directory. This enables the runtime linker to find libstatomic.so under ./lib when myprog is executed.
$ cp myprog.out app_root