Fortran On Web Using LFortran

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