1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
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
|