From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id D98C6385841A for ; Thu, 22 Sep 2022 08:19:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D98C6385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x531.google.com with SMTP id a41so12467050edf.4 for ; Thu, 22 Sep 2022 01:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=krcoI3HCECFBGzg/BCfySANK512RkY49KsIv6zgEyag=; b=UMqGI8droSIKryIlIzBnlSLEKTZDkOK/SJb1AoDSJQL7y0jQymhHCZmfc4cUtzx261 FPaDHre8VMXtHvYz8ohym4L7ki4AaO1rxiHqjSpFSv53ftjkRx95Lcu/Iyciwt/UI2NA aZNvlh15HgITdM2sUeyA86MdVBLAMRu3WBT1b7WfJsVeVcQTi8mWoL1IRavX52gYJaiF yEoEYGvStIOd+gV4CzqoUbRAFgpAFlbFpfRgO8t2fwnU5bIVZEUzo0cvR8uIVs8/7ZLq jPGTtVdualinBG2Wo+fJ/CdSeUGwJbTLPZOzJKX0v3GcSFy4G2ulpPKPTswnnfNehEsX Emyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=krcoI3HCECFBGzg/BCfySANK512RkY49KsIv6zgEyag=; b=bTym0gdBkhHIxBdo3Plv4qCRxmy/FI0n6qCc2I37QnLSJJk2jiU/Y1cNMxRYZmB1zx VES7TANLR7067f1e/aqPcm9ZetlfEUeAzlsPkFkjEoAuuGYOS87GLxZ8UgylQm0QuqcB O0yBJPDQLPPe3JIlujaEmf6IjeJqjjcCSn+xHiWV3oZiucqL9/PuuJhS9iRaKt2YtdJE 7Bogor0qy9dfuLkxIrvI7RjIr6skKbx662AzYVGv+mqlhg3gK1fefxQFnObEJBERVw7Y GL6Amt+7bcmvP7W2nJeGFmCeI0Nf8KSMmtBvmV1BeEa38G/sqO4TfkN9tSi4HYH3JOlD dlAw== X-Gm-Message-State: ACrzQf0bsZie7rNa+zMitiScjHx+3jhvUkvIRx8VkO7ScCoZy7LxYhSk kvHqu1hWZvTM56jiBGpu6+GIFkJaakE8/BZCtVg= X-Google-Smtp-Source: AMsMyM7cJ6/aWoZEz7mQRJ+mc16XaLIvQ8uqeCWR1cNLmkGQUtUsxSiRHWTKNJwi1+cnIjRarwnbmZI1fMS6SWaXyWw= X-Received: by 2002:a05:6402:a43:b0:44e:cf0a:5e82 with SMTP id bt3-20020a0564020a4300b0044ecf0a5e82mr1997104edb.118.1663834776510; Thu, 22 Sep 2022 01:19:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 22 Sep 2022 09:19:25 +0100 Message-ID: Subject: Re: CreateProcess No such file or directory To: LIU Hao Cc: mizo 91 , gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 22 Sept 2022 at 07:45, LIU Hao via Gcc-help wrote: > > =E5=9C=A8 2022/9/21 00:02, mizo 91 via Gcc-help =E5=86=99=E9=81=93: > > Hello, > > > > I'm having trouble compiling simple test program on windows 10 with lon= g > > 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 reas= on for that is, if we take > a look at 'libiberty/pex-win32.c' we see the following: > > 853 /* Create the child process. */ > 854 pid =3D win32_spawn (executable, (flags & PEX_SEARCH) !=3D 0, > 855 argv, env, dwCreationFlags, &si, &pi); > 856 if (pid =3D=3D (pid_t) -1) > 857 pid =3D spawn_script (executable, argv, env, dwCreationFlags, > 858 &si, &pi); > 859 if (pid =3D=3D (pid_t) -1) > 860 { > 861 *err =3D ENOENT; > 862 *errmsg =3D "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 i= f for whatever reason it > fails, it makes another attempt with `spawn_script`, and if it fails agai= n, `*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 =3D "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 =3D std::system_category().default_error_condition(GetLastError()); if (ec.category() =3D=3D std::generic_category()) errno =3D ec.value(); else errno =3D ENOENT; // or EINVAL might be better?