Visible to Intel only — GUID: GUID-31EAE8BD-7D6D-40D4-9336-6BE0E266543F
Visible to Intel only — GUID: GUID-31EAE8BD-7D6D-40D4-9336-6BE0E266543F
Use Compiler Options
A compiler option is a case-sensitive, command line expression used to change the compiler's default operation. Compiler options are not required to compile your program, but they can control different aspects of your application, such as:
- Code generation
- Optimization
- Output file (type, name, location)
- Linking properties
- Size of the executable
- Speed of the executable
Linux and macOS
When you specify compiler options on the command line, the following syntax applies:
[invocation] [option] [@response_file] file1 [file2...]
The invocation is icc.
The option represents zero or more compiler options and the file is any of the following:
- C or C++ source file (.C, .c, .cc, .cpp, .cxx, .c++, .i, .ii)
- Assembly file (.s, .S)
- Object file (.o)
- Static library (.a)
When compiling C language sources, invoke the compiler with icc. When compiling C++ language sources or a combination of C and C++, invoke the compiler with icpc.
Windows
When you specify compiler options on the command line, the following syntax applies:
[invocation] [option] [@response_file] file1 [file2 ...] [/link linker_option]
The invocation is icl.
The option represents zero or more compiler options, the linker_option represents zero or more linker options, and the file is any of the following:
- C or C++ source file (.c, .cc, .ccp, .cxx, .i)
- Assembly file (.asm)
- Object (.obj)
- Static library (.lib)
The optional response_file is a text file that lists the compiler options you want to include during compilation. See Use Response Files for additional information.
Default Operation
The compiler invokes many options by default. In this example, the compiler includes the option O2 (and other default options) in the compilation. Using C++ as an example:
Linux and macOS
icpx main.c
Windows
icx main.c
Each time you invoke the compiler, options listed in the corresponding configuration file override any competing default options. For example, if your configuration file includes the O3 option, the compiler uses O3 rather than the default O2 option. Use the configuration file to list the options for the compiler to use for every compilation. See Using Configuration Files.
Options specified in the command line environment variable override any competing default options and options listed in the configuration file.
Finally, options used on the command line override any competing options that may be specified elsewhere (default options, options in the configuration file, and options specified in the command line environment variable). If you specify the option O1 this option setting takes precedence over competing option defaults and competing options in the configuration files, in addition to the competing options in the command line environment variable.
Certain #pragma statements in your source code can override competing options specified on the command line. If a function in your code is preceded by #pragma optimize("", off), then optimization for that function is turned off. The override is valid even when the O2 optimization is on by default, the O3 is listed in the configuration file, and the O1 is specified on the command line for the rest of the program.
Use Competing Options
The compiler reads command line options from left to right. If your compilation includes competing options, then the compiler uses the one furthest to the right. Using C++ as an example:
Linux and macOS
icpc –xSSSE3 main.c file1.c –xSSE4.2 file2.c
Windows
icl /QxSSSE3 main.c file1.c /QxSSE4.2 file2.c
The compiler sees [Q]xSSSE3 and [Q]xSSE4.2 as two forms of the same option, where only one form can be used. Since [Q]xSSE4.2 is last (furthest to the right), it will be used.
All options specified on the command line are used to compile each file. The compiler does not compile individual files with specific options. For example:
Linux and macOS
icc -O3 main.c file1.c -mp1 file2.c
Windows
icl /O3 main.c file1.c /Qprec file2.c
It may seem that main.c and file1.c are compiled with the option O3, and file2.c is compiled with the -mp1 (Linux and macOS) or /Qprec (Windows) option. This is not correct; all files are compiled with both options.
A rare exception to this rule is the -x type option on Linux and macOS. Using C++ as an example:
Linux and macOS
icpc -x c file1 -x c++ file2 -x assembler file3
The type argument identifies each file type for the compiler.
Use Options with Arguments
Compiler options can be as simple as a single letter, such as the option E. Many options accept or require arguments. The O option, for example, accepts a single-value argument that the compiler uses to determine the degree of optimization. Other options require at least one argument and can accept multiple arguments. For most options that accept arguments, the compiler warns you if your option and argument are not recognized. If you specify O9, the compiler issues a warning, then ignores the unrecognized option O9, and proceeds with the compilation.
The O option does not require an argument, but there are other options that must include an argument. The I option requires an argument that identifies the directory to add to the include file search path. If you use this option without an argument, the compiler will not finish its compilation.
Other Forms of Options
You can toggle some options on or off by using the negation convention. For example, the [Q]ipo option (and many others) includes negation forms, -no-ipo (Linux and macOS) and /Qipo- (Windows), to change the state of the option.
Option Categories
When you invoke the Intel® C++ Compiler Classic and specify a compiler option, you have a wide range of choices to influence the compiler's default operation. Intel® C++ Compiler Classic options typically correspond to one or more of the following categories:
- Advanced Optimization
- Code Generation
- Compatibility
- Compiler Diagnostics
- Component Control
- Data
- Floating Point
- Inlining
- Interprocedural Optimizations (IPO)
- Language
- Linking/Linker
- Miscellaneous
- OpenMP and Parallel Processing
- Optimization
- Optimization Report
- Output
- Preprocessor
To see the included options in each category, invoke the compiler from the command line with the help category option. For example:
Linux and macOS
icc -help codegen
Windows
icl /help codegen
The help option prints to stdout with the names and syntax of the options found in the Code Generation category.