[PATCH] fix pdp11_expand_epilogue (PR target/107841)

2023-07-13 Thread Mikael Pettersson via Gcc-patches
If the stack frame only contains an alloca area, then
pdp11_expand_epilogue fails to deallocate it, resulting
in callee-saved registers and the return address being
restored from the wrong stack slots.  Fixed by adding
|| cfun->calls_alloca to the condition for deallocating
the frame.

Tested with a cross to pdp11-unknown-aout.

Ok for master? (Note: I don't have commit rights.)

gcc/

PR target/107841
* config/pdp11/pdp11.c (pdp11_expand_epilogue): Also
deallocate alloca-only frame.

gcc/testsuite/

PR target/107841
* gcc.target/pdp11/pr107841.c: New test.
---
 gcc/config/pdp11/pdp11.cc |  2 +-
 gcc/testsuite/gcc.target/pdp11/pr107841.c | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/pdp11/pr107841.c

diff --git a/gcc/config/pdp11/pdp11.cc b/gcc/config/pdp11/pdp11.cc
index f6dd841f184..311a1d225e0 100644
--- a/gcc/config/pdp11/pdp11.cc
+++ b/gcc/config/pdp11/pdp11.cc
@@ -393,7 +393,7 @@ pdp11_expand_epilogue (void)
   rtx x, reg, via_ac = NULL;
 
   /* Deallocate the local variables.  */
-  if (fsize)
+  if (fsize || cfun->calls_alloca)
 {
   if (frame_pointer_needed)
{
diff --git a/gcc/testsuite/gcc.target/pdp11/pr107841.c 
b/gcc/testsuite/gcc.target/pdp11/pr107841.c
new file mode 100644
index 000..a363c468b0b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/pdp11/pr107841.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Verify that the stack frame is deallocated using the frame pointer.  */
+
+void qq (int a)
+{
+char *s = __builtin_alloca (128);
+__builtin_sprintf (s, "qq %d", 3);
+}
+
+/* { dg-final { scan-assembler "mov\tr5,sp" } } */
-- 
2.41.0



Re: [PATCH] add glibc-stdint.h to vax and lm32 linux target (PR target/105525)

2023-05-22 Thread Mikael Pettersson via Gcc-patches
On Mon, May 22, 2023 at 3:57 PM Jan-Benedict Glaw  wrote:
>
> Hi!
>
> On Mon, 2023-05-22 14:10:48 +0100, Maciej W. Rozycki  
> wrote:
> > On Fri, 19 May 2023, Mikael Pettersson wrote:
> > > The background is that I maintain a script to build GCC-based crosses to
> > > as many targets as I can, currently it supports 78 distinct processors and
> > > 82 triplets (four processors have multiple triplets). I only check that I 
> > > can
> > > build the toolchains (full linux-gnu ones where possible).
> >
> >  Great work, thanks!
>
> I'd be very much interested in running your script as one build
> variant for my http://toolchain.lug-owl.de/ efforts. Is it available
> somewhere? That would be nice!

The script is publicly available as https://github.com/mikpe/buildcross.git.
Usage for actively maintained toolchains is pretty easy. For example, to build
a cross to sparc64-unknown-linux-gnu you just run

buildcross -jN sparc64

and it will leave the toolchain in cross-sparc64. (Other bits will
land in downloads/,
sources/, and host-tools/.)

Many older targets require older gcc versions to even build, and may
not work well
as 64-bit builds, so for those the operator needs to provide overrides
via the environment,
see e.g. the comments for the "a29k" target. None of that is automated, sorry.

If you're only interested in linux-gnu toolchains for actively
maintained targets there's
a build-many-glibcs.py script in glibc that should be a better fit.

/Mikael


Re: [PATCH] add glibc-stdint.h to vax and lm32 linux target (PR target/105525)

2023-05-19 Thread Mikael Pettersson via Gcc-patches
On Fri, May 19, 2023 at 2:06 PM Maciej W. Rozycki  wrote:
>
> On Sat, 29 Apr 2023, Jeff Law via Gcc-patches wrote:
>
> > > PR target/105525 is a build regression for the vax and lm32 linux
> > > targets present in gcc-12/13/head, where the builds fail due to
> > > unsatisfied references to __INTPTR_TYPE__ and __UINTPTR_TYPE__,
> > > caused by these two targets failing to provide glibc-stdint.h.
> > >
> > > Fixed thusly, tested by building crosses, which now succeeds.
> > >
> > > Ok for trunk? (Note I don't have commit rights.)
> > >
> > > 2023-04-28  Mikael Pettersson
> > >
> > > PR target/105525
> > > * config.gcc (vax-*-linux*): Add glibc-stdint.h.
> > > (lm32-*-uclinux*): Likewise.
> > Thanks.  I've pushed this to the trunk.
>
>  Hmm, I find it quite insteresting and indeed encouraging that someone
> actually verifies our VAX/Linux target.
>
>  Mikael, how do you actually verify it however?

My vax builds are only cross-compilers without kernel headers or libc.

The background is that I maintain a script to build GCC-based crosses to
as many targets as I can, currently it supports 78 distinct processors and
82 triplets (four processors have multiple triplets). I only check that I can
build the toolchains (full linux-gnu ones where possible).

/Mikael

>  I'm asking because while I did a glibc port for VAX/Linux (including VAX
> floating-point format support), it was many years ago and for LinuxThreads
> configuration only (hence glibc 2.4 only), which I suspect may not be
> supported by GCC anymore.  And it has never made its way upstream, because
> we'd have to land Linux kernel bits there first and that effort has
> stalled.
>
>  I can still boot that old stuff on my VAX machine, but the userland is
> minimal and somewhat unstable as things sometimes crash or otherwise
> behave in a weird way.  I do have working `bash' and more importantly
> `gdbserver' binaries though.
>
>   Maciej


[PATCH] add glibc-stdint.h to vax and lm32 linux target (PR target/105525)

2023-04-28 Thread Mikael Pettersson via Gcc-patches
PR target/105525 is a build regression for the vax and lm32 linux
targets present in gcc-12/13/head, where the builds fail due to
unsatisfied references to __INTPTR_TYPE__ and __UINTPTR_TYPE__,
caused by these two targets failing to provide glibc-stdint.h.

Fixed thusly, tested by building crosses, which now succeeds.

Ok for trunk? (Note I don't have commit rights.)

2023-04-28  Mikael Pettersson  

PR target/105525
* config.gcc (vax-*-linux*): Add glibc-stdint.h.
(lm32-*-uclinux*): Likewise.
---
 gcc/config.gcc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 6fd1594480a..671c7e3b018 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2287,7 +2287,7 @@ lm32-*-rtems*)
tmake_file="${tmake_file} lm32/t-rtems"
  ;;
 lm32-*-uclinux*)
-tm_file="elfos.h ${tm_file} gnu-user.h linux.h lm32/uclinux-elf.h"
+tm_file="elfos.h ${tm_file} gnu-user.h linux.h glibc-stdint.h 
lm32/uclinux-elf.h"
tmake_file="${tmake_file} lm32/t-lm32"
 ;;
 m32r-*-elf*)
@@ -3488,7 +3488,7 @@ v850*-*-*)
use_gcc_stdint=wrap
;;
 vax-*-linux*)
