xlc gxlc | C compiler. gxlc will accept GNU C compiler options. |
xlc++ xlC gxlc++ gxlC | C++ compiler.
gxlc++/gxlC will accept GNU C++ compiler options. |
xlf xlf90 xlf95 | Fortran compiler. |
mpxlc mpxlC mpxlf mpxlf90 |
Like above compilers, but will automatically links with the MPI and LAPI libraries. |
Now the compiler...
Compile
-c | Compile *.c and assemble *.s. NO linking. |
-Idir | Also search dir for header files. This can also be controlled by environmental variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH. |
-S | Compile *.c into assembly codes *.s. NO linking. |
-E | Run preprocessor only. The output is sent to stdout. |
-C | When running preprocessor, don't discard comments in the program. |
-qshowmacros=pre | Display definitions of built-in macros |
-o file | Place output in file |
-v -V | When compiling, also display the programs invoked by the compiler. |
-# | Like -v, but do NOT invoke the programs. |
-qphsinfo | When compiling, display what functions it's compiling and time/memory used in preprocessing/parsing etc. |
-qversion | Print the version number. |
-Bprefix | Search prefix for IBM XL Compiler executables. |
-qpath=prog=path | Search path for IBM XL Compiler executable prog, where prog can be a (assembler), l (linker) ... |
C/C++ dialect
-qlanglvl=s | Determine the language standard. s can be classic, extended (this is default for C), stdc89, stdc99, extc89 (this is default for C++), extc99 ... |
-qsmp | Enable OpenMP.
To use this option , one must invoke the compiler with one of the _r-suffix variations of the compiler name. __IBMSMP__ will be defined. |
-qchars=signed -qchars=unsigned | Whether by default char is signed or unsigned.
__CHAR_SIGNED__ or __CHAR_UNSIGNED__ will be defined. |
-qkeyword=asm -qasm=gcc | Support GCC inline assembly. |
-qtls | Support the thread-local storage keyword __thread. |
Preprocessor
-Dname -Dname=value |
Predefine the macro name, with value 1, or with the specified value |
-Uname | Un-define the (built-in or -D defined) macro name |
-M -qnakedep=gcc | Output a rule (to stdout) suitable for Makefile describing the dependencies of the source file. |
-MF file | The output of -M is written to file. |
Warning messages
-qinfo=all | Enable all information and warnings. |
-w | Suppress all warnings. |
-qmaxerr=num | Stop after first num errors. |
Link
-Ldir | Also search dir for library files. This can also be controlled by environmental variable LIBRARY_PATH. |
-llibrary | Link to liblibrary The linker searches libraries and object files in the order they are specified, so foo.o -lz bar.owill search library z after file foo.o but before bar.o, so if bar.o refers to functions in z, then -lz must appear AFTER bar.o |
-s | Remove all symbol information from the executable
|
-qstaticlink | Produce statically linked executables.
|
-qstaticlink=libgcc | Link to libgcc statically. |
-qmkshrobj | Produce shared libraries. |
-qnocrt | Don't link to the standard startup files.
|
-qnolib | Don't link to the standard system libraries. |
Debugging & Profiling
-g | Produce debugging information. |
-pg | Produce profiling information for gprof. |
-qoptdebug | Produce useful debugging information when optimization options are in effect. |
-qfullpath | Store full path information when used with -g option. |
-qlinedebug | Store line number and source file information when used with -g option. |
-qheapdebug | Enable debug versions of memory management functions. |
-qcheck=opt1:opt2 .. | Generate code to perform various runtime checks.
opt can be all, bounds, divzero, nullptr. |
-qfunctrace -qfunctrace=fun | Enable tracing for a specific list of functions
fun (a colon-separate list of symbol names.)
The user will need to implement the following two functions: __func_trace_enter and __func_trace_exit. |
Optimization
-O0 | Don't optimize. This is default. |
-O2 -O | Optimize.
__OPTIMIZE__ will be defined. |
-O3 | Optimize more. This level of optimization has the potential to alter the semantics of the program. |
-O4 | Optimize yet more. It will also optimize for architecture of the compiling machine (-qarch, -qtune, -qcache), perform link time/inter-procedural optimization (-qipa) and high-order transformation loop optimization (-qhot) |
-O5 | The same as -O4 -qipa=level=2 |
-qreport | Show diagnostic information about automatic loop parallelization and other optimizations during compilation. |
-qcompact | Optimize for code size.
__OPTIMIZE_SIZE__ will be defined. |
-qstrict -qstrict=opt1:opt2 .. | Disable optimizations which have the potential to alter the semantics of the program.
opt can be all, precision, exception, ieeefp, nans, infinities, subnormals, zerosigns, operationprecision, vectorprecision, order, association, reductionorder, guards, library, constructcopy |
-Q -qinline | Inline all functions that it can. |
-qpdf1 -qpdf2 -qfdpr | Profile guided optimization (PGO). FDPR is Feedback Directed Program Restructuring performance-tuning utility needs to optimize the resulting executable. |
-qipa | Link time/inter-procedural optimization. |
-qhot | High-order transformation loop optimization. |
-qsmp | Automatic parallelization. To use this option , one must invoke the compiler with one of the _r-suffix variations of the compiler name. __IBMSMP__ will be defined. |
-qarch=cpu -qarch=auto | Generate code for specific cpu, , e.g. ppc, ppc64, ppc970, pwr3, pwr4, pwr5, pwr6 .. |
-qtune=cpu -qtune=auto | Tune for specific cpu, e.g. ppc970, pwr3, pwr4, pwr5, pwr6 .. |
-q64 | Generate 64-bit code.
__64BIT__ will be defined. |
-qaltivec | Generate code using AltiVec SIMD extensions.
__ALTIVEC__ will be defined. |
-qsimd=auto | (Fortran) Generate code using SIMD extensions/vector instructions. |
-qflttrap=opt1:opt2 .. | Generate code to detect floating-point exceptions at runtime.
opt can be enable, overflow, underflow, zerodivide, invalid, inexact, imprecise, nanq, nonanq. |
-qfloat=opt1:opt2 .. | Generate code for various floating-point calculation strategies.
opt can be fltint (floating-point-to-integer conversions with faster inline code that does not check for overflows), fold (constant floating-point expressions are to be evaluated at compile time), maf (fused multiply/add), nan (detect NaN), relax (less conformance with the IEEE 754 standard)... |
-qieee=mode | (Fortran) Specify the rounding mode, which can be Near, Minus, Plus, Zero. |
-qessl | (Fortran) Use IBM's Engineering and Scientific Subroutine Library (ESSL) routines in place of Fortran 90 intrinsic procedures. |
-qlargepage | Optimize for the huge page support on POWER4 and higher systems. |
Interesting features
-qsaveopt | Save compiler version number and compiler options in the binary executable. |
IBM XL C/C++ Compiler built-in macros
One can usecc -qshowmacros -E foo.cto see all built-in macros and their values.
__cplusplus | Is defined if C++ compiler is in use.
This is ANSI C standard macro |
|
__FILE__ __BASE_FILE__ |
Name of the current input file (as a C string constant)
This is ANSI C standard macro. |
|
__LINE__ | Current input line number (as an integer constant)
This is ANSI C standard macro |
|
__FUNCTION__ | If inside a function, the current function name (as a C string constant)
This is ANSI C99 standard macro |
|
__DATE__ __TIME__ |
Date & time on which the preprocessor is run. (as C string constants)
These are ANSI C standard macros. | |
__TIMESTAMP__ | Last modification time of the input file (as a C string constant) | |
__STDC__ __STDC_VERSION__ |
Evaluate to 1 to mean the compiler is ISO standard conformant. __STDC_VERSION__ evaluates to a C string constant of the form of the form yyyymmL. __STDC__ is an ANSI C standard macro. |
|
__IBMC__ __IBMCPP__ |
Evaluate to integer constants representing the IBM XL C/C++ compiler version numbers (version/release/modification), e.g. version 10.1 will evaluate to 1010. | |
__xlc__ __xlC__ |
Evaluate to a C string constant representing the IBM XL C/C++ compiler version numbers (version/release/modification), e.g. version 10.1 will evaluate to 10.1.0.0. | |
__BIG_ENDIAN__ | Evaluate to 1 to indicate the endian-ness | |
__powerpc__ __PPC__ |
Evaluate to 1 to indicate the architecture | |
__ALTIVEC__ __VEC__ |
Defined if -qaltivec option is enabled. | |
__64BIT__ | Defined if 64-bit compilation mode is in effect. | |
__OPTIMIZE__ __OPTIMIZE_SIZE__ |
Defined if any optimization is enabled. Furthermore, __OPTIMIZE_SIZE__ is defined if the optimization is for size. |
|
__IBMSMP__ _IBMSMP |
Defined if -qsmp option is enabled. |
IBM XL C/C++ Compiler built-in functions
A complete list is here
__builtin_expect | Provide branch prediction hint to the compiler. |
__compare_and_swap __compare_and_swaplp __fetch_and_XXX __fetch_and_XXXlp __ldarx __lwarx __stdcx __stwcx |
Built-in atomic memory access
functions. XXX can be and, or, swap. |
__dcbf __dcbfl |
Flush cache of the given memory region. |
__prefetch_by_load __prefetch_by_stream |
Prefetch data in the given memory region. |
__builtin_return_address(lvl) | Get the address of the caller at call chain level lvl. |
IBM XL C/C++ Compiler #pragma directives
A complete list is here
#pragma init | Declare the designated function to be called before main is invoked. |
#pragma fini | Declare the designated function to be called after exit is invoked. |