public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Tim Van Holder <tim.vanholder@anubex.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: G++ creates unusable executable with -gdwarf-5 -Og, without any diagnostic issued
Date: Thu, 26 Mar 2020 08:40:58 +0000	[thread overview]
Message-ID: <AM6PR08MB3942C1B49DE4C8B0F5F8BDCE8FCF0@AM6PR08MB3942.eurprd08.prod.outlook.com> (raw)

Relevant package versions (all the current latest):


  *   Cygwin: 3.1.4
  *   binutils: 2.43+1git.de9c1b7cfe-1
  *   gcc-core, gcc-g++, libgcc1, libstdc++6: 9.3.0-1

Sample program (foo.cc):

#include <iostream>

using namespace std;

int
main(void)
{
  cout << "OK" << endl;
  return 0;
}

With a plain g++ foo.cc -o foo, I get a foo.exe that prints "OK".

However, with g++ -gdwarf-5 -Og foo.cc -o foo, I get a binary that reports
 -bash: ./foo.exe: cannot execute binary file: Exec format error
when run.
GDB can load the binary and show symbols just fine, but trying to run results in:
  Error creating process /cygdrive/.../foo.exe, (error 193).

Using -gdwarf-4 instead of -gdwarf-5 or dropping -Og makes the problem go away.
It also seems to be c++-specific; a C version of the sample program resulted in a working program
(could just be because a C++ program with iostream pulls in more, triggering the issue).

                 reply	other threads:[~2020-03-26  8:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR08MB3942C1B49DE4C8B0F5F8BDCE8FCF0@AM6PR08MB3942.eurprd08.prod.outlook.com \
    --to=tim.vanholder@anubex.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).