On Thu, 26 Nov 2020, Martin Husemann wrote: > > The VAX/NetBSD port however does use hardware FP in their libm as far as > > I can tell, so I guess it would be reasonable for libgfortran to do so as > > well. I haven't checked how correct their implementation actually is, but > > barring evidence otherwise I would assume they did the right thing. > > It does, but it is not totally correct in all places (due to gcc issues > some parts have not received good testing, and others clearly are broken, > eg. when tables are used that have not been adjusted for the different > limits in VAX float/double formats).
I have realised that with my VAX/Linux effort, more than 10 years ago, I did not encounter such issues, and I did port all the GCC components the compiler provided at the time (although the port of libjava could have been only partially functional as I didn't properly verify the IEEE<->VAX FP conversion stubs I have necessarily implemented), though what chose was 4.1.2 rather than the most recent version (to avoid the need to port NPTL right away). I should have tripped over this issue then, but I did not. So with the objective of this effort out of the way I have now looked into what happened with libgfortran here and realised that the cause of the compilation error was an attempt to provide a standard ISO C function missing from NetBSD's libc or libm (even though it's declared). Indeed: $ grep tgamma usr/include/math.h double tgamma(double); float tgammaf(float); long double tgammal(long double); $ readelf -s usr/lib/libc.so usr/lib/libm.so usr/lib/libc.a usr/lib/libm.a | grep tgamma $ So clearly something went wrong there and I think it's that that has to be fixed rather than the fallback implementations in libgfortran (which I gather have been only provided for legacy systems that do not implement a full ISO C environment and are no longer maintained). I suspect that once this function (and any other ones that may be missing) has been supplied by the system libraries libgfortran will just work out of the box. Here's the full list of math functions that the `configure' script in libgfortran reports as missing: checking for acosl... no checking for acoshf... no checking for acoshl... no checking for asinl... no checking for asinhf... no checking for asinhl... no checking for atan2l... no checking for atanl... no checking for atanhl... no checking for cosl... no checking for coshl... no checking for expl... no checking for fmaf... no checking for fma... no checking for fmal... no checking for frexpf... no checking for frexpl... no checking for logl... no checking for log10l... no checking for clog10f... no checking for clog10... no checking for clog10l... no checking for nextafterf... no checking for nextafter... no checking for nextafterl... no checking for lroundl... no checking for llroundf... no checking for llround... no checking for llroundl... no checking for sinl... no checking for sinhl... no checking for tanl... no checking for tanhl... no checking for erfcl... no checking for j0f... no checking for j1f... no checking for jnf... no checking for jnl... no checking for y0f... no checking for y1f... no checking for ynf... no checking for ynl... no checking for tgamma... no checking for tgammaf... no checking for lgammaf... no Except for the Bessel functions these are a part of ISO C; `long double' versions, some of which appear missing unlike their `float' or `double' counterparts, should probably just alias to the corresponding `double' versions as I doubt we want to get into the H-floating format, largely missing from actual VAX hardware and meant to be emulated by the OS. Please note that this is with NetBSD 9 rather than 9.1 (which has only been recently released and therefore I decided not to get distracted with an upgrade) and I don't know if it has been fixed in the latter release. Maciej