64 lines
2.4 KiB
ReStructuredText
64 lines
2.4 KiB
ReStructuredText
flang - the Flang Fortran compiler
|
|
==================================
|
|
|
|
SYNOPSIS
|
|
--------
|
|
|
|
:program:`flang` [*options*] *filename ...*
|
|
|
|
DESCRIPTION
|
|
-----------
|
|
|
|
:program:`flang` is a Fortran compiler which supports all of the Fortran 95 and
|
|
many newer language features. Flang supports OpenMP and has some support for
|
|
OpenACC and CUDA. It encompasses preprocessing, parsing, optimization, code
|
|
generation, assembly, and linking. Depending on the options passed in, Flang
|
|
will perform only some, or all, of these actions. While Flang is highly
|
|
integrated, it is important to understand the stages of compilation in order to
|
|
understand how to invoke it. These stages are:
|
|
|
|
Driver
|
|
The flang executable is actually a small driver that orchestrates the
|
|
execution of other tools such as the compiler, assembler and linker.
|
|
Typically you do not need to interact with the driver, but you
|
|
transparently use it to run the other tools.
|
|
|
|
Preprocessing
|
|
This stage performs tokenization of the input source file, macro expansion,
|
|
#include expansion and handles other preprocessor directives.
|
|
|
|
Parsing and Semantic Analysis
|
|
This stage parses the input file, translating preprocessor tokens into a
|
|
parse tree. Once in the form of a parse tree, it applies semantic
|
|
analysis to compute types for expressions and determine whether
|
|
the code is well formed. Parse errors and most compiler warnings
|
|
are generated by this stage.
|
|
|
|
Code Generation and Optimization
|
|
This stage translates the parse tree into intermediate code (known as
|
|
"LLVM IR") and, ultimately, machine code. It also optimizes this
|
|
intermediate code and handles target-specific code generation. The output
|
|
of this stage is typically a ".s" file, referred to as an "assembly" file.
|
|
|
|
Flang also supports the use of an integrated assembler, in which the code
|
|
generator produces object files directly. This avoids the overhead of
|
|
generating the ".s" file and calling the target assembler explicitly.
|
|
|
|
Assembler
|
|
This stage runs the target assembler to translate the output of the
|
|
compiler into a target object file. The output of this stage is typically
|
|
a ".o" file, referred to as an "object" file.
|
|
|
|
Linker
|
|
This stage runs the target linker to merge multiple object files into an
|
|
executable or dynamic library. The output of this stage is typically
|
|
an "a.out", ".dylib" or ".so" file.
|
|
|
|
OPTIONS
|
|
-------
|
|
|
|
.. toctree::
|
|
:maxdepth: 1
|
|
|
|
FlangCommandLineOptions
|