Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ClangCommandLineReference.rst 62.75 KiB

Clang command line argument reference

Introduction

This page lists the command line arguments currently supported by the GCC-compatible clang and clang++ drivers.

Add <dir> to search path for binaries and object files used implicitly

Add directory to framework include search path

Treat source input files as Objective-C inputs

Treat source input files as Objective-C++ inputs

Don't emit warning for unused driver arguments

Pass the comma separated arguments in <arg> to the assembler

Pass <arg> to fatbinary invocation

Pass <arg> to the ptxas assembler

Pass <arg> to the target offloading toolchain.

Pass <arg> to the specified target offloading toolchain. The triple that identifies the toolchain must be provided after the equals sign.

Run the static analyzer

Static analyzer report output format (html|plist|plist-multi-file|plist-html|text).

Emit ARC errors even if the migrator can fix them

Output path for the plist report

Specifies configuration file

Compile CUDA code for both host and device (default). Has no effect on non-CUDA compilations.

Compile CUDA code for device only

CUDA GPU architecture (e.g. sm_35). May be specified more than once.

Compile CUDA code for host only. Has no effect on non-CUDA compilations.

Enable device-side debug info generation. Disables ptxas optimizations.

Filename to write DOT-formatted header dependencies to

Filename (or -) to write dependency output to

Emit Clang AST files for source inputs

Use approximate transcendental functions

Flush denormal floating point values to zero in CUDA device mode.

Specify comma-separated list of triples OpenMP offloading targets to be supported

Add -rpath with architecture-specific resource directory to the linker flags

Use the gcc toolchain at the given directory

Generate CodeView debug information

Display available options

Make the next included directory (-I or -F) an indexer header map

Run the migrator

Additional arguments to forward to LLVM's option processing

Directory to dump module dependencies to

Don't error out if the detected version of the CUDA install is too low for the requested CUDA gpu architecture.

Disable builtin #include directories

Disable standard #include directories for the C++ standard library

Write output to <file>

Make migration to 'atomic' properties

Enable migration to modern ObjC

Enable migration to property and method annotations

Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods

Enable migration to infer instancetype for method result type

Enable migration to modern ObjC literals

Enable migration to NS_ENUM/NS_OPTIONS macros

Enable migration to modern ObjC property

Enable migration of setter/getter messages to property-dot syntax

Enable migration to add protocol conformance on classes

Enable migration to modern ObjC readonly property

Enable migration to modern ObjC readwrite property

Enable migration to modern ObjC subscripting

Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute

Enable migration to annotate property with NS_RETURNS_INNER_POINTER

Only modify files with a filename contained in the provided directory path

Enable mcount instrumentation

Use pipes between commands, when possible

Print the full library path of <file>

Enable Objective-C Ivar layout bitmap print trace

Print the library path for the currently used compiler runtime library ("libgcc.a" or "libclang_rt.builtins.*.a")

Print the full program path of <name>

Print the resource directory pathname

Print the paths used for finding libraries and programs

Support POSIX threads in generated code

Whether to build a relocatable precompiled header

Rewrite Legacy Objective-C source to C++

Compiler runtime library to use

Save llvm statistics.

Save intermediate compilation results.

Serialize compiler diagnostics to a file

C++ standard library to use

Generate code for the given target

Time individual commands

Enable some traditional CPP emulation

Show commands to run and use verbose output

Verify the binary representation of debug output

Print version information

Suppress all warnings

Resolve file paths relative to the specified directory

Treat subsequent input files as having type <language>

Actions

The action to perform on the input.

Only run the preprocessor

Only run preprocess and compilation steps

Only run preprocess, compile, and assemble steps

Use the LLVM representation for assembler and object files

Provide information about a particular module file

Only precompile the input

Rewrite Objective-C source to C++

Load and verify that a pre-compiled header file is not stale

Compilation flags

Flags controlling the behavior of Clang during compilation. These flags have no effect during actions that do not perform compilation.

Pass <arg> to the assembler

Pass <arg> to the clang compiler

Attempt to match the ABI of Clang <version>

Treat each comma separated argument in <arg> as a documentation comment block command

Allow __declspec as a keyword

Print fix-its in machine parseable form

Print source range spans in numeric form

Enables an experimental new pass manager in LLVM.

