This fixes a compilation error preventing bootstrap with Ada on
x86_64-pc-cygwin. See PR bootstrap/94918 for details.

Compared to the initial patch sent in May 2020, this v2 patch places
the fix in Ada's raise-gcc.c instead of the shared unwind-generic.h,
which should hopefully simplify getting it applied.

Tested by bootstrapping this and the preliminary workaround for
PR98590 on x86_64-pc-cygwin.

Ok for master and branches?

(Patch also attached to protect it against gmail formatting.)

gcc/ada/

2021-01-10  Mikael Pettersson  <mikpeli...@gmail.com>

        PR bootstrap/94918
        * raise-gcc.c: (__SEH__): Prevent windows.h from including
        x86intrin.h or emmintrin.h on Cygwin64.

--- gcc-11-20210103/gcc/ada/raise-gcc.c.~1~     2021-01-03
23:32:14.000000000 +0100
+++ gcc-11-20210103/gcc/ada/raise-gcc.c 2021-01-10 11:13:07.878685936 +0100
@@ -79,6 +79,15 @@ typedef char bool;
    (SJLJ or DWARF). We need a consistently named interface to import from
    a-except, so wrappers are defined here.  */

+#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__) && \
+    defined (__CYGWIN__) && !defined (__CYGWIN32__) && !defined (IN_RTS)
+/* Note: windows.h (via unwind-generic.h) on cygwin-64 includes x86intrin.h
+   which uses malloc. That fails to compile if malloc is poisoned, i.e. if
+   !IN_RTS.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
+#endif
+
 #ifndef IN_RTS
   /* For gnat1/gnatbind compilation: cannot use unwind.h, as it is for the
      target. So mimic configure...
gcc/ada/

2021-01-10  Mikael Pettersson  <mikpeli...@gmail.com>

	PR bootstrap/94918
	* raise-gcc.c: (__SEH__): Prevent windows.h from including
	x86intrin.h or emmintrin.h on Cygwin64.

--- gcc-11-20210103/gcc/ada/raise-gcc.c.~1~	2021-01-03 23:32:14.000000000 +0100
+++ gcc-11-20210103/gcc/ada/raise-gcc.c	2021-01-10 11:13:07.878685936 +0100
@@ -79,6 +79,15 @@ typedef char bool;
    (SJLJ or DWARF). We need a consistently named interface to import from
    a-except, so wrappers are defined here.  */
 
+#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__) && \
+    defined (__CYGWIN__) && !defined (__CYGWIN32__) && !defined (IN_RTS)
+/* Note: windows.h (via unwind-generic.h) on cygwin-64 includes x86intrin.h
+   which uses malloc. That fails to compile if malloc is poisoned, i.e. if
+   !IN_RTS.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
+#endif
+
 #ifndef IN_RTS
   /* For gnat1/gnatbind compilation: cannot use unwind.h, as it is for the
      target. So mimic configure...

Reply via email to