-fno-math-errno by default

David Schultz das at freebsd.org
Mon Feb 7 18:45:32 UTC 2011


On Mon, Feb 07, 2011, Roman Divacky wrote:
> should clang follow the same and default to -fno-math-errno
> on FreeBSD?
> 
> I guess so but I want to be sure, thank you!

Yes.  All the flag does, at least in gcc, is inform the compiler
that we don't have an old System V-style math library that sets
errno instead of using floating point exception flags.

The flag affects the way gcc handles built-in math functions.  For
instance, with -fno-math-errno, gcc is able to inline sqrt(x) into
a single instruction.  Without the flag, however, gcc wrongly
assumes that sqrt(3) might set errno, so it generates extra code
to check the sign of x and call the math library if x is negative.


More information about the freebsd-toolchain mailing list