-   tm_file="${tm_file} elfos.h gnu-user.h linux.h vax/elf.h vax/linux.h"
+   tm_file="${tm_file} elfos.h gnu-user.h linux.h glibc-stdint.h vax/elf.h 
vax/linux.h"
extra_options="${extra_options} vax/elf.opt"
;;
 vax-*-netbsdelf*)
-- 
2.40.0



Re: [PATCH v2] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2021-03-08 Thread Mikael Pettersson via Gcc-patches
On Mon, Mar 8, 2021 at 12:07 PM Eric Botcazou  wrote:
>
> > I wonder why we include  from this file at all,
> > and why it is not included from {t,}system.h instead which
> > is where system header specific fixups should be made
> > (and this one could be avoided because system headers
> > are included _before_ poisoning anything).
>
>  is the Mother of All Things on the platform so you don't want to
> include it liberally (although it can be tamed e.g. with WIN32_LEAN_AND_MEAN).
> Therefore including it from tsystem.h might be worse than the actual disease.
>
> Mikael, can you work around the problem by adding
>
> #ifdef __CYGWIN__
> #include "mingw32.h"
> #endif
>
> at the appropriate spot in raise-gcc.c instead?

This one worked. Is that what you had in mind?

* raise-gcc.c: On Cygwin include mingw32.h to prevent
windows.h from including x86intrin.h or emmintrin.h.
---
 gcc/ada/raise-gcc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c
