GFortran releases

Would it be possible to get those previous developers of gfortran in contact with users of this discourse, so the users can make the merge requests in their stead ?

I really feel like we shouldn’t throw away their expertise and work. I believe the ones making the merge request could and should credit the original contributor or something.

2 Likes

Oh ok, never imagined something like that.

Ok, this is much concerning. I totally agree with the following

and I’ll add that there’s no way that a younger generation, no matter how talented and motivated, could start from zero to contribute to such a big project, with no tutoring whatsoever from the former, experienced contributors. It’s really just a matter of knowing the codebase.

Maybe we could try to make some arrangement, where the experienced gfortran developers put effort in explaining and guiding others about the code structure, conventions, generically navigating the project and the interested “git aware” developers in turn give back support with git (which should be, as I understand from the comment above, the big main blocker for the older generation, greatly adding to the “small numbers” problem).
Ideally at first it would mean to “just” get merged all the patches sitting around in laptopts (in lieu of others, i.e. I totally agree that credit must be preserved!) but I’d really hope at some point this would make for a true passing of the baton between generations. Otherwise I’m really afraid that gfortran might really die this time.

If you’d let me divagate a bit, this seems to resemble too much what might be suddenly happening with twitter (almost all experienced people are gone, so who would tutor new developers and maintainers for the website, or even the company?).

2 Likes

Anyway, I know nothing about compiler development and truly believe I do not have the skills (not currently at least). But, to be more concrete, I can surely commit to give help with git. I’m no big expert with it either, but I’m pretty comfortable with it, as it is basically the main non-physics-related hard skill I tamed during these PhD years.

So @kargl, feel free to contact me (also privately) if you need any help with getting those patches merged, I’ll try to help as reactively as I can with it.

Well, all closed PRs are unmerged, and there are some comments clarifying that no, the github mirror is not monitored and there is another procedure to be followed (e.g. this one). We probably should refer to this: Contributing to GCC - GNU Project, where the clunky legal procedures are still in place (in some form). But, given that the actual author of the patch is an already active GCC developer I think we could just go with the Signed-off-by method. @kargl, you and your colleagues working in gfortran have all “sign-off” privileges, right?

Finally, now I can see why git looks quite a barrier here, they are not using a branch-based (PR-based in github speech) workflow, but the older email-based one originally devised for the Linux kernel (and still in place therein, iirc). Oof… but still I think that we can overcome everything by joining forces :slight_smile:

1 Like

This reminds me of something that has bothered me for the last 30 years. I understand that most modern compilers have a front-end, a middle, and a back end. The front-end translates the language source code into some intermediate symbolic language, which is then passed on to the middle and back-end parts of the compiler to produce the machine instructions.

In gfortran, the front-end is written in C. This means that in order to contribute to the compiler effort, the programmer must be fluent with three languges, C, fortran, and the intermediate language. Both C and fortran have evolved significantly over the past 30 years, so it is quite an effort and requires some significant skills to be able to do that. The intermediate language may have evolved during that time too.

To use a common phrase, in fortran we aren’t “eating our own dog food” in this respect.

I have wondered how things might have been different if the front-end development (to gfortran, or the LLVM fortran compilers, or to any other fortran compiler project) had instead been written in fortran rather than in some other language. Writing compilers still requires special skills, and knowledge of the intermediate language, but if we were eating our own dogfood, there might be be a larger pool of motivated potential developers.

3 Likes

Yes, it could be done in principle. The reason I chose C++ and not Fortran for the LFortran’s frontend is to have the whole compiler in the same language and to actually deliver a compiler. I can’t fight all the fights, so the first task is to deliver a working compiler that can also compile quickly (very important). If there is interest, we could write a new frontend in Fortran later once LFortran is in wide usage (currently it is not, so I am just focusing on delivering what we have).

What we have done already is to have the runtime library in Fortran, so if you want, you can already contribute to that here: lfortran/src/runtime at main · lfortran/lfortran · GitHub, see the thread How to contribute to LFortran's runtime library for more info how to contribute.

GFortran and Flang could also in principle be implemented in Fortran, but chose C or C++ for the same reasons I think, to have the GCC and LLVM compiler collection in the same language, so that people need to only learn one language to contribute to it.

2 Likes

A post was split to a new topic: How to contribute to LFortran’s runtime library

gfortran+libgfortran is written in a multitude of languages (Fortran, C, C++, awk, m4, …), but in general most is written C. In recent years a tiny bit of C++ has crept into the front-end. A competent Fortran programmer could read 1st edition K&R C (a ~200 page book) in a week or two, and have sufficient knowledge to hack on gfortran. The fortunate thing is that one has 25+ years of code to read to learn more.

If someone is interested in contributing to gfortran, then

  1. Subscribe to fortran@gcc.gnu.org list and introduce yourself
  2. Go to GFortran - GCC Wiki and scan it. There is a “For gfortran developers” section. Heck, updating and fixing the wiki would be a welcomed contribution.
  3. In that section, you’ll find a link to gfortran bugs. Follow the link and scan the bug list. Are there bugs that peak your interest? Read the bug reports. Some may have WIP patches.
  4. Start asking questions on fortran@

