winlibs_mingw
winlibs_mingw copied to clipboard
Fatal error with PCH compilation
When I try to make a wxWidgets program, I get an unexpected fatal error (which I did not have before):
g++ -c pch.h -I"C:/Build/src/wxWidgets/include" -I"C:/Build/src/wxWidgets/lib/gcc1210_dll/mswu"
In file included from pch.h:4:
C:/Build/src/wxWidgets/include/wx/cmdline.h:372:2: fatal error: cannot write PCH file: required memory segment unavailab
le
372 | };
| ^
I am using gcc version 12.1.0 (MinGW-W64 i686-posix-dwarf, built by Brecht Sanders)
.
I can confirm that gcc version 8.1.0 (i686-win32-sjlj-rev0, Built by MinGW-W64 project)
can compile pch.h without any problems.
I have seen PCH issues with MinGW-w64 for as long as I can remember, so I usually avoid precompiled headers.
See also for example these bug reports: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14940
I want to ammend an interesting finding.
I can successfully compile PCH using gcc 12.2 Rev1 provided by MSYS2, either used in MSY2 terminal or bare CMD window. But 12.2 Rev2 has the same old behavior. That's very strange.
I want to ammend an interesting finding.
I can successfully compile PCH using gcc 12.2 Rev1 provided by MSYS2, either used in MSY2 terminal or bare CMD window. But 12.2 Rev2 has the same old behavior. That's very strange.
The MSYS2 team applies two patches of their own in order to fix PCH support issues on mingw-based host platforms:
- Remove the 128 MiB size limit of PCH files ^1.
- Make PCH data relocation support [^2] more (if not fully) functional [^3].
Although they still build GCC with the --disable-libstdcxx-pch
flag [^4] instead of building it with the --enable-libstdcxx-pch
flag.
[^2]: Added in https://github.com/gcc-mirror/gcc/commit/747380f47da0da6c11fd5262ac428bb53433ea19 but the mingw-specific host-side support for this feature is incomplete. [^3]: https://github.com/msys2/MINGW-packages/blob/efe9529/mingw-w64-gcc/0021-PR14940-Allow-a-PCH-to-be-mapped-to-a-different-addr.patch [^4]: https://github.com/msys2/MINGW-packages/blob/efe9529/mingw-w64-gcc/PKGBUILD#L233