Invoke the C and C++ Compilers
The commands for invoking the C and C++ compilers.
- CC invokes the Cray C++ compiler.
- cc invokes the Cray C compiler.
- cpp, the C language preprocessor, is not part of CCE. The cpp command resolves to the GNU cpp command and does not predefine any Cray compiler-specific macros. If the predefinition of the Cray compiler-specific macros is required, then use the cc or CC command to do the source preprocessing using the -E or -P option.
A successful compilation creates an executable file, named a.out by default, that reflects the contents of the source code and any referenced library functions. Use the aprun command to run the executable on the compute nodes.
Simple C compiler invocation and application execution
% cc mysource.c; aprun -n 64 ./a.outBy default, the CC and cc commands automatically call the linker, which creates an executable file. If only one source file is specified, the object file (*.o) is deleted. If more than one source file is specified, the object files are retained.
Simple C compiler invocation using multiple source files
The following command creates and retains object files file1.o, file2.o, and file3.o, and creates the executable file a.out.
% cc file1.c file2.c file3.cSimple C compiler invocation using single source file
The following command creates file.o and a.out; file.o is not retained.
% cc file1.cCC Command
CC [ -c] [-C] [ -D macro[=def]] [-E] [-g] [-G level ] [-h arg] [ -I incldir] [ -K trap=opt,opt ...] [ -l libfile] [ -L ldir] [ -M] [-nostdinc] [ -o outfile] [-O level] [-P] [-S] [-U macro] [-V] [-Wphase,"opt ..."] [-X npes] [-Yphase, dirname] [-#] [-##] [-###] sourcefile . . .- .c
- .C
- .i
- .c++
- .C++
- .cc
- .cxx
- .Cxx
- .CXX
- .CC
The .i files are created when the preprocessing compiler command option (-P) is used. The CC command also accepts object files with the .o suffix, library files with the .a suffix, and assembler source files with the .s suffix.
cc Command
cc [ -c] [-C] [ -D macro[=def]] [-E] [-g] [-G level ] [-harg ] [ -I incldir] [ -K trap=opt[,opt] ...] [ -l libfile] [ -L ldir] [ -M] [-nostdinc] [ -o outfile] [-O level] [-P] [-S] [-U macro] [-V] [-Wphase,"opt ..."] [-X npes] [-Yphase, dirname] [-#] [-##] [-###] sourcefile . . .The cc command invokes the Cray C compiler. The cc command accepts C source files that have the .c and .i suffixes; object files with the .o suffix; library files with the .a suffix; and assembler source files with the .s suffix.
File Types Used or Created by the Compiler
- a.out
- Default name of the executable output file. Use the compiler driver command line option -o to specify an executable name other than a.out.
- .c, .C, .c++, .C++, .cc, .cxx, .Cxx, .CXX, .CC
- C++ source files
- .c
- C source files
- .i
- Files containing output from the source preprocessor
- .o
- Relocatable object code. During compilation, these relocatable object files are saved in the current directory automatically. If using CrayPat to conduct performance analysis experiments, the object files created during compilation must be kept in order to preserve source-to-executable function mapping. To do so, use the -h keepfiles option.
- .a
- Library files containing external references
- .s
- Assembly language files. Files with .s extensions are assembled and written to the corresponding .o file.
Command Line Examples
The following examples illustrate a variety of command lines for the C and C++ compiler commands:
CC -h conform myprog.C
% CC -h conform myprog.Ccc -c -h ipa1 myprog.c subprog.c
% cc -c -h ipa1 myprog.c subprog.ccc -I. disc.c vend.c
% cc -I. disc.c vend.ccc -P -D DEBUG newprog.c
% cc -P -D DEBUG newprog.ccc -c -h report=s mydata1.c
% cc -c -h report=s mydata1.cCC -h ipa5,report=if myfile.C
% CC -h ipa5,report=if myfile.CCompile Time Environment Variables
- CRAYOLDCPPLIB
- When set to a nonzero value, enables C++ code to use the following nonstandard Cray C++ headers files:
- common.h
- complex.h
- fstream.h
- generic.h
- iomanip.h
- iostream.h
- stdiostream.h
- stream.h
- strstream.h
- vector.h
- CRI_CC_OPTIONS, CRI_cc_OPTIONS
- Specifies command line options that are applied to all compilations. Options specified by this environment variable are added following the options specified directly on the command line. This is especially useful for adding options to compilations done with build tools.
Run Time Environment Variables
- CRAY_MALLOPT_OFF
- If set, then the system default mallopt parameters are used, instead of the compiler default parameters. For most programs, run time performance is improved by using the compiler defaults, but more memory may be used.
- MALLOC_MMAP_MAX_
- Specifies the maximum number of memory chunks to allocate with mmap. The compiler default value is 0. For most programs, run time performance is improved by using the compiler default, but more memory may be used.
- MALLOC_TRIM_THRESHOLD_
- Specifies the minimum size of the unused memory region at the top of the heap before the region is returned to the operating system. The compiler default value is 536870912 bytes. For most programs, run time performance is improved by using the compiler default, but more memory may be used.
- PGAS_ERROR_FILE
- Specifies the location to which libpgas (the library which provides an interface to the internal system network) error messages are written. The default is stderr. If stdout is specified, errors will be written to standard output.
- CRAYLIBS_ARCH_OVERRIDE
-
Override the default Cray math library run time selection and specify the library to use by CPU architecture. The valid options are: haswell, ivybridge, sandybridge, interlagos, abudhabi, interlagos-cu, abudhabi-cu, mc8, mc12, istanbul, shanghai, barcelona, opteron, x86-64, or mic-knl.
This run time environment variable can be used to specify that a lowest-common-denominator math library be used instead of the default selection, thus ensuring that identical computations produce identical results regardless of the type of compute node CPU actually used. The trade-off is that specifying an older library may affect performance on a newer CPU. For example, if ivybridge is specified, the code will run and produce identical results on a haswell compute node, but performance may be reduced.
Default: If not set, the library specific to the type of CPU selected at run time is used.