index 1446bfaaeb7..b096eba1b75 100644
--- a/gcc/ada/raise-gcc.c
+++ b/gcc/ada/raise-gcc.c
@@ -79,6 +79,12 @@ typedef char bool;
(SJLJ or DWARF). We need a consistently named interface to import from
a-except, so wrappers are defined here.  */

+#ifdef __CYGWIN__
+/* Prevent compile error due to unwind-generic.h including ,
+   see comment above #include  in mingw32.h.  */
+#include "mingw32.h"
+#endif
+
 #ifndef IN_RTS
   /* For gnat1/gnatbind compilation: cannot use unwind.h, as it is for the
  target. So mimic configure...
From 44a276e7900a506ee4b6f85d25ae5d96a11bd91e Mon Sep 17 00:00:00 2001
From: Mikael Pettersson 
Date: Mon, 8 Mar 2021 22:31:16 +0100
Subject: [PATCH] 	PR bootstrap/94918

	* raise-gcc.c: On Cygwin include mingw32.h to prevent
	windows.h from including x86intrin.h or emmintrin.h.
---
 gcc/ada/raise-gcc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c
index 1446bfaaeb7..b096eba1b75 100644
--- a/gcc/ada/raise-gcc.c
+++ b/gcc/ada/raise-gcc.c
@@ -79,6 +79,12 @@ typedef char bool;
(SJLJ or DWARF). We need a consistently named interface to import from
a-except, so wrappers are defined here.  */
 
+#ifdef __CYGWIN__
+/* Prevent compile error due to unwind-generic.h including ,
+   see comment above #include  in mingw32.h.  */
+#include "mingw32.h"
+#endif
+
 #ifndef IN_RTS
   /* For gnat1/gnatbind compilation: cannot use unwind.h, as it is for the
  target. So mimic configure...
-- 
2.26.2



Re: [PATCH v2] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2021-03-07 Thread Mikael Pettersson via Gcc-patches
On Sun, Jan 10, 2021 at 2:04 PM Mikael Pettersson  wrote:
>
> On Sun, Jan 10, 2021 at 11:57 AM Arnaud Charlet  wrote:
> >
> > > 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.
> >
> > Not sure why. Applying it there looks incomplete and kludgy, don't you
> > agree?
>
> Ok, then here's v3 which places the fix in unwind-generic.h. The fix
> matches what Ada's mingw32.h does.
>
> Tested by bootstrapping this and the preliminary workaround for
> PR98590 on x86_64-pc-cygwin.
>
> Ok for master and branches?

Ping. This is currently the only blocker for bootstrapping gcc-11 with
Ada on Cygwin64.

>
> libgcc/
>
> 2021-01-10  Mikael Pettersson  
>
> PR bootstrap/94918
> * unwind-generic.h (__SEH__): Prevent windows.h from including
> x86intrin.h or emmintrin.h on Cygwin64.
>
> --- gcc-11-20210103/libgcc/unwind-generic.h.~1~ 2021-01-03
> 23:32:20.0 +0100
> +++ gcc-11-20210103/libgcc/unwind-generic.h 2021-01-09
> 14:51:16.262378715 +0100
> @@ -30,6 +30,12 @@
>
>  #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
>  /* Only for _GCC_specific_handler.  */
> +#if defined (__CYGWIN__) && !defined (__CYGWIN32__) && !defined (IN_RTS)
> +/* Note: windows.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
>  #include 
>  #endif


Re: [PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)

2021-02-26 Thread Mikael Pettersson via Gcc-patches
On Fri, Feb 5, 2021 at 2:59 PM Arnaud Charlet  wrote:
>
> > > We'd rather not have PR references in the source files, so please remove 
> > > it
> > > (it will be there as part of the commit log and git annotate).
> > >
> > > OK with the comment updated.
> >
> > Thanks, here's the revised patch.
>
> OK, thanks.

I forgot to mention that I don't have commit rights to gcc, so can
someone please commit this for me? Thanks.

>
> > gcc/ada/
> >
> > 2021-02-05  Mikael Pettersson  
> >
> > PR bootstrap/98590
> > * cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.
> >
> > diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
> > index 4e00dedbbd6..7d64277110b 100644
> > --- a/gcc/ada/cstreams.c
> > +++ b/gcc/ada/cstreams.c
> > @@ -37,6 +37,11 @@
> >  #define _FILE_OFFSET_BITS 64
> >  /* the define above will make off_t a 64bit type on GNU/Linux */
> >
> > +/* tell Cygwin's  to expose fileno_unlocked() */
> > +#if defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(_GNU_SOURCE)
> > +#define _GNU_SOURCE
> > +#endif
> > +
> >  #include 
> >  #include 
> >  #include 


