On Mon, Feb 7, 2011 at 2:48 AM, Gerald Pfeifer <ger...@pfeifer.com> wrote: > David Schultz noticed that the FreeBSD libm does not set errno, never > has done, and never will, and thus has made -fno-math-errno the default > in the (old, GCC 4.2-based) system compiler: > > http://svn.freebsd.org/viewvc/base?view=revision&revision=181538 > > > We should also make this change for GCC 4.6 and possibly retroactively > GCC 4.5 since we are giving away performance for nothing. > > > Our documentation already notes that this is the case on Darwin > > On Darwin systems, the math library never sets @code{errno}. There is > therefore no reason for the compiler to consider the possibility that > it might, and @option{-fno-math-errno} is the default. > > which hacks config/i386/i386.c as follows: > > ix86_option_init_struct (struct gcc_options *opts) > { > if (TARGET_MACHO) > /* The Darwin libraries never set errno, so we might as well > avoid calling them when that's the only reason we would. */ > opts->x_flag_errno_math = 0; > > I guess I could just add a check for FSB_MAJOR there, but that would > only address i386. Is there a better way to accomplish this?
A new target macro/hook would be needed for that I think. But see also recent discussion about frontends wanting to change these defaults (and that not working anymore). Does FreeBSD ever set errno for malloc() calls? See PR47179 and PR42944 - which means it might require splitting the flag into a math piece and a general piece (or one covering just malloc & friends). Richard.