From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 087943858D28; Thu, 5 Jan 2023 11:09:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 087943858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672916943; bh=xZQreARIeedmVP+4XBAZKZK1rt+lvICSl5ISlj2EC+E=; h=From:To:Subject:Date:From; b=d3h4PEsOfsWmaorPV7Ai5jjRoZNz9boJ6DBdk26j1xUK3obuijMweuDT5HXP+p1om dadRlcCgEIDuf4xNJMSqtZAqXM1rYrKBNgas7T5Mr9dgMSanNXMSJJr7KfZPtLGlR+ HVK53tEmEX2DV8tmSxb3uJ+aNYoCjf6C9r+luy5g= From: "lh_mouse at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug bootstrap/108300] New: `abort()` macro cause bootstrap failure on *-w64-mingw32 Date: Thu, 05 Jan 2023 11:09:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lh_mouse at 126 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108300 Bug ID: 108300 Summary: `abort()` macro cause bootstrap failure on *-w64-mingw32 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: lh_mouse at 126 dot com Target Milestone: --- Recently, mingw-w64 has got updated from Wine. GCC then ceases to build: ``` ../../gcc/gcc/system.h:791:30: error: expected identifier before string constant 791 | #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) | ^~~~~~~~ ``` The reason is elaborated in this piece of log of #gcc on OFTC: ``` [16:51:28] on Windows hosts, now involves , which brings a struct that has `abort()` as a member function, so if the ma= cro above is expanded there it will become nonsense. [16:52:34] if GCC does not use that struct (and a plenty more)= the standard way to prevent them from being included is to define `WIN32_LEAN_AND_MEAN` before inclusion of . unfortunately, not = all GCC source files do so. [16:53:31] there are about thirty to forty files that include without defining `WIN32_LEAN_AND_MEAN`. do you think it is a g= ood idea to patch them all? [16:54:11] this can be generated by an sed command, but it's g= onna be a large patch, touching files that I am not familiar with. [16:55:03] or, we can patch mingw-w64 msxml.h to `#undef abort= `. [16:57:22] can you fixincludes windows.h to add a wrapperr that def= ines WIN32_LEAN_AND_MEAN and then include_next windows.h? [16:58:11] (that means you do not have to patch the original file .. you could also use fixincludes to do that too - but it seems maybe more complicated than the wrapper) [17:06:14] .. of course, that does not help if the files are sources that need to be built by the bootstrap compiler - it=E2=80=99s only going t= o succeed if they are all target-libs related. [17:23:52] .. hmm but if they are sources in the gcc tree, I=E2=80= =99d suppose that windows.h should not be included directly - but via system.h where you could place the #define before the inclusion. [17:34:14] ugh, the wonders of macros [17:34:25] maybe that can be a static inline fn instead? [17:34:41] (or even just regular ol inline) [18:08:19] yeah, GCC should not #define abort like that, it's disgusting [18:08:40] "but we've always done it like that" - time to stop ``` I create this PR for the record. In my opinion, including witho= ut `WIN32_LEAN_AND_MEAN` pulls in tons of unnecessary stuff and is almost never desired. This can be fixed by ``` sed -Ei 's,^( *)#( *)include ,\1#\2define WIN32_LEAN_AND_MEAN 1\n&,' \ $(grep --inc "*.[hc]" --inc "*.cc" -Flr "") ``` (Some source files already have it.)=