Use separate accesses for bitfields with legal widths and alignments.

Inline suitable functions

Inline functions which are (explicitly or implicitly) marked inline

Disable auto-generation of preprocessed source files and a script for reproduction during a clang crash

Don't use blacklist file for sanitizers

Level of field padding for AddressSanitizer

Enable linker dead stripping of globals in AddressSanitizer

Enable use-after-scope detection in AddressSanitizer

Path to blacklist file for sanitizers

Enable control flow integrity (CFI) checks for cross-DSO calls.

Generalize pointers in CFI indirect call type signature checks

Specify the type of coverage instrumentation for Sanitizers

Enable origins tracking in MemorySanitizer

Enable origins tracking in MemorySanitizer

Enable use-after-destroy detection in MemorySanitizer

Enable recovery for specified sanitizers

Enable sanitizer statistics gathering.

Enable atomic operations instrumentation in ThreadSanitizer (default)

Enable function entry/exit instrumentation in ThreadSanitizer (default)

Enable memory access instrumentation in ThreadSanitizer (default)

Enable trapping for specified sanitizers

Strip (or keep only, if negative) a given number of path components when emitting check metadata.

Turn on runtime checks for various forms of undefined or suspicious behavior. See user manual for available checks

Language standard to compile for

Preprocessor flags

Flags controlling the behavior of the Clang preprocessor.

Include comments in preprocessed output

Include comments from within macros in preprocessed output

Define <macro> to <value> (or 1 if <value> omitted)

Show header includes and nesting depth

Disable linemarker output in -E mode

Undefine macro <macro>

Pass the comma separated arguments in <arg> to the preprocessor

Pass <arg> to the preprocessor

Include path management

Flags controlling how #includes are resolved to files.

Add directory to include search path

Restrict all prior -I flags to double-quoted inclusion and remove current directory from include path

CUDA installation path

Add directory to the C++ SYSTEM include search path

Use the last modification time of <file> as the build session timestamp

Time when the current build session started

Specify the mapping of module name to precompiled module file, or load a module file if name is omitted.

Specify the module cache path

Disable validation of the diagnostic options when loading the module

Specify the interval (in seconds) after which a module file will be considered unused

Specify the interval (in seconds) between attempts to prune the module cache

Specify the module user build path

Don't verify input files for the modules if the module has been successfully validated or loaded during this build session

Validate the system headers that a module depends on when loading the module

Specify the prebuilt module path

Add directory to AFTER include search path

Add directory to SYSTEM framework search path

Add directory to SYSTEM framework search path, absolute paths are relative to -isysroot

Include macros from file before parsing

Include file before parsing

Include precompiled header file

Set the -iwithprefix/-iwithprefixbefore prefix

Add directory to QUOTE include search path

Set the system root directory (usually /)

Add directory to SYSTEM include search path

Add directory to end of the SYSTEM include search path

Overlay the virtual filesystem described by file over the real file system

Set directory to SYSTEM include search path with prefix

Set directory to include search path with prefix

Add directory to SYSTEM include search path, absolute paths are relative to -isysroot

Path to ptxas (used for compiling CUDA code)

Treat all #include paths starting with <prefix> as including a system header.

Dependency file generation

Flags controlling generation of a dependency file for make-like build systems.

Like -MD, but also implies -E and writes to stdout by default

Write a depfile containing user and system headers

Write depfile output from -MMD, -MD, -MM, or -M to <file>

Add missing headers to depfile

Write a compilation database entry per input

Like -MMD, but also implies -E and writes to stdout by default

Write a depfile containing user headers

Create phony target for each dependency (other than main file)

Specify name of main file output to quote in depfile

Specify name of main file output in depfile

Use NMake/Jom format for the depfile

Dumping preprocessor state

Flags allowing the state of the preprocessor to be dumped in various ways.

Print macro definitions in -E mode in addition to normal output

Print include directives in -E mode in addition to normal output

Print macro definitions in -E mode instead of normal output

Diagnostic flags

Flags controlling which warnings, errors, and remarks Clang will generate. See the :doc:`full list of warning and remark flags <DiagnosticsReference>`.

Enable the specified remark

Report transformation analysis from optimization passes whose name matches the given POSIX regular expression

Report missed transformations by optimization passes whose name matches the given POSIX regular expression

