Building a Fortran compiler in pure Fortran (Mega thread)

Yes, the runtime library should be maintained in Fortran, as we do in LFortran. There has to be a small C layer to interface with the system, and then a larger Fortran layer over that, implementing all of the ~200 intrinsic functions. You can use intrinsics that you already defined, but obviously you have to be careful to avoid cyclic dependencies. Some intrinsics are truly intrinsic, like size or len, which have to be implemented by the compiler itself, but many other intrinsics can be implemented as a library.

If anyone wants to help with that, I am happy to make it a standalone project.

See also Fortran runtime math library, where I proposed to maintain Fortran versions of the intrinsic functions as a community, but back then it wasn’t received very enthusiastically, however I think based on this thread, that now is a better timing.

1 Like