How to default to -fno-math-errno on all FreeBSD targets

Submitted by Gerald Pfeifer on Feb. 16, 2011, 12:09 a.m.

Details

Message ID alpine.LFD.2.02.1102160100560.2792@ybpnyubfg6.ybpnyqbznva6
State New
Headers show

Commit Message

Gerald Pfeifer Feb. 16, 2011, 12:09 a.m.
[ gcc -> gcc-patches ]

On Mon, 7 Feb 2011, Richard Guenther wrote:
> 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).

For the time being, and understanding the malloc() issue, how about a 
change like the following for the time being so that we are at least
on par with Darwin here?  This really is an efficiency killer.

This also brings upstream GCC in line with the system compiler, at
least on x86.

Gerald

PS: Passes bootstrap and testing, and I'll add a ChangeLog if approved.

Comments

Mike Stump Feb. 16, 2011, 1:34 a.m.
On Feb 15, 2011, at 4:09 PM, Gerald Pfeifer wrote:
> On Mon, 7 Feb 2011, Richard Guenther wrote:
>> 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).
> 
> For the time being, and understanding the malloc() issue, how about a 
> change like the following for the time being so that we are at least
> on par with Darwin here?

No, this is wrong.  It confuses the build compiler with the target compiler.  If you're doing native, it would work, but cross and canadian cross compilers won't work in general.

You can put -DFREEBSD_TARGET in t-freebsd, and then you can test that, if you wanted to.  Another, probably better approach would be to put this into freebsd.h, and then make use of that information in some way to do this.  For example:

freebsd.h:
#define FREEBSD_NEVER_SETS_ERRNO 1

and in i386.c:

#ifdef FREEBSD_NEVER_SETS_ERRNO
	if (FREEBSD_NEVER_SETS_ERRNO)
	  opts->x_flag_errno_math = 0;
#endif

Patch hide | download patch | download mbox

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 170202)
+++ config/i386/i386.c	(working copy)
@@ -5156,6 +5156,11 @@ 
        avoid calling them when that's the only reason we would.  */
     opts->x_flag_errno_math = 0;
 
+#ifdef __FreeBSD__
+  /* FreeBSD libm never sets errno, so we do not need to bother, too.  */
+  opts->x_flag_errno_math = 0;
+#endif
+
   opts->x_flag_pcc_struct_return = 2;
   opts->x_flag_asynchronous_unwind_tables = 2;
   opts->x_flag_vect_cost_model = 1;