Flang command line argument reference

Introduction

-B<prefix>

Search $prefix$file for executables, libraries, and data files. If $prefix is a directory, search $prefix/$file

-Qunused-arguments

Don’t emit warning for unused driver arguments

--config=<file>, --config <arg>

Specify configuration file

-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)

-frtlib-add-rpath, -fno-rtlib-add-rpath

Add -rpath with architecture-specific resource directory to the linker flags. When –hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags

-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

--gcc-install-dir=<arg>

Use GCC installation in the specified directory. The directory ends with path components like ‘lib{,32,64}/gcc{,-cross}/$triple/$version’. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation

--gcc-toolchain=<arg>

Specify a directory where Flang can find ‘lib{,32,64}/gcc{,-cross}/$triple/$version’. Flang will use the GCC installation with the largest version

-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.

--no-default-config

Disable loading default configuration files

-nodefaultlibs
-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-resource-dir, --print-resource-dir

Print the resource directory pathname that contains lib and include directories with the runtime libraries and MODULE files.

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

Print the normalized target triple

-pthread, -no-pthread

Support POSIX threads in generated code

-rtlib=<arg>, --rtlib=<arg>

Compiler runtime library to use

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

Save intermediate compilation results. <arg> can be set to ‘cwd’ for current working directory, or ‘obj’ which will save temporary files in the same directory as the final output file

--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

-w, --no-warnings

Suppress all warnings

-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 Flang during compilation. These flags have no effect during actions that do not perform compilation.

-Xflang <arg>

Pass <arg> to the flang compiler

-moutline-atomics, -mno-outline-atomics

Generate local calls to out-of-line atomic operations

-print-supported-cpus, --print-supported-cpus, -mcpu=help, -mtune=help

Print supported cpu models for the given target (if target is not specified,it will print the supported cpus for the default target)

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

Language standard to compile for

Preprocessor options

Flags controlling the behavior of the Flang 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 /)

Dumping preprocessor state

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

-dM

Print macro definitions in -E mode instead of normal output

Diagnostic options

Flags controlling which warnings, errors, and remarks Flang will generate. See Clang’s Diagnostic Reference for a 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, -fdiagnostics-color, -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

-fdiagnostics-color=<arg>

When to use colors in diagnostics. <arg> must be ‘auto’, ‘always’ or ‘never’.

-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

-fhermetic-module-files

Emit hermetic module files (no nested USE association)

-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’.

-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, -fno-openmp

Parse OpenMP pragmas and generate parallel code.

-fopenmp-force-usm

Force behavior as if the user specified pragma omp requires unified_shared_memory.

-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 11 for Flang

-fopenmp=<arg>
-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
-frealloc-lhs, -fno-realloc-lhs

If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated

-freciprocal-math, -fno-reciprocal-math

Allow division operations to be reassociated

-frecord-command-line, -fno-record-command-line

Generate a section named “.GCC.command.line” containing the driver command-line. After linking, the section may contain multiple command lines, which will be individually terminated by null bytes. Separate arguments within a command line are combined with spaces; spaces and backslashes within an argument are escaped with backslashes. This format differs from the format of the equivalent section produced by GCC with the -frecord-gcc-switches flag. This option is currently only supported on ELF targets.

-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
-fstrict-overflow, -fno-strict-overflow
-funderscoring, -fno-underscoring

Appends one trailing underscore to external names

-funsigned, -fno-unsigned

Enables UNSIGNED type

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

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

-fwrapv, -fno-wrapv

Treat signed integer overflow as two’s complement

-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.

HIP options

--rocm-path=<arg>

ROCm installation path, used for finding and automatically linking required bitcode libraries.

Target-dependent compilation options

-mabi=<arg>
-march=<arg>

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

-masm=<arg>
-mcmodel=<arg>
-mcode-object-version=<arg>

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

-mcpu=<arg>

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

-mdynamic-no-pic<arg>
-mlarge-data-threshold=<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. (RISC-V only)

-mtune=<arg>

Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and X86

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)

X86

-mapx-features=<arg1>,<arg2>..., -mno-apx-features=<arg1>,<arg2>...

Enable features of APX. <arg> must be ‘egpr’, ‘push2pop2’, ‘ppx’, ‘ndd’, ‘ccmp’, ‘nf’, ‘cf’ or ‘zu’.

-mevex512, -mno-evex512

LoongArch

-mannotate-tablejump, -mno-annotate-tablejump

Enable annotate table jump instruction to correlate it with the jump table.

-mdiv32, -mno-div32

Use div.w[u] and mod.w[u] instructions with input not sign-extended.

-mfrecipe, -mno-frecipe

Enable frecipe.{s/d} and frsqrte.{s/d}

-mlam-bh, -mno-lam-bh

Enable amswap[_db].{b/h} and amadd[_db].{b/h}

-mlamcas, -mno-lamcas

Enable amcas[_db].{b/h/w/d}

-mlasx, -mno-lasx

Enable Loongson Advanced SIMD Extension (LASX).

-mld-seq-sa, -mno-ld-seq-sa

Do not generate load-load barrier instructions (dbar 0x700)

-mlsx, -mno-lsx

Enable Loongson SIMD Extension (LSX).

-msimd=<arg>

Select the SIMD extension(s) to be enabled in LoongArch either ‘none’, ‘lsx’, ‘lasx’.

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

-Xlinker <arg>

Pass <arg> to the linker

-Xoffload-linker<triple> <arg>

Pass <arg> to the offload linkers or the ones identified by -<triple>

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