Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error with PCH compilation #108

Open
neolib opened this issue Jul 4, 2022 · 3 comments
Open

Fatal error with PCH compilation #108

neolib opened this issue Jul 4, 2022 · 3 comments

Comments

@neolib
Copy link

neolib commented Jul 4, 2022

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
Copy link
Owner

brechtsanders commented Jul 4, 2022

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
Copy link
Author

neolib commented Sep 16, 2022

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
Copy link

luisdallos commented Sep 17, 2022

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.

Footnotes

  1. https://github.com/msys2/MINGW-packages/blob/efe9529/mingw-w64-gcc/0010-Fix-using-large-PCH.patch

  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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants