brechtsanders / winlibs_mingw

winlibs standalone build of GCC compiler and MinGW-w64
935 stars 42 forks source link

Fatal error with PCH compilation #108

Open neolib opened 2 years ago

neolib commented 2 years ago

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.

brechtsanders commented 2 years ago

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

neolib commented 2 years ago

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.

luisdallos commented 2 years ago

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:

  1. Remove the 128 MiB size limit of PCH files ^1.
  2. 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.