This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to default to -fno-math-errno on all FreeBSD targets
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: gcc at gcc dot gnu dot org, David Schultz <das at freebsd dot org>, Loren James Rittle <rittle at labs dot mot dot com>
- Date: Mon, 7 Feb 2011 11:55:49 +0100
- Subject: Re: How to default to -fno-math-errno on all FreeBSD targets
- References: <alpine.LNX.2.00.1102070124510.8943@gerinyyl>
On Mon, Feb 7, 2011 at 2:48 AM, Gerald Pfeifer <gerald@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.