Skip to content

Compiling Fortran for WASM #184

@rth

Description

@rth

There have been some earlier discussion about building Fortran code in various issues, trying to put together the available information about it here (a number of the below was adapted from @mdboom comments).

Currently it's necessary for,

  • BLAS with LAPACK (needed by scipy Port Scipy #72)
  • scipy also includes some Fortran by itself
  • R

There is some relevant discussion about it in emscripten-core/emscripten#998

The possible solutions are,

  1. using f2c (as currently done in WIP: Initial steps toward Scipy support #75 ). The limitation is that this only works with f77 not f90. For instance scipy can include F90 code starting from 1.0.0 (Mingw Gfortran on Windows? scipy/scipy#2829 (comment)). Not sure yet if it currently actually does as of 1.1.0.
    There may be some other F90 to C converter (e.g. http://cci.lbl.gov/fable/) that could work.
  2. Use flang. There are some suggestions in Fortran support with FLANG emscripten-core/emscripten#5553 that it might work. It should be noted however that, the conda-forge flang package is currently using @isuruf 's fork, as far as I understood, aimed at windows support, that targets LLVM 5.0 (while emsdk version we use needs LLVM 6.0).
    Apart for Fortran support emscripten-core/emscripten#998, I could not find any information about WASM support in flang (checked the mailing list and issues). Though is some relevant discussion on slack mentioning that flang doesn't support i386 (32 bit architecture) (Please support the i386 architecture flang-compiler/flang#123) while wasm currently is 32-bit only (whether emscripten only supports 32-bit compilation? emscripten-core/emscripten#5485)

Please correct me if I missed something..

So in the short term converting Fortran to C seems the only viable possibility.

cc @jakirkham

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions