4 ms·
Weird that it doesn't go into LFortran more, they even have an excellent online and mindblowing WASM example. https://dev.lfortran.org/ https://dev.lfortran.org
by droelf 3y ago
Weird that it doesn't go into LFortran more, they even have an excellent online and mindblowing WASM example. https://dev.lfortran.org/ https://dev.lfortran.org/
- andsoitis 3y ago> Weird that it doesn't go into LFortran more, they even have an excellent online and mindblowing WASM example. They write: The LFortran compiler has made great strides over the last few years. In 2020, it was missing a lot of features and only supported a very small subset of Fortran. Now it now supports a much wider range of language features and can be used to compile a reasonable amount of Fortran code. It can even compile to WebAssembly out of the box! However, there are still some barriers that make using LFortran a little rough. The project is currently considered to be in alpha phase and the developers state that issues compiling real-world code are expected. While it can successfully compile some projects, such as MINPACK, the full Fortran specification is not yet supported and so many larger projects still cannot be compiled. The LFortran developers are targeting full support for Fortran 2018, and its standout feature is an interactive Jupyter-like Fortran REPL. With a few more years of development, I expect that LFortran will be an excellent choice for compiling Fortran code for WebAssembly. and Check out the LFortran demo at https://dev.lfortran.org https://dev.lfortran.org. While extremely impressive, note that the first thing I tried was changing x * 2 to x * 3 and saw that such a change is currently not supported by the code generator.
- Onavo 3y agoAlso of course LPython https://lpython.org/ https://lpython.org/
- certik 3y agoThe author of LFortran here. The demo at https://dev.lfortran.org https://dev.lfortran.org uses our direct WASM backend that does not use LLVM. It is currently more limited, and indeed, we currently do not support the cubic power x**3 there, only square power x**2. Our most advanced backend is LLVM, and that of course supports x**3 and a very wide subset of Fortran (such as 60% of all SciPy packages fully compile and all SciPy tests pass). However, LLVM is huge and relatively slow, so we do not use LLVM in the online demo, which runs the compiler itself in the browser. For offline LLVM based WASM compilation I think LFortran is ready be tried. We'll be happy to help!
- georgestagg 3y agoI’ll definitely be trying out more of LFortran in the future. For this post I really wanted to go deeper into the approach we’ve taken with flang, but I can see that LFortran is also a very strong choice here for running Fortran on Wasm.
- certik 3y agoThanks. Please report all bugs that you find. I talked to my collaborators, we'll try to get some simple demo of Fortran->LLVM->WASM working soon, we need to figure out the runtime library issue (like you did), hook it into the driver, etc. I was in fact thinking about exactly this just last week, to easily distribute my simple computational codes online via static pages. I think exactly the approach that you took with Flang should work with LFortran also.
- forgotpwd16 3y agoGrats for the amazing work! LFortran is very cool project.
- certik 3y agoThank you!
- superjan 3y agoJust curious but what is keeping you from compiling x*3?
- certik 3y agoNothing, we can compile x*3. We can't compile x**3, because we do not have a runtime library setup for WASM yet (Flang above had the same issue) and WASM can do x**2, but arbitrary power, such as x**3, requires a runtime power function that we haven't implemented yet. If you want to help, you can fix it probably quite easily right here: https://github.com/lfortran/lfortran/blob/69d488b1d1fd26b163536199e0c5492ef990f285/src/libasr/codegen/asr_to_wasm.cpp#L1665 https://github.com/lfortran/lfortran/blob/69d488b1d1fd26b163....