Compiler Options

This page lists the command-line options currently supported by Arm Fortran Compiler (armflang). Arm Fortran compiler is built on the Flang open source Fortran front‑end, and the LLVM-based optimisation and code generation back-end.

Actions

Options that control what action to perform on the input.

Option Description Usage
‑E Only run the preprocessor. armflang ‑E
‑S Only run preprocess and compilation steps. armflang ‑S
‑c Only run preprocess, compile, and assemble steps. armflang ‑c
‑fopenmp Enable OpenMP and link in the OpenMP library, libomp. armflang ‑fopenmp
‑fsyntax-only Show syntax errors but do not perform any compilation. armflang ‑fsyntax-only

File options

Options that specify input or output files.

Option Description Usage
-I<dir> Add directory to include search path. armflang ‑I<dir>
-include <file> Include file before parsing. armflang ‑include <file>, ‑‑include <file>
-o <file> Write output to armflang ‑o <file>. armflang ‑o <file>

Basic driver options

Options that affect basic functionality of the armflang driver.

Option Description Usage
--gcc‑toolchain=<arg> Use the gcc toolchain at the given directory. armflang ‑‑gcc‑toolchain=<arg>
-help
Display available options. armflang ‑help
armflang ‑‑help
--help‑hidden Display hidden options.
Only use these options if advised to do so by your Arm representative.
armflang ‑‑help‑hidden
-v Show commands to run and use verbose output. armflang ‑v
--version
--vsn
Show the version number and some other basic information about the compiler. armflang ‑‑version
armflang ‑‑vsn

Optimization options

Options that control optimization behavior and performance.

Option Description Usage
-O0 Minimum optimization for the performance of the compiled binary.
Turns off most optimizations. When debugging is enabled, this option generates code that directly corresponds to the source code. Therefore, this might result in a significantly larger image.
This is the default optimization level.
armflang ‑O0
-O1 Restricted optimization.
When debugging is enabled, this option gives the best debug view for the trade-off between image size, performance, and debug.
armflang ‑O1
-O2 High optimization.
When debugging is enabled, the debug view might be less satisfactory because the mapping of object code to source code is not always clear.
The compiler might perform optimizations that cannot be described by debug information.
armflang ‑O2
-O3 Very high optimization.
When debugging is enabled, this option typically gives a poor debug view.
Arm recommends debugging at lower optimization levels.
armflang ‑O3
-Ofast Enable all the optimizations from level 3 including those performed with the ‑ffp‑mode=fast armflang option.
This level also performs other aggressive optimizations that might violate strict compliance with language standards.
armflang ‑Ofast
-ffast‑math Allow aggressive, lossy floating-point optimizations. armflang ‑ffast‑math
-ffinite‑math‑only Enable optimizations that ignore the possibility of NaN and +/‑Inf. armflang ‑ffinite‑math‑only
-ffp‑contract={fast |on |off} Controls when the compiler is permitted to form fused floating-point operations (such as FMAs).
  • fast: Always, except when using -O0 to set the optimization level to 0 (default).
  • on: Only in the presence of the FP_CONTRACT pragma.
  • off: Never.
armflang ‑ffp‑contract={fast |on |off}
-finline
-fno-inline
Enable or disable inlining (enabled by default). armflang ‑finline (enable)
armflang ‑fno‑inline (disable)
-fstack-arrays
-fno-stack-arrays
Place all automatic arrays on stack memory.
For programs using very large arrays on particular operating systems, consider extending stack memory runtime limits.
Enabled by default at optimization level -Ofast
armflang -fstack-arrays (enable)
armflang -fno-stack-arrays (disable)
-fstrict‑aliasing Tells the compiler to adhere to the aliasing rules defined in the source language.
In some circumstances, this flag allows the compiler to assume that pointers to different types do not alias.
Enabled by default when using ‑Ofast.
armflang ‑fstrict‑aliasing
-funsafe‑math‑optimizations
-fno-unsafe-math-optimizations
This option enables reassociation and reciprocal math optimizations, and does not honor trapping nor signed zero. armflang ‑funsafe‑math‑optimizations (enable)
armflang ‑fno‑unsafe‑math‑optimizations (disable)
-fvectorize
-fno-vectorize
Enable or disable loop vectorization.

Enabled by default.
armflang ‑fvectorize (enable)
armflang ‑fno‑vectorize (disable)
-mcpu=<arg> Select which CPU architecture to optimize for ‑mcpu=native causes the compiler to auto-detect the CPU architecture from the build computer. armflang ‑mcpu=<arg>

Workload compilation options

Options that affect the way Fortran workloads compile.

Option Description Usage
-Mallocatable={95 | 03} Select semantics for assignments to allocatables.. Fortran 2003 (03) allows dynamic reallocation, which will error in Fortran 90/95 (95).
Default = 03.
armflang ‑Mallocatable={95 | 03}
-cpp Preprocess Fortran files. armflang ‑cpp
-fbackslash
-fno-backslash
Treat backslash as C-style escape character (fbackslash) or as a normal character (fno‑backslash).
Enabled by default.
armflang ‑fbackslash (enable)
armflang ‑fno‑backslash (disable)
-fconvert={native | swap | big‑endian | little‑endian} Convert between big and little endian data format.
Default = native.
armflang ‑fconvert={native | swap | big‑endian | little‑endian}
-ffixed‑form Force fixed‑form format Fortran.
This is default for .f and .F files, and is the inverse of ‑ffree‑form.
armflang ‑ffixed‑form
-ffixed‑line‑length={0 |72 | 132 | none} Set line length in fixed-form format Fortran.
Default is 72. 0 and none are equivalent and set the line length to a very large value (>132).
armflang ‑ffixed‑line‑length={0 |72 | 132 | none}
-ffree‑form Force free-form format for Fortran.
This is default for .f90 or .F90 files, and is the inverse of ‑ffixed‑form.
armflang ‑ffree‑form
-fma Enable generation of FMA instructions. armflang ‑fma
-fno‑fortran‑main Don't link in Fortran main. armflang ‑fno‑fortran‑main
-frecursive Allocate all local arrays on the stack, allowing thread-safe recursion.
In the absence of this flag, some large local arrays may be allocated in static memory. This reduces stack , but is not thread-safe.
This flag is enabled by default when ‑fopenmp is given.
armflang ‑frecursive
-i8 Treat INTEGER and LOGICAL as INTEGER*8 and LOGICAL*8. armflang ‑i8
-no‑flang‑libs Do not link against Flang libraries. armflang ‑no‑flang‑libs
-nocpp Don't preprocess Fortran files. armflang ‑nocpp
-nofma Disable generation of FMA instructions. armflang ‑nofma
-r8 Treat REAL as REAL*8. armflang ‑r8
-static‑flang‑libs Link using static Flang libraries. armflang ‑static‑flang‑libs

Development options

Options that support code development.

Option Description Usage
-fcolor-diagnostics
-fno-color-diagnostics
Use colors in diagnostics. armflang -fcolor-diagnostics
armflang -fno-color-diagnostics
-g Generate source-level debug information. armflang -g

Warning options

Options that control the behavior of warnings.

Option Description Usage
-W<warning>
-Wno-<warning>
Enable or disable the specified warning.
armflang -W<warning>
-Wall Enable all warnings. armflang -Wall
-w Suppress all warnings. armflang -w

Preprocessor options

Options that control preprocessor behavior.

Option Description Usage
-D <macro>=<value> Define macro to value (or 1 if value omitted). armflang -D=
-U Undefine macro <macro>. armflang -U<macro>

Linker options

Options that control linking behavior and performance.

Option Description Usage
-Wl,<arg> Pass the comma separated arguments in <arg> to the linker. armflang ‑Wl, <arg> ;...
-Xlinker <arg> Pass <arg> to the linker. armflang ‑Xlinker  <arg>
-l<library> Search for the library named <library> when linking. armflang ‑l<library>
-larmflang At link time, include this option to use the default Fortran libarmflang runtime library for both serial and parallel (OpenMP) Fortran workloads.

Notes:
  • This option is set by default when linking using armflang.
  • You need to explicitly include this option if you are linking with armclang instead of armflang at link time.
  • This option only applies to link time operations.
armflang ‑larmflang
-larmflang-nomp At link time, use this option to avoid linking against the OpenMP Fortran runtime library.

Notes:
  • This option is set by default when compiling and linking using armflang with the -fno-openmp option.
  • You need to explicitly include this option if you are linking with armclang instead of armflang at link time.
  • This option should not be used when your code has been compiled with the -lomp or -fopenmp options.
  • When using this option, do not link to any OpenMP-utilizing Fortran runtime libraries in your code.
  • This option only applies to link time operations.
armflang ‑larmflang-nomp
-shared
--shared
Causes library dependencies to be resolved at runtime by the loader. This is the inverse of static. If both options are given, all but the last option will be ignored. armflang ‑shared
armflang ‑‑shared
-static Causes library dependencies to be resolved at link time. This is the inverse of shared. If both options are given, all but the last option is ignored. armflang ‑static, ‑‑static

Notes about linking Fortran workloads

To link serial or parallel Fortran workloads using armclang instead of armflang, include the -larmflang option to link with the default Fortran runtime library for serial and parallel Fortran workloads. You also need to pass any options required to link using the required mathematical routines for your code.

To statically link, in addition to passing -larmflang and the mathematical routine options, you also need to pass:

  • -static
  • -lomp
  • -lrt

To link serial or parallel Fortran workloads using armclang instead of armflang, without linking against the OpenMP runtime libraries, instead pass -armflang-nomp at link time. For example, pass:

  • -larmflang-nomp
  • Any mathematical routine options, for example: -lm or -lamath.

Again, to statically link, in addition to -larmflang-nomp and the mathematical routine options, you also need to pass:

  • -static
  • -lrt

Warning

  • Do not link against any OpenMP-utlizing Fortran runtime libraries when using this option.
  • All lockings and thread local storage will be disabled.
  • Arm does not recommend using the -larmflang-nomp option for typical workloads. Use this option with caution.

 

Note

The -lompstub option (for linking against libompstub) might still be needed if you have imported omp_lib in your Fortran code but not compiled with -fopenmp.