Compiling and linking
Multiple compiler suites are available for building and linking application codes, and while they are all share many similarities, it is inevitable that there are also some differences. For example, depending on the type of application, one set of compilers may produce code that performs better than another. Or, certain types of syntax may be accepted by some compilers but not others.
The following compilers are currently available:
Compiling and linking is performed using wrapper scripts ftn,
cc, and CC for source code written in Fortran, C, and C++,
respectively. These wrappers invoke the appropriate compiler based on
the current Programming Environment and produce executables that can be run
on the compute nodes. These wrappers are fairly versatile, and
automatically link in a wide variety of libraries as necessary, including
Cray's Scientific Software Library (libsci) and MPI ( for instance,
-lmpi is not required and will cause the link step to fail). In other
words, do NOT use mpicc (for instance) to compile MPI codes; the cc or CC
wrapper already contains the proper compiler and library invocations.
There are numerous options that can be used to influence the compilation
process. Some of these may produce the same behavior across all
compilers, but many of them are specific to a particular compiler.
Some of the more commonly-used options are listed here (see the compiler
man pages or the Cray
Application Developer's Environment User's Guide for more detailed
|Produce object file only; do not make executable|
|Include symbol table and other information for debugging|
|Displays verbose compiler output|
|Produce a listing file|
|Specify the name of the executable|
|Controls the level of compiler optimization|
|Specifies additional location(s) of header files|
|Specifies additional location(s) of library files|
|Specifies additional libraries to be linked|
The following table provides a comparison of common functionality across compilers.
||High level optimization
|-h omp (default)
at runtime: aprun --cc=none ...
|OpenMP directives and pragmas
||Fortran unformatted data files as big-endian
||Fortran fixed form
||Fortran free form
||Zero fill all uninitialized variables.
|-e m -J dir_name
||Save .mod files to directory dir_name
||RUNTIME OPTIONS For DEBUG/DEVELOPMENT
||require IEEE precision for numeric ops
||-ffpe-trap=... # fortran
||FP traps, see compiler man pages for further info.
-h bounds # c
-R b # fortran
||-fbounds-check # fortran
||check array bounds
There are two ways to enable dynamic linking when using the compiler wrapper scripts with any of the supported compilers.
The first way is to use the '-dynamic' flag. This works in principle but the user has to make sure they reproduce the right runtime environment (LD_LIBRARY_PATH) when running the program.
The second method is to use two environment variables that do both:
so that the application is linked dynamically and the paths to the module libraries are preserved using the '--rpath' linker option.
You will have to still pass the correct '-L' and '-Wl,--rpath,PATH_TO_LIB' options for third party libraries that are not provided by modules since the compiler wrapper does not know about these libraries.