From: Rainer Orth Date: Wed, 1 Jun 2011 14:49:21 +0000 (+0000) Subject: crtfastmath.c: Include , . X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0699e415bc4e5ecac90580da110ee5fe14b60c38;p=gcc.git crtfastmath.c: Include , . gcc: * config/i386/crtfastmath.c [!__x86_64__ && __sun__ && __svr4__]: Include , . (sigill_caught): Define. (sigill_hdlr): New function. (set_fast_math) [!__x86_64__ && __sun__ && __svr4__]: Check if SSE insns can be executed. * config/sol2.h (ENDFILE_SPEC): Use crtfastmath.o if -ffast-math etc. * config/sparc/sol2.h (ENDFILE_SPEC): Remove. libgcc: * config.host (i[34567]86-*-solaris2*): Add i386/t-crtfm to tmake_file. Add crtfastmath.o to extra_parts. From-SVN: r174532 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 72fc84bbc1c..db9ecb4296d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2011-06-01 Rainer Orth + + * config/i386/crtfastmath.c [!__x86_64__ && __sun__ && __svr4__]: + Include , . + (sigill_caught): Define. + (sigill_hdlr): New function. + (set_fast_math) [!__x86_64__ && __sun__ && __svr4__]: Check if SSE + insns can be executed. + * config/sol2.h (ENDFILE_SPEC): Use crtfastmath.o if -ffast-math + etc. + * config/sparc/sol2.h (ENDFILE_SPEC): Remove. + 2011-06-01 Rainer Orth * config/t-slibgcc-darwin: Move to ... diff --git a/gcc/config/i386/crtfastmath.c b/gcc/config/i386/crtfastmath.c index 1c1ce2c7860..a80e2ede3ee 100644 --- a/gcc/config/i386/crtfastmath.c +++ b/gcc/config/i386/crtfastmath.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. + * Copyright (C) 2005, 2007, 2009, 2011 Free Software Foundation, Inc. * * This file is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -30,6 +30,26 @@ #include "cpuid.h" #endif +#if !defined __x86_64 && defined __sun__ && defined __svr4__ +#include +#include + +static volatile sig_atomic_t sigill_caught; + +static void +sigill_hdlr (int sig __attribute((unused)), + siginfo_t *sip __attribute__((unused)), + ucontext_t *ucp) +{ + sigill_caught = 1; + /* Set PC to the instruction after the faulting one to skip over it, + otherwise we enter an infinite loop. 4 is the size of the stmxcsr + instruction. */ + ucp->uc_mcontext.gregs[EIP] += 4; + setcontext (ucp); +} +#endif + static void __attribute__((constructor)) #ifndef __x86_64__ /* The i386 ABI only requires 4-byte stack alignment, so this is necessary @@ -47,9 +67,31 @@ set_fast_math (void) if (edx & bit_SSE) { - unsigned int mxcsr = __builtin_ia32_stmxcsr (); + unsigned int mxcsr; - mxcsr |= MXCSR_FTZ; +#if defined __sun__ && defined __svr4__ + /* Solaris 2 before Solaris 9 4/04 cannot execute SSE instructions even + if the CPU supports them. Programs receive SIGILL instead, so check + for that at runtime. */ + struct sigaction act, oact; + + act.sa_handler = sigill_hdlr; + sigemptyset (&act.sa_mask); + /* Need to set SA_SIGINFO so a ucontext_t * is passed to the handler. */ + act.sa_flags = SA_SIGINFO; + sigaction (SIGILL, &act, &oact); + + /* We need a single SSE instruction here so the handler can safely skip + over it. */ + __asm__ volatile ("movss %xmm2,%xmm1"); + + sigaction (SIGILL, &oact, NULL); + + if (sigill_caught) + return; +#endif /* __sun__ && __svr4__ */ + + mxcsr = __builtin_ia32_stmxcsr () | MXCSR_FTZ; if (edx & bit_FXSAVE) { diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index cf7574830f0..3d539d7ec5b 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -141,7 +141,9 @@ along with GCC; see the file COPYING3. If not see %{p|pg:-ldl} -lc}" #undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtend.o%s crtn.o%s" +#define ENDFILE_SPEC \ + "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ + crtend.o%s crtn.o%s" /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */ #undef STARTFILE_SPEC diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h index a53b82a8e95..ddc7c4db68a 100644 --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -117,11 +117,6 @@ along with GCC; see the file COPYING3. If not see #define NO_DBX_BNSYM_ENSYM 1 -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ - crtend.o%s crtn.o%s" - /* Select a format to encode pointers in exception handling data. CODE is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is true if the symbol may be affected by dynamic relocations. diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 7aa390477b9..d4d87a5e990 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2011-06-01 Rainer Orth + + * config.host (i[34567]86-*-solaris2*): Add i386/t-crtfm to + tmake_file. + Add crtfastmath.o to extra_parts. + 2011-06-01 Rainer Orth * config/gmon-sol2.c: Reindent. diff --git a/libgcc/config.host b/libgcc/config.host index 8b1113b9067..f064952485d 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -338,6 +338,8 @@ i[34567]86-*-rtems*) tmake_file="${tmake_file} t-crtin i386/t-softfp i386/t-crtstuff t-rtems" ;; i[34567]86-*-solaris2*) + tmake_file="$tmake_file i386/t-crtfm" + extra_parts="$extra_parts crtfastmath.o" ;; i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae) ;;