Report transformations performed by optimization passes whose name matches the given POSIX regular expression

Enable the specified warning

Enable warnings for deprecated constructs and define __DEPRECATED

Target-independent compilation options

Enable C++17 aligned allocation functions

Treat editor placeholders as valid source code

Use ANSI escape codes for diagnostics

Use Apple's kernel extensions ABI

Enable Apple gcc-compatible #pragma pack handling

Restrict code to those available for App Extensions

Enable the 'blocks' language feature

Accept non-standard constructs supported by the Borland compiler

Load the clang builtins module map file.

Use colors in diagnostics

Enable support for the C++ Coroutines TS

Generate coverage mapping to enable code coverage analysis

Enable C++ exceptions

Place each data in its own section (ELF Only)

Emit extra debug info to make sample profile more accurate.

Emit macro debug information

remap file source paths in debug info

Place debug types in their own section (ELF Only)

Parse templated function definitions at the end of the translation unit

Print absolute paths in diagnostics

Prevent optimization remarks from being output if they do not have at least this profile count

Enable profile hotness information in diagnostic line

Display include stacks for diagnostic notes

Print option name with mappable diagnostics

Print a template comparison tree for differing templates

Allow '$' in identifiers

Enable '[[]]' attributes in all C and C++ language modes

Use DWARF style exceptions

Embed LLVM bitcode (option: off, all, bitcode, marker)

Emit all declarations, even if unused

Use emutls functions to access thread_local variables

Enable support for exception handling

Allow aggressive, lossy floating-point optimizations

Form fused FP ops (e.g. FMAs): fast (everywhere) | on (according to FP_CONTRACT pragma, default) | off (never fuse)

Assert that the compilation takes place in a freestanding environment

Place each function in its own section (ELF Only)

Allow GNU-extension keywords regardless of language standard

Generate output compatible with the standard GNU Objective-C runtime

Use the gnu89 inline semantics

Implicitly search the file system for module map files.

Instrument function entry only, after inlining, without arguments to the instrumentation call

Generate calls to instrument function entry and exit

Like -finstrument-functions, but insert the calls after inlining

Enable the integrated assembler

Enable LTO in 'full' mode

Controls the backend parallelism of -flto=thin (default of 0 means the number of threads will be derived from the number of CPUs detected)

Set LTO mode to either 'full' or 'thin'

Require math functions to indicate errors by setting errno

Specify the maximum alignment to enforce on pointers lacking an explicit alignment

Load this module map file

Specify the name of the module to build

Enable the 'modules' language feature

Require declaration of modules used within a module

Ignore the definition of the given macro when building and loading modules

Search even non-imported modules to resolve references

Like -fmodules-decluse but requires all headers to be in modules

Enable support for the C++ Modules TS

Enable full Microsoft Visual C++ compatibility

Dot-separated value representing the Microsoft compiler version number to report in _MSC_VER (0 = don't define it (default))

Accept some non-standard constructs supported by the Microsoft compiler

Microsoft compiler version number to report in _MSC_VER (0 = don't define it (default))

Specifies the largest alignment guaranteed by '::operator new(size_t)'

Disable implicit builtin knowledge of a specific function

Do not elide types when printing diagnostics

Do not treat C++ operator name keywords as synonyms for operators

Do not compile OpenMP target code as relocatable.

Synthesize retain and release calls for Objective-C pointers

Use EH-safe code when synthesizing retains and releases in -fobjc-arc

Enable Objective-C exceptions

Specify the target Objective-C runtime kind and version

Enable ARC-style weak references in Objective-C

OpenMP target code is compiled as relocatable using the -c flag. For OpenMP targets the code is relocatable by default.

Emit OpenMP code only for SIMD-based constructs.

Specify the file name of any generated YAML optimization record

Specify the default maximum struct packing alignment

Recognize and construct Pascal-style string literals

Override the default ABI to return all structs on the stack

Use the PLT to make function calls

Load the named plugin (dynamic shared object)

Generate instrumented code to collect execution counts into default.profraw (overridden by LLVM_PROFILE_FILE env var)

Generate instrumented code to collect execution counts into <directory>/default.profraw (overridden by LLVM_PROFILE_FILE env var)

Generate instrumented code to collect execution counts into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)

Generate instrumented code to collect execution counts into <file> (overridden by LLVM_PROFILE_FILE env var)

Use instrumentation data for profile-guided optimization

Specifies that the sample profile is accurate. If the sample
profile is accurate, callsites without profile samples are marked as cold. Otherwise, treat callsites without profile samples as if we have no profile

Enable sample-based profile guided optimizations

Use instrumentation data for profile-guided optimization. If pathname is a directory, it reads from <pathname>/default.profdata. Otherwise, it reads from file <pathname>.

Allow division operations to be reassociated

Override the default ABI to return small structs in registers

Enable C++17 relaxed template template argument matching

Turn on loop reroller

Generate a YAML optimization record file

Use SEH style exceptions

Allocate to an enum type only as many bytes as it needs for the declared range of possible values

Force wchar_t to be a short unsigned int

Which overload candidates to show when overload resolution fails: best|all; defaults to all

Enable C++14 sized global deallocation functions

Use SjLj style exceptions

Enable the superword-level parallelism vectorization passes

Place debug types in their own section (ELF Only)

Enable stack protectors for functions potentially vulnerable to stack smashing

Force the usage of stack protectors for all functions

Use a strong heuristic to apply stack protectors to functions

Emit full debug info for all types used by the program

Enable optimizations based on the strict definition of an enum's value range

Always treat control flow paths that fall off the end of a non-void function as unreachable

Enable optimizations based on the strict rules for overwriting polymorphic C++ objects

Perform ThinLTO importing using provided function summary index

Issue call to specified function rather than a trap instruction

Trap on integer overflow

Specify the function to be called on overflow

Process trigraph sequences

Use unique names for text and data sections (ELF Only)

Turn on loop unroller

Use .init_array instead of .ctors

Use the given vector functions library

Enable the loop vectorization passes

Give inline C++ member functions default visibility by default

Give global types 'default' visibility and global functions and variables 'hidden' visibility by default

Set the default symbol visibility for all global declarations

Enables whole-program vtable optimization. Requires -flto

Treat signed integer overflow as two's complement

Store string literals as writable data

Determine whether to always emit __xray_customevent(...) calls even if the function it appears in is not always instrumented.

Filename defining the whitelist for imbuing the 'always instrument' XRay attribute.

Sets the minimum function size to instrument with XRay

Generate XRay instrumentation sleds on function entry and exit

Filename defining the whitelist for imbuing the 'never instrument' XRay attribute.

Enable System z vector language extension

OpenCL flags

OpenCL only. Allow denormals to be flushed to zero.

OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__.

OpenCL only. Allow floating-point optimizations that assume arguments and results are not NaNs or +-Inf.

OpenCL only. Specify that single precision floating-point divide and sqrt used in the program source are correctly rounded.

OpenCL only. Generate kernel argument metadata.

OpenCL only. Allow use of less precise MAD computations in the generated binary.

OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.

OpenCL only. This option disables all optimizations. By default optimizations are enabled.

OpenCL only. Treat double precision floating-point constant as single precision constant.

OpenCL language standard to compile for.

OpenCL only. This option is added for compatibility with OpenCL 1.0.

OpenCL only. Allow unsafe floating-point optimizations. Also implies -cl-no-signed-zeros and -cl-mad-enable.

Target-dependent compilation options

Put objects of at most <size> bytes into small data section (MIPS / Hexagon)

Enable SVR4-style position-independent code (Mips only)

Align doubles to two words in structs (x86 only)

Link stack frames through backchain on System Z

Set EABI type, e.g. 4, 5 or gnu (default depends on triple)

Place constants in the .rodata section instead of the .sdata section even if they meet the -G <size> threshold (MIPS)

Assume that externally defined data is in the small data if it meets the -G <size> threshold (MIPS)

Insert calls to fentry at function entry (x86 only)

Use 32-bit floating point registers (MIPS only)

Use 64-bit floating point registers (MIPS only)

Enable merging of globals

Use GP relative accesses for symbols known to be in a small data section (MIPS)

Use Intel MCU ABI

(integrated-as) Emit an object file which can be used with an incremental linker

Extend the -G behaviour to object local data (MIPS)

Generate branches with extended addressability, usually via indirect jumps.

Set Mac OS X deployment target

Enable the generation of 4-operand madd.s, madd.d and related instructions.