• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

documentation/H03-May-2022-7,1546,035

include/H10-Oct-2019-2,6752,150

lib/H03-May-2022-67,43053,663

module/H10-Oct-2019-1,041762

runtime/H03-May-2022-1,4821,115

test/H03-May-2022-26,82612,278

tools/f18/H03-May-2022-1,2121,052

.clang-formatH A D10-Oct-2019763 2826

.gitignoreH A D10-Oct-2019169 2019

LICENSEH A D10-Oct-201911.1 KiB202169

README.mdH A D10-Oct-20194.3 KiB168127

README.md

1<!--
2Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
3-->
4
5# F18
6
7F18 is a ground-up implementation of a Fortran front end written in modern C++.
8F18, when combined with LLVM, is intended to replace the Flang compiler.
9
10Flang is a Fortran compiler targeting LLVM.
11Visit the [Flang wiki](https://github.com/flang-compiler/flang/wiki)
12for more information about Flang.
13
14## Getting Started
15
16Read more about f18 in the [documentation directory](documentation).
17Start with the [compiler overview](documentation/Overview.md).
18
19To better understand Fortran as a language
20and the specific grammar accepted by f18,
21read [Fortran For C Programmers](documentation/FortranForCProgrammers.md)
22and
23f18's specifications of the [Fortran grammar](documentation/f2018-grammar.txt)
24and
25the [OpenMP grammar](documentation/OpenMP-4.5-grammar.txt).
26
27Treatment of language extensions is covered
28in [this document](documentation/Extensions.md).
29
30To understand the compilers handling of intrinsics,
31see the [discussion of intrinsics](documentation/Intrinsics.md).
32
33To understand how an f18 program communicates with libraries at runtime,
34see the discussion of [runtime descriptors](documentation/RuntimeDescriptor.md).
35
36If you're interested in contributing to the compiler,
37read the [style guide](documentation/C++style.md)
38and
39also review [how f18 uses modern C++ features](documentation/C++17.md).
40
41## Building F18
42
43### Get the Source Code
44
45```
46cd where/you/want/the/source
47git clone https://github.com/flang-compiler/f18.git
48```
49
50### Supported C++ compilers
51
52F18 is written in C++17.
53
54The code has been compiled and tested with
55GCC versions 7.2.0, 7.3.0, 8.1.0, and 8.2.0.
56
57The code has been compiled and tested with
58clang version 7.0 and 8.0
59using either GNU's libstdc++ or LLVM's libc++.
60
61### LLVM dependency
62
63F18 uses components from LLVM.
64
65The instructions to build LLVM can be found at
66https://llvm.org/docs/GettingStarted.html.
67
68We highly recommend using the same compiler to compile both llvm and f18.
69
70The f18 CMakeList.txt file uses
71the variable `LLVM_DIR` to find the installed components.
72
73To get the correct LLVM libraries included in your f18 build,
74define LLVM_DIR on the cmake command line.
75```
76LLVM=<LLVM_INSTALLATION_DIR>/lib/cmake/llvm cmake -DLLVM_DIR=$LLVM ...
77```
78where `LLVM_INSTALLATION_DIR` is
79the top-level directory
80where llvm is installed.
81
82### Building f18 with GCC
83
84By default,
85cmake will search for g++ on your PATH.
86The g++ version must be one of the supported versions
87in order to build f18.
88
89Or,
90cmake will use the variable CXX to find the C++ compiler.
91CXX should include the full path to the compiler
92or a name that will be found on your PATH,
93e.g. g++-7.2, assuming g++-7.2 is on your PATH.
94```
95export CXX=g++-7.2
96```
97or
98```
99CXX=/opt/gcc-7.2/bin/g++-7.2 cmake ...
100```
101There's a third option!
102The CMakeList.txt file uses the variable GCC
103as the path to the bin directory containing the C++ compiler.
104
105GCC can be defined on the cmake command line
106where `<GCC_DIRECTORY>` is the path to a GCC installation with bin, lib, etc:
107```
108cmake -DGCC=<GCC_DIRECTORY> ...
109```
110
111### Building f18 with clang
112
113To build f18 with clang,
114cmake needs to know how to find clang++
115and the GCC library and tools that were used to build clang++.
116
117The CMakeList.txt file expects either CXX or BUILD_WITH_CLANG to be set.
118
119CXX should include the full path to clang++
120or clang++ should be found on your PATH.
121```
122export CXX=clang++
123```
124BUILD_WITH_CLANG can be defined on the cmake command line
125where `<CLANG_DIRECTORY>`
126is the path to a clang installation with bin, lib, etc:
127```
128cmake -DBUILD_WITH_CLANG=<CLANG_DIRECTORY>
129```
130Or GCC can be defined on the f18 cmake command line
131where `<GCC_DIRECTORY>` is the path to a GCC installation with bin, lib, etc:
132```
133cmake -DGCC=<GCC_DIRECTORY> ...
134```
135To use f18 after it is built,
136the environment variables PATH and LD_LIBRARY_PATH
137must be set to use GCC and its associated libraries.
138
139### Installation Directory
140
141To specify a custom install location,
142add
143`-DCMAKE_INSTALL_PREFIX=<INSTALL_PREFIX>`
144to the cmake command
145where `<INSTALL_PREFIX>`
146is the path where f18 should be installed.
147
148### Build Types
149
150To create a debug build,
151add
152`-DCMAKE_BUILD_TYPE=Debug`
153to the cmake command.
154Debug builds execute slowly.
155
156To create a release build,
157add
158`-DCMAKE_BUILD_TYPE=Release`
159to the cmake command.
160Release builds execute quickly.
161
162### Build F18
163```
164cd ~/f18/build
165cmake -DLLVM_DIR=$LLVM ~/f18/src
166make
167```
168