[PATCH] don't enable DWARF5 by default on Windows (PR98860)

2021-02-08 Thread Mikael Pettersson via Gcc-patches
PR98860 is a gcc-11 regression where bootstrap fails on Windows since
the switch to enable DWARF5 by default. The symptoms are that
executables generated by the stage1 compiler fail to run with "Exec
format error", which confuses subsequent configure steps and causes
hard errors. This happens even with the very latest binutils master.

Fixed by updating SUBTARGET_OVERRIDE_OPTIONS to set dwarf_version to 4
unless the user explicitly requested another version. I see some other
targets did the same.

Tested on Cygwin64 and mingw-w64.

Ok for master?

2021-02-08  Mikael Pettersson  

PR bootstrap/98860
* config/i386/cygming.h (SUBTARGET_OVERRIDE_OPTIONS): Override
dwarf_version to 4.

--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -209,6 +209,9 @@ along with GCC; see the file COPYING3.  If not see
 #define SUBTARGET_OVERRIDE_OPTIONS \
 do {   \
   flag_pic = TARGET_64BIT ? 1 : 0;  \
+  /* DWARF5 currently does not work on Windows. */ \
+  if (!global_options_set.x_dwarf_version) \
+dwarf_version = 4; \
 } while (0)

 /* Define this macro if references to a symbol must be treated
From 9d1b9e26cc77d325fd5574cb422771588d6aa71f Mon Sep 17 00:00:00 2001
From: Mikael Pettersson 
Date: Sat, 6 Feb 2021 22:59:43 +0100
Subject: [PATCH] cygming: DWARF5 does not work on Windows

---
 gcc/config/i386/cygming.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index cfbca34f996..071f83cfd2d 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -209,6 +209,9 @@ along with GCC; see the file COPYING3.  If not see
 #define SUBTARGET_OVERRIDE_OPTIONS	\
 do {	\
   flag_pic = TARGET_64BIT ? 1 : 0;  \
+  /* DWARF5 currently does not work on Windows. */			\
+  if (!global_options_set.x_dwarf_version)\
+dwarf_version = 4;			\
 } while (0)
 
 /* Define this macro if references to a symbol must be treated
-- 
2.26.2



Re: [PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)

2021-02-05 Thread Mikael Pettersson via Gcc-patches
On Fri, Feb 5, 2021 at 9:35 AM Arnaud Charlet  wrote:
>
> > This fixes the bootstrap failure with Ada on Cygwin since the switch
> > to C++11. The configure checks detect that fileno_unlocked () is
> > present, but when Ada's cstreams.c is compiled in C++11 mode,
> >  does not declare it, causing a hard error.
> >
> > Fixed by defining _GNU_SOURCE before including .
> >
> > Ok for the master branch?
> >
> > gcc/ada/
> >
> > 2021-02-03  Mikael Pettersson  
> >
> > PR bootstrap/98590
> > * cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.
>
> We'd rather not have PR references in the source files, so please remove it
> (it will be there as part of the commit log and git annotate).
>
> OK with the comment updated.

Thanks, here's the revised patch.

gcc/ada/

2021-02-05  Mikael Pettersson  

PR bootstrap/98590
* cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.

diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
index 4e00dedbbd6..7d64277110b 100644
--- a/gcc/ada/cstreams.c
+++ b/gcc/ada/cstreams.c
@@ -37,6 +37,11 @@
 #define _FILE_OFFSET_BITS 64
 /* the define above will make off_t a 64bit type on GNU/Linux */

