public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables
@ 2021-01-18 14:29 brechtsanders at users dot sourceforge.net
  2021-01-18 14:32 ` [Bug c/98729] " brechtsanders at users dot sourceforge.net
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-18 14:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

            Bug ID: 98729
           Summary: GCC 11 MinGW Windows build doesn't generate working PE
                    executables
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: brechtsanders at users dot sourceforge.net
  Target Milestone: ---

Created attachment 49994
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49994&action=edit
Invalid Windows .exe PE file

When I try to build GCC 11 for MinGW (using MinGW-w64 8.0.0) configure fails
(on both 32-bit and 64-bit) when it's trying to test if it can run a compiled
.exe file.

When I replicate this command with:
`echo "int main () { return 0; }" |
/R/winlibs64_stage/gcc-11-20210117/build_mingw/./gcc/xgcc
-B/R/winlibs64_stage/gcc-11-20210117/build_mingw/./gcc/
-L/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/x86_64-w64-mingw32/lib
-L/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/mingw/lib -isystem
/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/x86_64-w64-mingw32/include
-isystem /R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/mingw/include
-B/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/x86_64-w64-mingw32/bin/
-B/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/x86_64-w64-mingw32/lib/
-isystem
/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/x86_64-w64-mingw32/include
-isystem
/R/winlibs64_stage/inst_gcc-11-20210117/share/gcc/x86_64-w64-mingw32/sys-include
--sysroot=/R/winlibs64_stage/gcc-11-20210117/build_mingw/mingw-w64   -o
conftest.exe -g -O2 -xc -`
it builds `conftest.exe`, but running it (fro MSYS2 bash shell) with
`conftest.exe` fails with error `bash: ./conftest.exe: cannot execute binary
file: Exec format error`, or when I run it from Windows or Command prompt it
pops up a message saying `This app can't run on your PC`.

The command `file conftest.exe` does return `conftest.exe: PE32+ executable
(console) x86-64, for MS Windows`.

I have attached this file.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c/98729] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
@ 2021-01-18 14:32 ` brechtsanders at users dot sourceforge.net
  2021-01-18 16:40 ` [Bug target/98729] " pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-18 14:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #1 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
I have discovered that adding `-s` to the above build command or stripping the
.exe file with `strip` does allow it to run. So probably something is messed up
in the debugging symbols section.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
  2021-01-18 14:32 ` [Bug c/98729] " brechtsanders at users dot sourceforge.net
@ 2021-01-18 16:40 ` pinskia at gcc dot gnu.org
  2021-01-18 17:16 ` brechtsanders at users dot sourceforge.net
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-01-18 16:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
this sounds more like it is a bug in binutils rather than GCC.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
  2021-01-18 14:32 ` [Bug c/98729] " brechtsanders at users dot sourceforge.net
  2021-01-18 16:40 ` [Bug target/98729] " pinskia at gcc dot gnu.org
@ 2021-01-18 17:16 ` brechtsanders at users dot sourceforge.net
  2021-01-19  7:38 ` [Bug target/98729] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-18 17:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #3 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Strange, I'm using the same binutils to build GCC 10.2.0 and have no issues
there.

Configuring the GCC build with `LDFLAGS_FOR_TARGET="-s"` works around this
issue for now, but only for win64. For the win32 build libgfortran fails with
`libgfortran/generated/matmul_c8.c:126: undefined reference to 'LC5'`

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (2 preceding siblings ...)
  2021-01-18 17:16 ` brechtsanders at users dot sourceforge.net
@ 2021-01-19  7:38 ` rguenth at gcc dot gnu.org
  2021-01-19  7:41 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-19  7:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
            Summary|GCC 11 MinGW Windows build  |[11 Regression] GCC 11
                   |doesn't generate working PE |MinGW Windows build doesn't
                   |executables                 |generate working PE
                   |                            |executables
             Target|                            |mingw-w64

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Maybe another -gdwarf5 issue?  does MingW use DWARF debug?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (3 preceding siblings ...)
  2021-01-19  7:38 ` [Bug target/98729] [11 Regression] " rguenth at gcc dot gnu.org
@ 2021-01-19  7:41 ` rguenth at gcc dot gnu.org
  2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-19  7:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yes, the attached file contains DWARF 5 debug info.  Try to build the test
file with -gdwarf-4 and see if that makes it work.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (4 preceding siblings ...)
  2021-01-19  7:41 ` rguenth at gcc dot gnu.org