The unfortunate part is that many to old contributors have stopped participating on fortran@, so you’ll need to be patient with responses.

10 Likes

Just hypothetically, what would one need to study or look through to be able to write a compiler in Fortran ?

You need to have some knowledge of how compilers are engineered: lexer, parser, semantic analysis but not necessarily be an expert on that.
If you are developing a new compiler you will most likely want llvm bindings (probably the C api at least until we have better generics support).
Most parser and lexer generators target C and C++ so you would need to add a Fortran target or more likely write the parser and lexer yourself.

Rustc was initially written in Ocaml, maybe LFortran could be rewritten in Fortran in some very distant future.

1 Like

Thanks, for posting this. I almost feel like this (or some version of it) should be a separate post for people to find easily i.e. “Contributing to GFortran”. Do you have any other bits of advice on getting new contributors started with gfortran?

2 Likes

I’ve been thinking about the idea a bit: Brad Richardson / lets-build-a-compiler · GitLab . I don’t expect to have real time to devote to the effort any time soon though.

As @meow464 said, you’ll likely have to write the parser manually, rather than be able to use any of the existing generator tools.

2 Likes

Another question:
@everythingfunctional @RonShepard @meow464
What would be the benefit of eating our own dog food “Cutting out the middle man” (I like this quote better) and writing the compiler in pure Fortran ?

(forgive my naive question)

Here is a general article on the subject.

In general, in our case it would mean one less language to master before being able to contribute to future compiler developments. Other benefits are that the tools that are developed to support the compiler can also be used for other unrelated projects.

1 Like

There are now three different free modern Fortran compilers (gfortran, lfortran and flang, which exists in a traditional and a “from scratch” version). One the one hand this is good, on the other hand, each of these compilers would profit from more manpower. So I don’t think a fouth free modern Fortran compiler would really be beneficial.

Furthermore these compilers profit from the existing llvn/gcc infrastructure, which has matured for at least a decade (or 3 in the case of gcc).

So while a Fortran compiler that can compile itself sounds like a nice idea, I do not really believe the Fortran community should increase the number of free compilers.

Disclaimer: My practical experience in building compilers is exactly zero, so take everything I wrote with a large grain of salt.

6 Likes

I appreciate and respect your opinion none the less.

However, I must push back.
The argument I have against this is that there is one common lisp implementation, yet there are different common lisp compilers each offering different things.

At one point in time there were more than three Fortran compilers, why then did those compiler manufacturers not use your argument ?

My point is how long do we have to wait until the proverbial well runs dry of gfortran devs ?
If we make a compiler in Fortran, we reduce the overhead required to contribute to the compiler.

1 Like

I would also add intel’s ifort and ifx compilers to that list. They are now also freely available, so that makes five compilers, not three.

And one reason for a fortran-based fortran compiler is exactly to address the manpower issue.

As for whether reading the K&R C book is sufficient to contribute to the gfortran effort, consider the following. Here is the very first program in that book, on page 6:

main()
{
  printf("hello, world\n");
}

Here is what happens when you try to run it.

$ gcc hello.c
hello.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main()
^
hello.c:3:3: error: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Werror,-Wimplicit-function-declaration]
  printf("hello, world\n");
  ^
hello.c:3:3: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning and 1 error generated.

I do know enough C to know how to fix these problems, but my point is that the C language has changed over the last four decades, just as fortran has changed, and it is sometimes difficult to keep up with all of the changes.

3 Likes

I know that’s not the main point of your post, but I really had to double check. In my book, there is an extra #include <stdio.h> before main.
Maybe that’s from the first version of the book (I have the second)?

Thank you for explaing the motivation

One question: Do you think of a pure frontend, or also a backend (that cares about CPU-specific optimizations ect)?

I am not opposed to writing a compiler in Fortran and actually believe the fields where Fortran is used should not become to specialized.
And I do not want to be the one that contributes nothing, but tells people what can/should not be done

I am just a bit concerned wheter the intersection of people interested in Fortran (most of them are rather natural than computer scientists) and people able to and willing to contribute to writing a compiler (for free) is limited and a fully standard- conforming compiler requires years of work.

The development of gfortran to the current state took about 20 years.

By the way, while Steve is concerned about the current state of gfortran, I still want to thank the developers (like him) for providing a free, and platform-dependent optimizing Compiler for modern Fortran. I am not sure whether this community would exist without gfortran.

I can not judge whether a switch to Fortran to write a compiler would motivate more people.
I agree that a lot of compilers (e.g. Free Pascal ect.) aim to be self-hosting.

2 Likes

With “free” I actually meant open-source and not bound the a vendor company, so that (in theory) everyone who is interested can contribute.

Still it is great that Intel provides a high-quality Fortran compiler and there is still competition like NAG.

I am not sure about this, I have to read up a lot more on compilers to answer this.

Again, I don’t know why it took this long. Only the compiler devs know why.

1 Like