Lines Matching full:flang

9 # Flang drivers
17 There are two main drivers in Flang:
18 * the compiler driver, `flang`
19 * the frontend driver, `flang -fc1`
24 Fortran compilation job and delegates it to `flang -fc1`, the frontend
31 not yet available in Flang, but will be relatively easy to support once such
32 libraries become available. Flang's compiler driver is intended for Flang's
33 end-users - its interface needs to remain stable. Otherwise, Flang's users will
38 | *Flang’s compiler driver and the **tools** that it runs* |
40 The **frontend driver** glues together and drives all of the Flang's frontend
43 driver for Flang, LLVM and MLIR libraries. Contrary to the compiler driver, it
46 accepts many frontend-specific options not available in `flang` and as such
48 intended for Flang developers. In particular, there are no guarantees about the
54 | *Flang's frontend driver and the **libraries** that it drives* |
61 flang -Xflang -fdebug-dump-parse-tree input.f95
64 In the invocation above, `-fdebug-dump-parse-tree` is forwarded to `flang
69 flang: warning: argument unused during compilation:
72 As `-fdebug-dump-parse-tree` is only supported by `flang -fc1`, `flang`
76 As hinted above, `flang` and `flang -fc1` are two separate tools. The
77 fact that these tools are accessed through one binary, `flang`, is just an
82 specialised tools. In particular, `flang` is not aware of various
84 checks). It does not have to be. Conversely, the frontend driver, `flang
100 In fact, Flang needs to adhere to this model in order to be able to re-use
103 than Clang, then `flang` corresponds to `gfortran` and `flang -fc1` to
107 The main entry point for Flang's compiler driver is implemented in
108 `flang/tools/flang-driver/driver.cpp`. Flang's compiler driver is implemented
113 One implication of this dependency on Clang is that all of Flang's compiler
116 Flang and Clang, the corresponding definitions are shared.
134 flang -ccc-print-phases -E file.f
142 flang -ccc-print-phases -c file.f
155 `clang::driver::Tool`. For Flang we introduced a specialisation of this class:
156 `clang::driver::Flang`. This class implements the logic to either translate or
157 forward compiler options to the frontend driver, `flang -fc1`.
163 When used as a linker, Flang's frontend driver assembles the command line for an
168 By default, the Flang linker driver adds several libraries to the linker
177 $ flang -v -o example example.o
183 * `FortranRuntime`: Provides most of the Flang runtime library.
187 or Flang as the linker driver. If Clang is used, it will automatically all
190 `FortranRuntime` and/or `FortranDecimal`. An alternative is to use Flang to link.
198 includes, with Flang (and Fortran in general) it only affects Darwin libraries'
202 Flang's frontend driver is the main interface between compiler developers and
203 the Flang frontend. The high-level design is similar to Clang's frontend
230 implemented in `flang/tools/flang-driver/driver.cpp`. It can be accessed by
231 invoking the compiler driver, `flang`, with the `-fc1` flag.
236 words, `flang -fc1 <input-file>` is equivalent to `flang -fc1 -fsyntax-only
240 Adding a new compiler option in Flang consists of two steps:
245 All of Flang's compiler and frontend driver options are defined in
247 Flang, you will either:
249 in one of Clang's drivers (e.g. `clang`), but not yet available in Flang, or
260 following Flang specific visibility flags to control this:
261 * `FlangOption` - this option will be available in the `flang` compiler driver,
262 * `FC1Option` - this option will be available in the `flang -fc1` frontend driver,
265 `Visibility`, and options that are only supported in Flang should not specify
279 First, every option needs to be parsed. Flang compiler options are parsed in
282 * frontend driver: `flang/lib/Frontend/CompilerInvocation.cpp`,
283 * compiler driver: `clang/lib/Driver/ToolChains/Flang.cpp`.
289 by the frontend, make sure that it is either forwarded to `flang -fc1` or
292 flags, we usually just forward from `flang` to `flang -fc1`. This is
293 then tested in `flang/test/Driver/frontend-forward.F90`.
305 `flang/include/flang/Frontend/FrontendOptions.h`. For example, for
338 (CMake 3.28.0), `cmake` can detect `flang` as a
340 `flang` as follows:
342 cmake -DCMAKE_Fortran_COMPILER=<path/to/flang> <src/dir>
348 where `<version>` corresponds to the LLVM Flang version.
351 In LIT, we define two variables that you can use to invoke Flang's drivers:
352 * `%flang` is expanded as `flang` (i.e. the compiler driver)
353 * `%flang_fc1` is expanded as `flang -fc1` (i.e. the frontend driver)
357 `%flang` or `%flang_fc1` is used. However, when you are using `%flang` instead
359 driver invocation (i.e. `flang -fc1 -<extra-flags>`). In some cases that might
373 semantic checks. Similarly to Clang, Flang leverages `LoadLibraryPermanently`
379 Flang plugins are limited to `flang -fc1` and are currently only available /
388 There is an example plugin located in `flang/example/PrintFlangFunctionNames`
395 `PluginParseTreeAction` (defined in `flang/include/flang/FrontendActions.h`), in
422 `flang/include/flang/Parser/parse-tree-visitor.h`.
442 defined in `flang/include/flang/Parser/parse-tree.h`. In the example, there is a
449 plugins. The Flang plugin registry, defined in
450 `flang/include/flang/Frontend/FrontendPluginRegistry.h`, is an alias of
464 frontend driver, `flang -fc1`:
471 flang -fc1 -load flangPrintFunctionNames.so -plugin print-fns file.f90
474 Both these options are parsed in `flang/lib/Frontend/CompilerInvocation.cpp` and
476 `flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp`
492 default, that controls the exporting of executable symbols from `flang`,
496 `flang/example` directory and added as a `sub_directory` to the
497 `flang/examples/CMakeLists.txt`, for example, the `PrintFlangFunctionNames`
520 in `flang/lib/Optimizer/Passes/Pipelines.cpp` contains extension point callback
522 `invokeFIROptLastEPCallbacks` for Flang drivers to be able to insert additonal
525 default inliner pass in `flang`.
538 The framework to enable pass plugins in `flang` uses the exact same
546 flang -fpass-plugin=/path/to/plugin.so <file.f90>
558 into `flang` as built-in middle-end passes.
565 `-Ofast` in Flang means `-O3 -ffast-math -fstack-arrays`.
594 aren't included in Flang because Flang currently has no support for strict
598 as Flang.
601 any unsupported GCC/GFortran warning flags into Flang's compiler driver will
608 optimization. `flang -O3` should enable all optimizations for execution time,
613 is not yet supported in Flang and so Flang follows GFortran in not including
615 - `-Mcache_align`: there is no equivalent flag in Flang or Clang.
616 - `-Mflushz`: flush-to-zero mode - when `-ffast-math` is specified, Flang will