@ 2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
  2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-19 19:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #6 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Created attachment 50004
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50004&action=edit
test built with -gdwarf-4

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (5 preceding siblings ...)
  2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
@ 2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
  2021-01-20  9:23 ` brechtsanders at users dot sourceforge.net
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-19 19:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #7 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Adding flag `-gdwarf-4` to the above command still results in a file that won't
execute, see attached file `conftest-gdwarf-4.exe`

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (6 preceding siblings ...)
  2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
@ 2021-01-20  9:23 ` brechtsanders at users dot sourceforge.net
  2021-01-20 12:40 ` brechtsanders at users dot sourceforge.net
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-20  9:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #8 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Also, my win64 build uses SEH, not dwarf, so it doesn't look like dwarf is the
issue. I also tried to build with `--enable-compressed-debug-sections=none`,
but that fix the problem either.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (7 preceding siblings ...)
  2021-01-20  9:23 ` brechtsanders at users dot sourceforge.net
@ 2021-01-20 12:40 ` brechtsanders at users dot sourceforge.net
  2021-02-01 17:39 ` ebotcazou at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-01-20 12:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #9 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
The attached .exe will run on Windows after removing the section called `/20`
from the PE file using: `strip conftest.exe --remove-section="/20"`

I don't know what this section does, but I did notice it contains a reference
to `cygwin.S`, which I didn't expect to see in a pure MinGW binary.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (8 preceding siblings ...)
  2021-01-20 12:40 ` brechtsanders at users dot sourceforge.net
@ 2021-02-01 17:39 ` ebotcazou at gcc dot gnu.org
  2021-02-02  8:51 ` brechtsanders at users dot sourceforge.net
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-02-01 17:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2021-02-01

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> I don't know what this section does, but I did notice it contains a
> reference to `cygwin.S`, which I didn't expect to see in a pure MinGW binary.

The file just implements the stack checking routine mandated by Windows.

Can you post the list of sections given by objdump?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (9 preceding siblings ...)
  2021-02-01 17:39 ` ebotcazou at gcc dot gnu.org
@ 2021-02-02  8:51 ` brechtsanders at users dot sourceforge.net
  2021-02-02 12:05 ` ebotcazou at gcc dot gnu.org
  2021-02-09 20:21 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: brechtsanders at users dot sourceforge.net @ 2021-02-02  8:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #11 from Brecht Sanders <brechtsanders at users dot sourceforge.net> ---
Created attachment 50113
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50113&action=edit
objdump -h

List of sections attached (created using `objdump -h`)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (10 preceding siblings ...)
  2021-02-02  8:51 ` brechtsanders at users dot sourceforge.net
@ 2021-02-02 12:05 ` ebotcazou at gcc dot gnu.org
  2021-02-09 20:21 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2021-02-02 12:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---


*** This bug has been marked as a duplicate of bug 98860 ***

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/98729] [11 Regression] GCC 11 MinGW Windows build doesn't generate working PE executables
  2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
                   ` (11 preceding siblings ...)
  2021-02-02 12:05 ` ebotcazou at gcc dot gnu.org
@ 2021-02-09 20:21 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-02-09 20:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98729

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Brecht Sanders from comment #8)
> Also, my win64 build uses SEH, not dwarf,

DWARF is still used for debug info even if you don't use it for EH.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-02-09 20:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 14:29 [Bug c/98729] New: GCC 11 MinGW Windows build doesn't generate working PE executables brechtsanders at users dot sourceforge.net
2021-01-18 14:32 ` [Bug c/98729] " brechtsanders at users dot sourceforge.net
2021-01-18 16:40 ` [Bug target/98729] " pinskia at gcc dot gnu.org
2021-01-18 17:16 ` brechtsanders at users dot sourceforge.net
2021-01-19  7:38 ` [Bug target/98729] [11 Regression] " rguenth at gcc dot gnu.org
2021-01-19  7:41 ` rguenth at gcc dot gnu.org
2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
2021-01-19 19:06 ` brechtsanders at users dot sourceforge.net
2021-01-20  9:23 ` brechtsanders at users dot sourceforge.net
2021-01-20 12:40 ` brechtsanders at users dot sourceforge.net
2021-02-01 17:39 ` ebotcazou at gcc dot gnu.org
2021-02-02  8:51 ` brechtsanders at users dot sourceforge.net
2021-02-02 12:05 ` ebotcazou at gcc dot gnu.org
2021-02-09 20:21 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).