Flang command line argument reference

Introduction

-dumpmachine

Display the compiler’s target processor

-dumpversion

Display the version of the compiler

-fopenmp-targets=<arg1>,<arg2>...

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

-fppc-native-vector-element-order, -fno-ppc-native-vector-element-order

Specifies PowerPC native vector element order (default)

-fstack-arrays, -fno-stack-arrays

Attempt to allocate array temporaries on the stack, no matter their size

-fversion-loops-for-stride, -fno-version-loops-for-stride

Create unit-strided versions of loops

-gpulibc

Link the LLVM C Library for GPUs

-help, --help

Display available options

--help-hidden

Display help for hidden options

-mllvm <arg>, -mllvm=<arg>

Additional arguments to forward to LLVM’s option processing

-mmlir <arg>

Additional arguments to forward to MLIR’s option processing

-module-dir<dir>, -J<arg>

This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to be searched by an USE statement. The default is the current directory.

-nogpulib

Do not link device library for CUDA/HIP device compilation

-nogpulibc
-nopie
-o<file>

Write output to <file>

-print-effective-triple, --print-effective-triple

Print the effective target triple

-print-target-triple, --print-target-triple

Print the normalized target triple

-pthread, -no-pthread

Support POSIX threads in generated code

-save-temps=<arg>, --save-temps=<arg>, -save-temps (equivalent to -save-temps=cwd), --save-temps (equivalent to -save-temps=cwd)

Save intermediate compilation results.

--sysroot=<arg>
--target=<arg>, -target <arg>

Generate code for the given target

-v

Show commands to run and use verbose output

--version

Print version information

-x<language>

Treat subsequent input files as having type <language>

Actions

The action to perform on the input.

-E

Only run the preprocessor

-S

Only run preprocess and compilation steps

-c

Only run preprocess, compile, and assemble steps

-emit-llvm

Use the LLVM representation for assembler and object files

-fsyntax-only

Run the preprocessor, parser and semantic analysis stages

Compilation options

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

-Xflang <arg>

Pass <arg> to the flang compiler

-std=<arg>, --std=<arg>

Language standard to compile for

Preprocessor options

Flags controlling the behavior of the Clang preprocessor.

-D<macro>=<value>

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

-P

Disable linemarker output in -E mode

-U<macro>

Undefine macro <macro>

Include path management

Flags controlling how #includes are resolved to files.

-I<dir>

Add directory to include search path. For C++ inputs, if there are multiple -I options, these directories are searched in the order they are given before the standard system directories are searched. If the same directory is in the SYSTEM include search paths, for example if also specified with -isystem, the -I option will be ignored

-isysroot<dir>

Set the system root directory (usually /)

Diagnostic options

Flags controlling which warnings, errors, and remarks Clang will generate. See the full list of warning and remark flags.

-R<remark>

Enable the specified remark

-Rpass-analysis=<arg>

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

-Rpass-missed=<arg>

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

-Rpass=<arg>

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

-W<warning>

Enable the specified warning

Target-independent compilation options

-cpp

Enable predefined and command line preprocessor macros

-fPIC, -fno-PIC
-fPIE, -fno-PIE
-falternative-parameter-statement

Enable the old style PARAMETER statement

-fapprox-func, -fno-approx-func

Allow certain math function calls to be replaced with an approximately equivalent calculation

-fassociative-math, -fno-associative-math
-fbackslash, -fno-backslash

Specify that backslash in string introduces an escape character

-fcolor-diagnostics, -fno-color-diagnostics

Enable colors in diagnostics

-fconvert=<arg>

Set endian conversion of data for unformatted files

-fdefault-double-8

Set the default double precision kind to an 8 byte wide type

-fdefault-integer-8

Set the default integer and logical kind to an 8 byte wide type

-fdefault-real-8

Set the default real kind to an 8 byte wide type

-ffast-math, -fno-fast-math

Allow aggressive, lossy floating-point optimizations

-ffixed-form

Process source files in fixed form

-ffixed-line-length=<arg>, -ffixed-line-length-<arg>

Set column after which characters are ignored in typical fixed-form lines in the source file

-ffp-contract=<arg>

Form fused FP ops (e.g. FMAs): fast (fuses across statements disregarding pragmas) | on (only fuses in the same statement unless dictated by pragmas) | off (never fuses) | fast-honor-pragmas (fuses across statements unless dictated by pragmas). Default is ‘fast’ for CUDA, ‘fast-honor-pragmas’ for HIP, and ‘on’ otherwise. <arg> must be ‘fast’, ‘on’, ‘off’ or ‘fast-honor-pragmas’.

-ffree-form

Process source files in free form

-fhonor-infinities, -fno-honor-infinities

Specify that floating-point optimizations are not allowed that assume arguments and results are not +-inf.

-fhonor-nans, -fno-honor-nans

Specify that floating-point optimizations are not allowed that assume arguments and results are not NANs.

-fimplicit-none, -fno-implicit-none

No implicit typing allowed unless overridden by IMPLICIT statements

-finput-charset=<arg>

Specify the default character set for source files

-fintegrated-as, -fno-integrated-as

Enable the integrated assembler

-fintrinsic-modules-path <dir>
This option specifies the location of pre-compiled intrinsic modules,

