JuliaPackaging/BinaryBuilderBase.jl

Use -fno-optimize-sibling-calls for Fortran libraries

Closed this issue · 6 comments

Newer gfortran compilers do more aggressive optimization that breaks the ABI for character arguments.

See JuliaLang/julia#32870 for a detailed description.
And a fix of a crash on power: JuliaLang/julia#38836

One remedy is passing -fno-optimize-sibling-calls to gfortran, which will prevent the optimizations that cause breakage. We may at least want to apply this for LAPACK (inside OpenBLAS) and a few other Fortran libraries.

Over time, packages that call fortran functions with character/string inputs should do the right thing.

I transferred the issue to BinaryBuilderBase because I thought we may want to do this for all libraries, directly in the compiler wrappers. But I'm not entirely sure this is the case to be honest 😅

@vchuravy Would it be a problem to do this by default for all fortran libraries? It seems safe to me to do so.

There were some benchmarks done, which showed that this option has little performance impact. On the other hand I would rather fix this with a fcall macro JuliaLang/julia#38872 that handles this properly instead of having folks rely on accidental behaviour.

I guess doing it in in BinaryBuilderBase is a good idea, since we can use it in a few builds, and then remove the flag when Julia upstream fixes it. But note that people are probably doing bad things in other non-Julia libraries too.

It would be nice to pass this flag directly to gfortran by default, so that it makes its way through all the libraries over time. What needs to happen for this?

Given that this really hasn't been much of an issue, I'm closing this.