Skip to content

Instantly share code, notes, and snippets.

@Shaikh-Ubaid
Last active August 24, 2023 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shaikh-Ubaid/b93adf592383ca0f25ba5d4d88854701 to your computer and use it in GitHub Desktop.
Save Shaikh-Ubaid/b93adf592383ca0f25ba5d4d88854701 to your computer and use it in GitHub Desktop.

LFortran: IMPLEMENTING A CUSTOM WASM BACKEND

GSoC'22 Report


  • 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.

Project Outline:

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.

What was done:

Our project was mostly completed in four phases as follows:

Merge/Pull Requests

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:

Outcome:

The outcomes of the project are the following:

  • A WASM Backend for LFortran

  • A WAT Backend for LFortran

  • LFortran (along with its runtime library) compiles to WASM using emscripten

  • CI (Continuous Integration) support for building to wasm and storing built lfortran 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

Future Work:

There are tremendous possiblities of extending this work. Some of the future work includes the following:

  • Extending the current wasm and wat backends: Adding support for dynamic memory allocation and thus array allocations during runtime. Supporting structs and derived types in the wasm and wat backends.

  • More Robutness: Finding and fixing bugs in the current wasm and wat backends. Some of the issues are noted at WASM: Future Prospects #597 and fixing them would (hopefully) make our wasm architecture more robust.

  • Supporting WASI: One of the directions could be to add support of WASI (WebAssembly System Interface) to the LFortran WASM Backend.

  • Data Visualization: We could also try to explore data visualization using fortran.

My Learnings

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 learnt rebasing, resetting (hard, soft) and cherry-picking commits. Previously, I used to be afraid of merge 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 used NextJS while building the lcompilers_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 about intrinsic functions, runtime library, etc.

  • Compilers: I got the opportunity to learn how a compiler works, specifically the backend/codegen part.

  • Conda: This was the first time for me using conda and I realized how powerful conda 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.

@rajkumardongre
Copy link

Really Amazing Work 💯

@Shaikh-Ubaid
Copy link
Author

Thank you @rajkumardongre! You have done amazing work as well!

@rajkumardongre
Copy link

Thank you 🙌.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment