[PATCH v3] Change default to -fno-math-errno

Jeff Law law@redhat.com
Thu Jun 21 22:53:00 GMT 2018


On 06/18/2018 10:46 AM, Joseph Myers wrote:
> On Mon, 18 Jun 2018, Jeff Law wrote:
> 
>> So do we need to set or check math_errhandling & MATH_ERRNO at all?  Or
> 
> That's a matter for libc (glibc currently sets it based on __FAST_MATH__ / 
> __NO_MATH_ERRNO__, but fails to avoid including MATH_ERREXCEPT in the 
> definition for configurations not supporting exceptions).
> 
>> WRT library behavior, I thought it was only complex arithmetic that had
>> the option of setting errno.  I thought float/double math functions had
>> a requirement to set errno?
> 
> For complex.h functions it's always optional.  For math.h functions at 
> least one of errno and exceptions must be set, as indicated in the 
> definition of math_errhandling (and if math_errhandling is defined to just 
> one of MATH_ERRNO and MATH_ERREXCEPT, functions then may or may not also 
> indicate errors in the other way).  Hence the question of whether a 
> -fno-math-errno default should be different for (mainly soft-float) 
> configurations not supporting floating-point exceptions, for which errno 
> is the only way they have available to indicate errors.
> 
Ah.  THanks for explaining things.

I think all this implies that the setting of -fno-math-errno by default
really depends on the math library in use since it's the library that
has to arrange for either errno to get set or for an exception to be raised.

I don't know enough about the various math runtimes to even hazard a
guess about the behavior of each.  glibc, musl, ulibc, newlib... THen
there's the alterate libraries from Intel & AMD and the proprietary Unix
math runtimes.  Ugh.

With that in mind ISTM that we may be best off keeping the default
as-is, but overriding it for libraries which we know are going to throw
exceptions rather than set errno.

Thoughts?

jeff



More information about the Gcc-patches mailing list