+/* tell Cygwin's  to expose fileno_unlocked() */
+#if defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+
 #include 
 #include 
 #include 
From f9b9b44f5341b0d8df7b1bb00de6f7231258891b Mon Sep 17 00:00:00 2001
From: Mikael Pettersson 
Date: Fri, 5 Feb 2021 14:43:52 +0100
Subject: [PATCH] Ensure fileno_unlocked() is visible on Cygwin.

---
 gcc/ada/cstreams.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
index 4e00dedbbd6..7d64277110b 100644
--- a/gcc/ada/cstreams.c
+++ b/gcc/ada/cstreams.c
@@ -37,6 +37,11 @@
 #define _FILE_OFFSET_BITS 64
 /* the define above will make off_t a 64bit type on GNU/Linux */
 
+/* tell Cygwin's  to expose fileno_unlocked() */
+#if defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+
 #include 
 #include 
 #include 
-- 
2.26.2



[PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)

2021-02-03 Thread Mikael Pettersson via Gcc-patches
This fixes the bootstrap failure with Ada on Cygwin since the switch
to C++11. The configure checks detect that fileno_unlocked () is
present, but when Ada's cstreams.c is compiled in C++11 mode,
 does not declare it, causing a hard error.

Fixed by defining _GNU_SOURCE before including .

Ok for the master branch?

gcc/ada/

2021-02-03  Mikael Pettersson  

PR bootstrap/98590
* cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.

diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
index 4e00dedbbd6..9d2f41c5269 100644
--- a/gcc/ada/cstreams.c
+++ b/gcc/ada/cstreams.c
@@ -37,6 +37,11 @@
 #define _FILE_OFFSET_BITS 64
 /* the define above will make off_t a 64bit type on GNU/Linux */

+/* tell Cygwin's  to expose fileno_unlocked() to work around
PR98590 */
+#if defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+
 #include 
 #include 
 #include 
From 7a277d8c2a6c1d4ccfbb0ca350e4b1f35a3e575c Mon Sep 17 00:00:00 2001
From: Mikael Pettersson 
Date: Wed, 3 Feb 2021 17:25:42 +0100
Subject: [PATCH] Ensure fileno_unlocked() is visible on Cygwin.

---
 gcc/ada/cstreams.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
index 4e00dedbbd6..9d2f41c5269 100644
--- a/gcc/ada/cstreams.c
+++ b/gcc/ada/cstreams.c
@@ -37,6 +37,11 @@
 #define _FILE_OFFSET_BITS 64
 /* the define above will make off_t a 64bit type on GNU/Linux */
 
+/* tell Cygwin's  to expose fileno_unlocked() to work around PR98590 */
+#if defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+
 #include 
 #include 
 #include 
-- 
2.26.2



Re: [PATCH v2] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2021-01-10 Thread Mikael Pettersson via Gcc-patches
On Sun, Jan 10, 2021 at 11:57 AM Arnaud Charlet  wrote:
>
> > 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.
>
> Not sure why. Applying it there looks incomplete and kludgy, don't you
> agree?

Ok, then here's v3 which places the fix in unwind-generic.h. The fix
matches what Ada's mingw32.h does.

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

Ok for master and branches?

libgcc/

2021-01-10  Mikael Pettersson  

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

--- gcc-11-20210103/libgcc/unwind-generic.h.~1~ 2021-01-03
23:32:20.0 +0100
+++ gcc-11-20210103/libgcc/unwind-generic.h 2021-01-09
14:51:16.262378715 +0100
@@ -30,6 +30,12 @@

 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#if defined (__CYGWIN__) && !defined (__CYGWIN32__) && !defined (IN_RTS)
