public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable @ 2022-06-05 19:13 brechtsanders at users dot sourceforge.net 2022-07-04 9:18 ` [Bug pch/105858] " brechtsanders at users dot sourceforge.net ` (7 more replies) 0 siblings, 8 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-06-05 19:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 Bug ID: 105858 Summary: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: brechtsanders at users dot sourceforge.net Target Milestone: --- When building the Windows 64-bit version of GCC 12.1.0 against MinGW-w64 build with --libstdcxx-pch the following error occurs: In file included from R:/winlibs64_stage/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h:82: R:/winlibs64_stage/gcc-12.1.0/build_mingw/x86_64-w64-mingw32/libstdc++-v3/include/ext/enc_filebuf.h:63:1: fatal error: cannot write PCH file: required memory segment unavailable 63 | } // namespace | ^ compilation terminated. This error does not happen when building the 32-bit version. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net @ 2022-07-04 9:18 ` brechtsanders at users dot sourceforge.net 2022-07-25 9:32 ` brechtsanders at users dot sourceforge.net ` (6 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-07-04 9:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #1 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- Any news on this? I am not the only one experiencing this. See also: https://github.com/brechtsanders/winlibs_mingw/issues/108 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net 2022-07-04 9:18 ` [Bug pch/105858] " brechtsanders at users dot sourceforge.net @ 2022-07-25 9:32 ` brechtsanders at users dot sourceforge.net 2022-08-06 10:02 ` brechtsanders at users dot sourceforge.net ` (5 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-07-25 9:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #2 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- Just checked, issue is still present in snapshot 12-20220723. Anybody able to confirm the issue or know what the status is? ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net 2022-07-04 9:18 ` [Bug pch/105858] " brechtsanders at users dot sourceforge.net 2022-07-25 9:32 ` brechtsanders at users dot sourceforge.net @ 2022-08-06 10:02 ` brechtsanders at users dot sourceforge.net 2022-09-04 7:58 ` brechtsanders at users dot sourceforge.net ` (4 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-08-06 10:02 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #3 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- Some information I received related to this issue: On 01/08/2022 14:52, Luis Dallos wrote: > > PCH has had issues for as long as I can remember, see for example: > > * https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/0010-Fix-using-large-PCH.patch > > The msys2 team commited in msys2/MINGW-packages@52908ed an additional patch in order to fix PCH relocation issues. > > https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/0021-PR14940-Allow-a-PCH-to-be-mapped-to-a-different-addr.patch > > See also: > > msys2/MINGW-packages#11582 (comment) > https://gcc.gnu.org/pipermail/gcc-patches/2022-May/594556.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net ` (2 preceding siblings ...) 2022-08-06 10:02 ` brechtsanders at users dot sourceforge.net @ 2022-09-04 7:58 ` brechtsanders at users dot sourceforge.net 2022-09-04 13:53 ` brechtsanders at users dot sourceforge.net ` (3 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-09-04 7:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #4 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- Any update on this issue? I see performance complaints from several people in GCC12+MinGW-w64 being much slower in the build without precompiled headers (see: https://github.com/brechtsanders/winlibs_mingw/issues/107) ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net ` (3 preceding siblings ...) 2022-09-04 7:58 ` brechtsanders at users dot sourceforge.net @ 2022-09-04 13:53 ` brechtsanders at users dot sourceforge.net 2022-12-24 1:56 ` egor.pugin at gmail dot com ` (2 subsequent siblings) 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-09-04 13:53 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #5 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- I believe this is issue is cause by the fact that mmap is missing on Windows. In gcc/ggc-common.cc this causes use of default_gt_pch_get_address() as HOST_HOOKS_GT_PCH_GET_ADDRESS which just returns NULL resulting in "cannot write PCH file: required memory segment unavailable". Though mmap doesn't exist, it isn't that hard to emulate, as can be seen in https://github.com/alitrack/mman-win32 , so maybe some code is needed to use the Windows memory mapping mechanism. I did try to build against https://github.com/alitrack/mman-win32, but I ran into the issue that this requires linking with the library mman-win32, but passing it to LDFLAGS doesn't work as it's not near the end of the linker command and link order is important on Windows/MinGW. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net ` (4 preceding siblings ...) 2022-09-04 13:53 ` brechtsanders at users dot sourceforge.net @ 2022-12-24 1:56 ` egor.pugin at gmail dot com 2022-12-26 15:02 ` brechtsanders at users dot sourceforge.net 2022-12-30 13:26 ` brechtsanders at users dot sourceforge.net 7 siblings, 0 replies; 9+ messages in thread From: egor.pugin at gmail dot com @ 2022-12-24 1:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #6 from Egor Pugin <egor.pugin at gmail dot com> --- Same issue. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net ` (5 preceding siblings ...) 2022-12-24 1:56 ` egor.pugin at gmail dot com @ 2022-12-26 15:02 ` brechtsanders at users dot sourceforge.net 2022-12-30 13:26 ` brechtsanders at users dot sourceforge.net 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-12-26 15:02 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #7 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- Any update on this? This issue makes GCC12 really slow on Windows because PCH support doesn't work. If mman-win32 support could be made to work it might solve this issue. The problem is that this requires linking with -lmman (and this flag needs to be near the end of the list of linked libraries) ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug pch/105858] MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net ` (6 preceding siblings ...) 2022-12-26 15:02 ` brechtsanders at users dot sourceforge.net @ 2022-12-30 13:26 ` brechtsanders at users dot sourceforge.net 7 siblings, 0 replies; 9+ messages in thread From: brechtsanders at users dot sourceforge.net @ 2022-12-30 13:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105858 --- Comment #8 from Brecht Sanders <brechtsanders at users dot sourceforge.net> --- I seem to be having some success after applying patches based on: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/0010-Fix-using-large-PCH.patch https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gcc/0021-PR14940-Allow-a-PCH-to-be-mapped-to-a-different-addr.patch My patch for GCC 12.2.0 looks like this: patch -ulbf gcc/config/i386/host-mingw32.cc << EOF @@ -46,5 +46,2 @@ -/* FIXME: Is this big enough? */ -static const size_t pch_VA_max_size = 128 * 1024 * 1024; - /* Granularity for reserving address space. */ @@ -90,5 +87,2 @@ void* res; - size = (size + va_granularity - 1) & ~(va_granularity - 1); - if (size > pch_VA_max_size) - return NULL; @@ -102,3 +96,3 @@ - res = VirtualAlloc (NULL, pch_VA_max_size, + res = VirtualAlloc (NULL, size, MEM_RESERVE | MEM_TOP_DOWN, @@ -143,3 +137,2 @@ OSVERSIONINFO version_info; - int r; @@ -152,3 +145,3 @@ this to work. We can't change the offset. */ - if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size) + if ((offset & (va_granularity - 1)) != 0) return -1; @@ -177,21 +170,20 @@ - /* Retry five times, as here might occure a race with multiple gcc's - instances at same time. */ - for (r = 0; r < 5; r++) - { - mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset, - size, addr); - if (mmap_addr == addr) - break; - if (r != 4) - Sleep (500); - } - - if (mmap_addr != addr) + /* Try mapping the file at \`addr\`. */ + mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset, + size, addr); + if (mmap_addr == NULL) { - w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx"); - CloseHandle(mmap_handle); - return -1; + /* We could not map the file at its original address, so let the + system choose a different one. The PCH can be relocated later. */ + mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset, + size, NULL); + if (mmap_addr == NULL) + { + w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx"); + CloseHandle(mmap_handle); + return -1; + } } + addr = mmap_addr; return 1; EOF ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-12-30 13:26 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-06-05 19:13 [Bug c/105858] New: MinGW-w64 64-bit build with --libstdcxx-pch: fatal error: cannot write PCH file: required memory segment unavailable brechtsanders at users dot sourceforge.net 2022-07-04 9:18 ` [Bug pch/105858] " brechtsanders at users dot sourceforge.net 2022-07-25 9:32 ` brechtsanders at users dot sourceforge.net 2022-08-06 10:02 ` brechtsanders at users dot sourceforge.net 2022-09-04 7:58 ` brechtsanders at users dot sourceforge.net 2022-09-04 13:53 ` brechtsanders at users dot sourceforge.net 2022-12-24 1:56 ` egor.pugin at gmail dot com 2022-12-26 15:02 ` brechtsanders at users dot sourceforge.net 2022-12-30 13:26 ` brechtsanders at users dot sourceforge.net
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).