[RFC] Command-line compatibility with gfortran

This was discussed during the flang call last week (see notes here), but I am posting this here in case others have different opinions.

An issue was raised regarding the -ffree-line-length option. This is supported in gfortran but not in flang. This option is not meaningful for flang since flang’s parser only imposes limits on fixed form code.

This raises some questions regarding what to do with options that are supported in gfortran, but may not be relevant to flang. clang is largely, but not entirely, command-line compatible with gcc. The question is whether it is reasonable for flang to accept some gfortran options and ignore them after emitting a warning message.

A related PR (and associated RFC), supports some gcc options that are also accepted by clang. In this case, those options are ignored with a warning message. These options are also accepted by gfortran. Since there were no objections to that RFC, I intend to proceed with it. The case there, though, is that the options are accepted by clang. It would seem to be more reasonable to maintaing compatibility with clang than with gfortran.

The opinion during the flang call was that we should not strive for command-line compatibility with gfortran. If anyone feels otherwise, we can initiate a discussion here.

If there are no contrary opinions, I will close the issue that sparked this discussion. Requests for gfortran options will continue to be considered on a case-by-case basis.

To expand on the topic: FreeBSD Ports (a collection of build recipes for the official package repository) allows for swapping compilers for C, C++ and Fortran language. As an experiment I tried to use Flang 21 to build all the Fortran ports we currently have. Of course, it resulted in a large fallout, which I started analyzing through. It resulted in fixes for ports on our side and following issues reported to GH:

I’m not saying that Flang should implement all these flags, but this is rather an illustration of what would be nice to have to help us downstream packagers make Flang a mostly drop-in replacement for gfortran.

Thanks for compiling all the issues in one place (and for filing them in the first place).

There are PR’s open that will address some of these. I have assigned other issues to myself and will open PR’s for those too once I have finished implementing them.

While there is willingness to support some non-standard intrinsics and gfortran-specific options, complete compatibiity with gfortran is not something we are actively considering.