+/* Note: windows.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
 #include 
 #endif
libgcc/

2021-01-10  Mikael Pettersson  

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

--- gcc-11-20210103/libgcc/unwind-generic.h.~1~	2021-01-03 23:32:20.0 +0100
+++ gcc-11-20210103/libgcc/unwind-generic.h	2021-01-09 14:51:16.262378715 +0100
@@ -30,6 +30,12 @@
 
 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#if defined (__CYGWIN__) && !defined (__CYGWIN32__) && !defined (IN_RTS)
+/* Note: windows.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
 #include 
 #endif
 


[PATCH v2] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2021-01-10 Thread Mikael Pettersson via Gcc-patches
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  

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.0 +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  

	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.0 +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...


Re: [PATCH] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2020-05-03 Thread Mikael Pettersson via Gcc-patches
On Sat, May 2, 2020 at 9:46 PM Arnaud Charlet  wrote:
>
> > This fixes three compilation errors preventing bootstrap of gcc-10/11
> > with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.
> >
> > Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
> > shared with mingw, also by building a cross to x86_64-w64-mingw32.
> >
> > Ok for master and gcc-10 branch?
>
> No, the libgnat/g-sercom__mingw.adb is wrong and isn't needed.
>
> If there is an issue, it would be in "s-oscons-tmplt.c" which is supposed
> to define Serial_Port_Descriptor as:
>
>subtype Serial_Port_Descriptor is System.Win32.HANDLE;
>
> See:
>
> #if defined (__MINGW32__) || defined (__CYGWIN__)
> # define TARGET_OS "Windows"
> # define Serial_Port_Descriptor "System.Win32.HANDLE"
> TXT("with System.Win32;")

Thanks, the "|| defined(__CYGWIN__)" is missing so
Serial_Port_Descriptor becomes "int" on Cygwin, triggering the error.
Revised patch below, re-tested on Cygwin64.

This fixes three compilation errors preventing bootstrap of gcc-10/11
with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.

Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
shared with mingw, also by building a cross to x86_64-w64-mingw32.

Ok for master and gcc-10 branch?

(I don't have commit rights, so I will need assistance with that.)

(The patch is also attached, since gmail _will_ corrupt this text.)

gcc/ada/

2020-05-03  Mikael Pettersson  

PR bootstrap/94918

* mingw32.h: Prevent windows.h from including emmintrin.h on Cygwin64.
* s-oscons-tmplt.c (Serial_Port_Descriptor): Define as
System.Win32.HANDLE also on Cygwin.

libgcc/

2020-05-03  Mikael Pettersson  

PR bootstrap/94918

* unwind-generic.h (__SEH__): Prevent windows.h from including
x86intrin.h and emmintrin.h.

--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02
17:18:44.196573200 +0200
@@ -56,6 +56,7 @@
 /* Note: windows.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
 #include 

--- gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c.~1~ 2020-04-30
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c 2020-05-03
11:06:32.958993300 +0200
@@ -261,7 +261,7 @@ main (void) {
 TXT("--  This is the version for " TARGET)
 TXT("")
 TXT("with Interfaces.C;")
-#if defined (__MINGW32__)
+#if defined (__MINGW32__) || defined (__CYGWIN__)
 # define TARGET_OS "Windows"
 # define Serial_Port_Descriptor "System.Win32.HANDLE"
 TXT("with System.Win32;")
--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02
17:18:44.212239100 +0200
@@ -30,6 +30,8 @@

 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #include 
 #endif
--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30 
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02 17:18:44.196573200 
+0200
@@ -56,6 +56,7 @@
 /* Note: windows.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
 #include 
 
--- gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c.~1~ 2020-04-30 
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c 2020-05-03 
11:06:32.958993300 +0200
@@ -261,7 +261,7 @@ main (void) {
 TXT("--  This is the version for " TARGET)
 TXT("")
 TXT("with Interfaces.C;")
-#if defined (__MINGW32__)
+#if defined (__MINGW32__) || defined (__CYGWIN__)
 # define TARGET_OS "Windows"
 # define Serial_Port_Descriptor "System.Win32.HANDLE"
 TXT("with System.Win32;")
--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30 
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02 
17:18:44.212239100 +0200
@@ -30,6 +30,8 @@
 
 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #include 
 #endif
 


[PATCH] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2020-05-02 Thread Mikael Pettersson via Gcc-patches
This fixes three compilation errors preventing bootstrap of gcc-10/11
with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.

Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
shared with mingw, also by building a cross to x86_64-w64-mingw32.

Ok for master and gcc-10 branch?

(I don't have commit rights, so I will need assistance with that.)

(The patch is also attached, since gmail _will_ corrupt this text.)

gcc/ada/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* mingw32.h: Prevent windows.h from including emmintrin.h on Cygwin64.
* libgnat/g-sercom__mingw.adb (Open): Insert missing type conversion.

libgcc/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* unwind-generic.h (__SEH__): Prevent windows.h from including
x86intrin.h and emmintrin.h.

--- gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb.~1~
 2020-04-30 22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb
2020-05-02 16:36:49.565719571 +0200
@@ -103,6 +103,7 @@ package body GNAT.Serial_Communications
is
   C_Name  : constant String := String (Name) & ASCII.NUL;
   Success : BOOL;
+  HFile   : HANDLE;
   pragma Unreferenced (Success);

begin
@@ -110,7 +111,7 @@ package body GNAT.Serial_Communications
  Success := CloseHandle (HANDLE (Port.H));
   end if;

-  Port.H := CreateFileA
+  HFile := CreateFileA
 (lpFileName=> C_Name (C_Name'First)'Address,
  dwDesiredAccess   => GENERIC_READ or GENERIC_WRITE,
  dwShareMode   => 0,
@@ -118,6 +119,7 @@ package body GNAT.Serial_Communications
  dwCreationDisposition => OPEN_EXISTING,
  dwFlagsAndAttributes  => 0,
  hTemplateFile => 0);
+  Port.H := Serial_Port_Descriptor (HFile);

   pragma Assert (INVALID_HANDLE_VALUE = -1);

--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02
16:36:44.485724702 +0200
@@ -56,6 +56,7 @@
 /* Note: windows.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
 #include 

--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02
16:36:44.485724702 +0200
@@ -30,6 +30,8 @@

 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #include 
 #endif
gcc/ada/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* mingw32.h: Prevent windows.h from including emmintrin.h on Cygwin64.
* libgnat/g-sercom__mingw.adb (Open): Insert missing type conversion.

libgcc/

2020-05-02  Mikael Pettersson  

PR bootstrap/94918

* unwind-generic.h (__SEH__): Prevent windows.h from including
x86intrin.h and emmintrin.h.

--- gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb.~1~  
2020-04-30 22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/libgnat/g-sercom__mingw.adb  2020-05-02 
16:36:49.565719571 +0200
@@ -103,6 +103,7 @@ package body GNAT.Serial_Communications
is
   C_Name  : constant String := String (Name) & ASCII.NUL;
   Success : BOOL;
+  HFile   : HANDLE;
   pragma Unreferenced (Success);
 
begin
@@ -110,7 +111,7 @@ package body GNAT.Serial_Communications
  Success := CloseHandle (HANDLE (Port.H));
   end if;
 
-  Port.H := CreateFileA
+  HFile := CreateFileA
 (lpFileName=> C_Name (C_Name'First)'Address,
  dwDesiredAccess   => GENERIC_READ or GENERIC_WRITE,
  dwShareMode   => 0,
@@ -118,6 +119,7 @@ package body GNAT.Serial_Communications
  dwCreationDisposition => OPEN_EXISTING,
  dwFlagsAndAttributes  => 0,
  hTemplateFile => 0);
+  Port.H := Serial_Port_Descriptor (HFile);
 
   pragma Assert (INVALID_HANDLE_VALUE = -1);
 
--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30 
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02 16:36:44.485724702 
+0200
@@ -56,6 +56,7 @@
 /* Note: windows.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
 #include 
 
--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30 
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02 
16:36:44.485724702 +0200
@@ -30,6 +30,8 @@
 
 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED