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