- Organization: Fortran-Lang
- Mentors: Ondrej Certik, Gagandeep Singh, Rohit Goswami
- Contributor: Ubaid Shaikh
This report summarizes the work done as part of my GSoC 2022
project titled LFortran: IMPLEMENTING A CUSTOM WASM BACKEND
at LFortran
/Fortran-Lang
.
The objective in this project is to implement a WebAssembly
(WASM
) Backend for the LFortran
Compiler.
The goal is also to compile LFortran
to WASM
and deploy on a static webpage. Thus, this project aims
to add to fortran
the capability of executing on the World Wide Web
, the only truly universal platform.
Our project was mostly completed in four phases as follows:
-
Pre-GSoC Phase: During this phase we iterated over the design of the
wasm
backend and implemented it. The weekly blogs during this phase are as follows: -
GSoC Phase-1: During this phase we designed the
wat
backend and added initial support for compilinglfortran
towasm
. We also deployed the builtlfortran
wasm
binary to a live site. The weekly blogs during this phase are as follows: -
GSoC Phase-2: Now that we had the
wasm
backend, thewat
backend and compilation oflfortran
towasm
. The next part of the project was to extend thewasm
andwat
backends to support more features offortran
/ASR
. This extension of both the backends was accomplished in this phase. The weekly blogs during this phase are as follows: -
GSoC Ending Phase: This comprises the final week(s) of GSoC where we focused on
CI
(Continuous Integration) support for wasm building, its storage and some final features and fixes. The blog during this phase is as follows:
The merge
/pull
requests submitted during the period of GSoC
from (approx)23-05-2022
to 23-08-2022
are as follows:
At Gitlab/lfortran
:
At GitHub/lfortran
:
At GitHub/lcompilers_frontend
:
The outcomes of the project are the following:
-
A
WASM
Backend forLFortran
-
A
WAT
Backend forLFortran
-
LFortran
(along with itsruntime library
) compiles toWASM
usingemscripten
-
CI
(Continuous Integration) support for building towasm
and storing builtlfortran
wasm
at lfortran/wasm_builds -
A frontend for the static webpage (at dev.lfortran.org) where we deploy our
lfortran
wasm
binary and can see it live in action -
CI
(Continuous Integration) support for building the frontend site
There are tremendous possiblities of extending this work. Some of the future work includes the following:
-
Extending the current
wasm
andwat
backends: Adding support for dynamic memory allocation and thusarray
allocations during runtime. Supportingstructs
and derived types in thewasm
andwat
backends. -
More Robutness: Finding and fixing bugs in the current
wasm
andwat
backends. Some of the issues are noted at WASM: Future Prospects #597 and fixing them would (hopefully) make ourwasm
architecture more robust. -
Supporting WASI: One of the directions could be to add support of
WASI
(WebAssembly System Interface
) to theLFortran
WASM
Backend. -
Data Visualization: We could also try to explore data visualization using
fortran
.
It has been an incredible journey, full of fun and learning for me.
Following is a list of my learnings (including but not limited to):
-
GIT: I got to learn/improve
version control
(git
) skills. I learntrebasing
,resetting
(hard, soft) andcherry-picking
commits. Previously, I used to be afraid ofmerge
conflicts and now, I enjoy resolving them. -
WASM: This project provided me with the wonderful opportunity to understand how binaries are created and processed. I got to learn about the
wasm
structure and its textual format (wat
). -
NextJS: I got to learn about
NextJS
. We usedNextJS
while building thelcompilers_frontend
. -
CI: I also got the opportunity to work towards the
CI
(Continuous Integration) part during the course of the project. -
CMake: I also got the opportunity to get my hands onto
CMake
during the course of the project. -
Fortran: I got to learn about
fortran
. I learned aboutintrinsic
functions,runtime library
, etc. -
Compilers: I got the opportunity to learn how a
compiler
works, specifically thebackend
/codegen
part. -
Conda: This was the first time for me using
conda
and I realized how powerfulconda
environments could be.
and the list goes on.
Indeed, I think this project has made me a better programmer, problem solver, analyzer and communicator.
I am thankful to Ondrej Sir and team for accepting me in this project. Thank you so much for this wonderful journey and amazing experience throughout.
Really Amazing Work 💯