An open API service indexing awesome lists of open source software.

https://github.com/steleman/fc

LLVM based Fortran frontend
https://github.com/steleman/fc

Last synced: 4 months ago
JSON representation

LLVM based Fortran frontend

Awesome Lists containing this project

README

          

# **FC - LLVM Based fortran frontend**

A new front end for Fortran has been written in the design spirit of LLVM/Clang. Approximately 20000 lines of code effort has got close to Fortran 95 standard. The Front end is complete end to end solution without semantic analysis. It compiles 400+ unit test cases and 2 SPEC CPU 2017 benchmarks.

### Dependencies
```
LLVM 7.0 - Can be built from source or prebuilt binaries can be used.
gfortran (for running unit tests)
```

## Build instructions
```
1. Set following environment variables
a. CLANG_BINARY=bin/clang
b. PATH=/bin:$PATH
c. LD_LIBRARY_PATH=/lib;$PATH
2. mkdir build && cd build
3. cmake -G Ninja -DLLVM_DIR=/lib/cmake/llvm/ ../fc -DCMAKE_INSTALL_PREFIX= -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
4. ninja install
5. ninja test

Note that clang-7.0 is already in your PATH. This will be used for building FC.
```

## Running HelloWorld

```
$ cat hello.f90
program hello
print *, "Hello world!"
end program hello
$ export CLANG_BINARY=/bin/clang
$ export LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH
$ /bin/fc hello.f90
$ ./a.out
Hello world!
```

## Running test

```
cd build
ctest
```
OR

```
cd build
ninja test
```

## Compiling input file to AST

```
fc -emit-ast
```
OR
```
fc -emit-ast -o
```

## Emitting LLVM IR
```
fc -emit-llvm
```

## Emitting LLVM BC

```
fc -emit-bc
```

## Fortran standard
Fortran standard can be specified via -std=f77 or -std=f95. If not specified standard is derived from file extension. Source files with ".f" are compiled to F77 standard and all other extensions are compiled to default standard.

### Enter following command for more options
```
fc --help
```

## Developed by
[CompilerTree Technologies](http://compilertree.com)