public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "martin at martin dot st" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/105506] Error building GCC 12.1.0 against MinGW-w64: fatal error: cannot execute 'cc1': CreateProcess: No such file or directory
Date: Sun, 05 Jun 2022 20:19:27 +0000	[thread overview]
Message-ID: <bug-105506-4-IbXRGybRP9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105506-4@http.gcc.gnu.org/bugzilla/>

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

Martin Storsjö <martin at martin dot st> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |martin at martin dot st

--- Comment #6 from Martin Storsjö <martin at martin dot st> ---
This is an old longstanding issue that seems to have reappeared, but which has
been fixed differently recently in the very latest mingw-w64 git. But first a
brief history of the issue:

GCC uses the access() function for checking whether a binary exists and is
executable (with the X_OK flag as parameter). On Windows, there's no separate
"execute" permission bit, but the X_OK bit (which isn't a documented parameter
from Microsoft's side) used to be ignored.

In Vista, msvcrt.dll's access() function suddenly stopped ignoring the bit that
was used for X_OK (which mingw had decided to use for that purpose), and
started erroring out when this bit was set. This was dealt with in 2007 in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33281, by adding a
reimplementation of the access() function in mingw. By defining
__USE_MINGW_ACCESS, the access() function is redirected to the __mingw_access()
function. GCC set -D__USE_MINGW_ACCESS when building on mingw to include this
workaround.

After some time, it seems like Microsoft reverted this behaviour in
msvcrt.dll's access() function, because now it no longer seems like this
behaviour is present, not on modern Windows 10, but not even on "modern"
installations of Vista either. So the need for -D__USE_MINGW_ACCESS has
vanished (and bitrotted in GCC somewhat).

UCRT's access() function does have the same issue though - if passed the
undocumented, mingw-invented X_OK bit, it errors out. As GCC did try to define
__USE_MINGW_ACCESS, the workaround should have been picked up though, but as
GCC's codebase had evolved, the define wasn't being set in all the cases where
it might have been needed. This was fixed for GCC 11 in
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=89e95ad2e7679322b2f5ee9070ff2721d5ca1d6d
(and later backported to GCC 9 and 10 in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101238).

But apparently something has changed further in GCC 12, so that this define
doesn't end up set in all the places where it needs to. (It'd be interesting to
know why/where/when!) In mingw-w64, we decided to enable this workaround
unconditionally for UCRT (as a more general fix for other audiences, although
GCC is the only one I've heard of needing it) - skipping the UCRT provided
access() function and always using the mingw reimplementation, see
https://github.com/mingw-w64/mingw-w64/commit/bceadc54d8f32b3f14c69074892e2718eac08e3b.

So to successfully build GCC 12 running on UCRT, you'd need to use another GCC
install, with the very latest mingw-w64 (or an older release with that fix
cherry-picked, plus the following Makefile.in update from
https://github.com/mingw-w64/mingw-w64/commit/89bacd2be60fa92dd74d3b5f2074b06a32d8c784),
to build GCC 12. Alternatively, see if you can manually pass
-D__USE_MINGW_ACCESS to the GCC 12 build, if it'd end up in all the places
where it's needed.

  parent reply	other threads:[~2022-06-05 20:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 15:06 [Bug c/105506] New: " brechtsanders at users dot sourceforge.net
2022-05-14 18:42 ` [Bug target/105506] " brechtsanders at users dot sourceforge.net
2022-05-27  9:48 ` brechtsanders at users dot sourceforge.net
2022-05-27 11:34 ` brechtsanders at users dot sourceforge.net
2022-06-05 14:28 ` brechtsanders at users dot sourceforge.net
2022-06-05 14:34 ` brechtsanders at users dot sourceforge.net
2022-06-05 20:19 ` martin at martin dot st [this message]
2022-06-06  9:00 ` brechtsanders at users dot sourceforge.net
2022-06-06 11:07 ` martin at martin dot st
2023-01-16 10:44 ` [Bug target/105506] [12/13 Regression] " rguenth at gcc dot gnu.org
2023-01-16 19:18 ` hjl.tools at gmail dot com
2023-01-16 21:32 ` brechtsanders at users dot sourceforge.net
2023-01-16 22:31 ` hjl.tools at gmail dot com
2023-01-18 20:19 ` brechtsanders at users dot sourceforge.net
2023-02-01 21:52 ` hjl.tools at gmail dot com
2023-05-08 12:24 ` [Bug target/105506] [12/13/14 " rguenth at gcc dot gnu.org

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=bug-105506-4-IbXRGybRP9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).