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 53482385840C for ; Thu, 22 Sep 2022 08:43:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 53482385840C 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 b35so12613326edf.0 for ; Thu, 22 Sep 2022 01:43:00 -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=P44yFcOOIt/o94yFRTSpPIg+aCmUy7RwH4cwnNNsiCI=; b=huT+oqwMS8EGJ9rCDG+TzsJHN9fOPlAm64sJM0DSdR5GFKfoyzkKHKq7W3mI4ZqOZD bJH5nB9H4sKOM79CGbxTlQV9HEod3oOiodJSiZ1oWkQL25B8PlD3LhgEcNDBBNhOsuuH MnhtPOCHQNfpal0pzGddoS9d1Kvt4ehd5cOrVFoiJZtp7F20vvTdsuLuF9Q9IcY8TqoI zFqPI+/TWRYm04SscKqeACnwnYB5HKvv4bccgc7sysUp6zd01MlDwfhqvSzfhoUwg8ok YZ7Y490scSabzrM+Hw9XkMaqG58QMf2t/0k5coQTFdaQ6MSFxZbguV+XObm9nDVSOMS6 JVBA== 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=P44yFcOOIt/o94yFRTSpPIg+aCmUy7RwH4cwnNNsiCI=; b=v2czDWuvrf0iT7oV0/ZMuwM2XwUaiYbDFUA3jm2DfLapVS/8z+Y8xnJkUnv2MTlHOw bdvE+A+M8piyadAKvipRe8nOxKeIcAp0l3y0Lj8zoUrnXAfTE4q8ciO5ugf9/5UJPQgg dJE6N8NLesAmH7iFqleAdR4j0lhUNmS0Qq+RYXFNANSWyuTfisbKJOXaN0kyQXv5cByL iIX3I4fIwQQ8f5xl1O17EikprqEMK72T0ZuCgwl02oAksF/XIzbxo4s0HwKcyQTdYMmK VolL2RpQty/2y9B3KVlwrBeW+c4KRLJEZqDoeDwdUHEppwxFktOSbaiefVC0KLS3ggEf tx6w== X-Gm-Message-State: ACrzQf3Af/19X8p8hqp5jo2rEjzyMX6JLkTJ3MG56BNyOHc3s3eaS36w hFDl7mxS4N1WMs061Jp/NeAYrRzTbOsvkNP61MI= X-Google-Smtp-Source: AMsMyM5QcqzDUPmD5qEQ0wKQeadnpRH1DcT9Eel/afZbCeSslFlgz1vTBIgygzeOz/N4DQnM3jvXSuD4jdioUgZReJY= X-Received: by 2002:a05:6402:a43:b0:44e:cf0a:5e82 with SMTP id bt3-20020a0564020a4300b0044ecf0a5e82mr2074589edb.118.1663836179120; Thu, 22 Sep 2022 01:42:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 22 Sep 2022 09:42:47 +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,KAM_SHORT,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 09:19, Jonathan Wakely wrote: > > 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 l= ong > > > 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 re= ason 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 a= s 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 ag= ain, `*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? I reported https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107007