skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.7k stars 186 forks source link

Fortran removed? #12

Closed hsnyder closed 2 years ago

hsnyder commented 2 years ago

Just curious why Fortran was removed? I would guess that the reason for removal was just size and relatively low interest, but I'm not sure if there are deeper reasons than that. Is re-enabling Fortran as simple as adding it to the enabled languages and then dealing with libquadmath, or is it more difficult than that?

skeeto commented 2 years ago

I'd like to support gfortran, but just as I was starting to do so, it broke with Binutils 2.36. This was the Binutils update that introduced long-overdue PIE / dynamic base support for Mingw-w64, which I decided was more important than continuing to support gfortran. I haven't figured out how to fix it myself, and each GCC release I've checked if gfortran has been fixed upstream.

When I built the gfortran releases, yes, it was literally as simple as adding fortran to the enabled languages. You'll need it enabled in the bootstrap cross compiler, too, in order to cross-compile the gfortran runtime. Since you know about libquadmath, it sounds like you've already tried it yourself. If you know how to fix the libquadmath issue, I'd be happy to hear it!

If you're really itching for gfortran, there's a release/1.5 branch that trots along for a bit skipping the Binutils update commit, and in theory that could continue forward independently with more updates.

hsnyder commented 2 years ago

Ahhh interesting! I've built gfortran from source on Linux but I haven't tried the w64devkit dockerfile, I just grab your binary releases when I need a new version on windows. I was at one point able to get a working compiler with libquadmath disabled and static runtime libs built, but I don't remember the details off the top of my head. I will let you know if I do manage to get such a configuration working in w64devkit.

I don't fully understand your comment about the binutils release adding "long-overdue PIE / dynamic base support for Mingw-w64"... I found reference online to the --dynamicbase option producing broken executables in mingw-w64, but am I right that this only matters if you're compiling with --dynamicbase for the extra security of address space layout randomization?

skeeto commented 2 years ago

Revisiting this issue with a fresh perspective I was able to solve it very quickly. I just needed to add --with-pic to the GCC configuration so that libquadmath is build appropriately for ASLR. So gfortran works again, and I added a gfortran build to the releases for v1.9.0, and will include a gfortran build going forward.

this only matters if you're compiling with --dynamicbase for the extra security of address space layout randomization?

Starting with Binutils 2.36, dynamic base becomes mandatory. It was broken and unusable before 2.36, and now it's always enabled. On the major Linux distributions (where this is called PIE), it's been the default for some years now, which is why I called it overdue to Mingw-w64.