public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: LIU Hao <lh_mouse@126.com>
Cc: mizo 91 <mizo91@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: CreateProcess No such file or directory
Date: Thu, 22 Sep 2022 09:19:25 +0100	[thread overview]
Message-ID: <CAH6eHdTYCXGYR+yEvxWD_8fehjB7PcW_YNfzM+ufUMQAOKTjSA@mail.gmail.com> (raw)
In-Reply-To: <a76c146a-191a-2683-fe9e-14dd3ec0ba02@126.com>

On Thu, 22 Sept 2022 at 07:45, LIU Hao via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> 在 2022/9/21 00:02, mizo 91 via Gcc-help 写道:
> > Hello,
> >
> > I'm having trouble compiling simple test program on windows 10 with long
> > list of includes provided via '@response_file' argument
> >
> >
>
> Greetings. mingw-w64 developer speaking.
>
> As far as I can see, there are at least two issues about your report:
>
>
> The first, obvious issue is that the error message is incorrect. The reason for that is, if we take
> a look at 'libiberty/pex-win32.c' we see the following:
>
>    853   /* Create the child process.  */
>    854   pid = win32_spawn (executable, (flags & PEX_SEARCH) != 0,
>    855                      argv, env, dwCreationFlags, &si, &pi);
>    856   if (pid == (pid_t) -1)
>    857     pid = spawn_script (executable, argv, env, dwCreationFlags,
>    858                         &si, &pi);
>    859   if (pid == (pid_t) -1)
>    860     {
>    861       *err = ENOENT;
>    862       *errmsg = "CreateProcess";
>    863     }
>
> We also notice this is the only place where `"CreateProcess"` appears as a sole part of an error
> message.
>
> The cause of this issue is apparent: libiberty tries `win32_spawn`, and if for whatever reason it
> fails, it makes another attempt with `spawn_script`, and if it fails again, `*err` is always set to
> `ENOENT` i.e. `No such file or directory`, no matter why.

It seems to me that pex-win32.c should use GetLastError() (and maybe
FormatMessage) to get a Windows error code, rather than assuming
ENOENT.

Using C++ that would look something like:

std::string errmsg = "CreateProcess:" +
std::system_category().message(GetLastError());

Or maybe win32_spawn should call GetLastError() and convert that to an
errno value and store it in errno:

std::error_condition ec =
std::system_category().default_error_condition(GetLastError());
if (ec.category() == std::generic_category())
  errno = ec.value();
else
  errno = ENOENT; // or EINVAL might be better?

  parent reply	other threads:[~2022-09-22  8:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 16:02 mizo 91
2022-09-20 16:18 ` Richard Earnshaw
2022-09-20 17:17   ` mizo 91
2022-09-20 22:27     ` Tamar Christina
2022-09-21  2:42       ` fedor_qd
2022-09-21 15:27         ` mizo 91
2022-09-21 15:41           ` Tom Kacvinsky
2022-09-26  6:58           ` Re[2]: " fedor_qd
2022-09-22  6:44 ` LIU Hao
2022-09-22  7:35   ` mizo 91
2022-09-22  9:46     ` LIU Hao
2022-09-22 14:55       ` mizo 91
2022-09-22 16:04         ` LIU Hao
2022-09-22 16:50           ` mizo 91
2022-09-23 17:40             ` Xi Ruoyao
2022-09-23 21:11               ` mizo 91
2022-09-24  5:13                 ` Xi Ruoyao
2022-09-24  9:28                   ` mizo 91
2022-09-24  9:51                     ` Xi Ruoyao
2022-09-24 10:20                       ` Jonathan Wakely
2022-09-23 17:14         ` David Brown
2022-09-23 20:55           ` mizo 91
2022-09-22  8:19   ` Jonathan Wakely [this message]
2022-09-22  8:42     ` Jonathan Wakely
2022-09-22  9:48       ` LIU Hao
2022-09-22  9:50       ` mizo 91

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=CAH6eHdTYCXGYR+yEvxWD_8fehjB7PcW_YNfzM+ufUMQAOKTjSA@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=lh_mouse@126.com \
    --cc=mizo91@gmail.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).