We are happy to share that LFortran can compile Fortran codes to WebAssembly via the LLVM Backend.
We have deployed the following examples in our blog post Fortran On Web Using LFortran.
- MNIST Classifier
- Matrix Multiplication 2D
- Simple Linear Regression
We would love it if you could try our examples and share your feedback on it.
26 Likes
On the other hand, I have recently had 15 bugs in Lfortran admitted by the developers of that compiler to be bugs. I’m still trying to find a workaround for one of my favourite programs that it won’t compile.
Are there other possible values for --target or --backend? (–backend isn’t even mentioned iin the usage documentation). I am especially interested in compiling for Windows and FreeBSD. Could I combine --static with --target?
1 Like
Thank you for reporting them. LFortran is alpha quality, meaning it is expected to break for you, and we appreciate any bugs that people report. Once we reach beta quality, it will be expected to work (then it will be concerning if LFortran breaks for your project; but right now it is expected that it will break). You can follow our progress towards beta using the progress bar and links at our front page: https://lfortran.org/.
2 Likes
The --target
applies to the llvm
backend. We need to explicitly enable the desired targets while building lfortran
.
diff --git a/build1.sh b/build1.sh
index 49a1cf78b..e0bc58311 100755
--- a/build1.sh
+++ b/build1.sh
@@ -12,5 +12,8 @@ cmake \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH_LFORTRAN;$CONDA_PREFIX" \
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
-DCMAKE_INSTALL_LIBDIR=share/lfortran/lib \
+ -DWITH_TARGET_WASM=yes \
+ -DWITH_TARGET_AARCH64=yes \
+ -DWITH_TARGET_X86=yes \
.
cmake --build . -j16 --target install
after building with the above, we can print the supported targets as follows:
% lfortran --print-targets
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
For --backend
, we have several backends like llvm
, wasm
(our custom webassembly backend), c
, cpp
(you would need kokkos
library for this to work), x86
, fortran
and julia
. llvm
is our most advanced and default backend.
Could I combine --static with --target?
I think it should be possible to use combined --static
and --target
when compiling to arm
or aarch
binary using llvm
. I am unsure if --static
applies to wasm
as target.
1 Like