if they are not in the default location expected by the compiler.

-flarge-sizes

Use INTEGER(KIND=8) for the result type in size-related intrinsics

-flogical-abbreviations, -fno-logical-abbreviations

Enable logical abbreviations

-flto=<arg>, -flto (equivalent to -flto=full), -flto=auto (equivalent to -flto=full), -flto=jobserver (equivalent to -flto=full)

Set LTO mode. <arg> must be ‘thin’ or ‘full’.

-fms-runtime-lib=<arg>

Specify Visual Studio C runtime library. “static” and “static_dbg” correspond to the cl flags /MT and /MTd which use the multithread, static version. “dll” and “dll_dbg” correspond to the cl flags /MD and /MDd which use the multithread, dll version. <arg> must be ‘static’, ‘static_dbg’, ‘dll’ or ‘dll_dbg’.

-fno-fortran-main

Do not include Fortran_main.a (provided by Flang) when linking

-fomit-frame-pointer, -fno-omit-frame-pointer

Omit the frame pointer from functions that don’t need it. Some stack unwinding cases, such as profilers and sanitizers, may prefer specifying -fno-omit-frame-pointer. On many targets, -O1 and higher omit the frame pointer by default. -m[no-]omit-leaf-frame-pointer takes precedence for leaf functions

-fopenacc

Enable OpenACC

-fopenmp

Parse OpenMP pragmas and generate parallel code.

-fopenmp-target-debug, -fno-openmp-target-debug

Enable debugging in the OpenMP offloading device RTL

-fopenmp-version=<arg>

Set OpenMP version (e.g. 45 for OpenMP 4.5, 51 for OpenMP 5.1). Default value is 51 for Clang

-foptimization-record-file=<file>

Specify the output name of the file containing the optimization remarks. Implies -fsave-optimization-record. On Darwin platforms, this cannot be used with multiple -arch <arch> options.

-foptimization-record-passes=<regex>

Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)

-fpass-plugin=<dsopath>

Load pass plugin from a dynamic shared object file (only with new pass manager).

-fpic, -fno-pic
-fpie, -fno-pie
-freciprocal-math, -fno-reciprocal-math

Allow division operations to be reassociated

-fropi, -fno-ropi

Generate read-only position independent code (ARM only)

-frwpi, -fno-rwpi

Generate read-write position independent code (ARM only)

-fsave-optimization-record, -fno-save-optimization-record

Generate a YAML optimization record file

-fsave-optimization-record=<format>

Generate an optimization record file in a specific format

-fsigned-zeros, -fno-signed-zeros
-funderscoring, -fno-underscoring

Appends one trailing underscore to external names

-fuse-ld=<arg>
-fveclib=<arg>

Use the given vector functions library. <arg> must be ‘Accelerate’, ‘libmvec’, ‘MASSV’, ‘SVML’, ‘SLEEF’, ‘Darwin_libsystem_m’, ‘ArmPL’ or ‘none’.

-fxor-operator, -fno-xor-operator

Enable .XOR. as a synonym of .NEQV.

-nocpp

Disable predefined and command line preprocessor macros

-pedantic, --pedantic

Warn on language extensions

Common Offloading options

--offload-arch=<arg>, --no-offload-arch=<arg>

Specify an offloading device architecture for CUDA, HIP, or OpenMP. (e.g. sm_35). If ‘native’ is used the compiler will detect locally installed architectures. For HIP offloading, the device architecture can be followed by target ID features delimited by a colon (e.g. gfx908:xnack+:sramecc-). May be specified more than once.

--offload-device-only

Only compile for the offloading device.

--offload-host-device

Compile for both the offloading host and device (default).

--offload-host-only

Only compile for the offloading host.

Target-dependent compilation options

-march=<arg>

For a list of available architectures for the target use ‘-mcpu=help’

-mcode-object-version=<arg>

Specify code object ABI version. Defaults to 5. (AMDGPU only). <arg> must be ‘none’, ‘4’ or ‘5’.

-mcpu=<arg>

For a list of available CPUs for the target use ‘-mcpu=help’

-mdynamic-no-pic<arg>
-mrvv-vector-bits=<arg>

Defaults to the vector length agnostic value of “scalable”. Accepts power of 2 values between 64 and 65536. Also accepts “zvl” to use the value implied by -march/-mcpu. On Clang, value will be reflected in __riscv_v_fixed_vlen preprocessor define (RISC-V only)

AARCH64

-msve-vector-bits=<arg>

Specify the size in bits of an SVE vector register. Defaults to the vector length agnostic value of “scalable”. (AArch64 only)

Optimization level

Flags controlling how much optimization should be performed.

-O<arg>
-Ofast<arg>

Debug information generation

Flags controlling how much and what kind of debug information should be generated.

Kind and level of debug information

-g

Generate source-level debug information

Debug level
-g0
-g2
-g3
-gline-directives-only

Emit debug line info directives only

-gline-tables-only, -g1

Emit debug line number tables only

Linker options

Flags that are passed on to the linker

-L<dir>

Add directory to library search path

-Wl,<arg>,<arg2>...

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

-l<arg>
-rdynamic
-rpath <arg>
-shared, --shared
-static, --static