On Tue, May 10, 2022 at 09:30:03PM +0800, LIU Hao via Gcc-patches wrote: > From 2e314baed84fd80b3b3c4c67787a032b86dd54dc Mon Sep 17 00:00:00 2001 > From: LIU Hao <lh_mo...@126.com> > Date: Tue, 10 May 2022 13:19:07 +0800 > Subject: [PATCH] [PR14940] Remove size limit of PCH > > There shouldn't be such a limit in practice. > > 2022-05-03 LIU Hao <lh_mo...@126.com> > > PR pch/14940 > * config/i386/host-mingw32.cc (pch_VA_max_size): Remove. > (mingw32_gt_pch_get_address): Remove size limit.
This looks reasonable, but doesn't contain the most important part. As mentioned in https://gcc.gnu.org/r12-5855 the generic part can now support relocation of PCH, so it is fine if it is mapped at some other address, it is preferrable if it is mapped at the same address as it was written for, but if not, the generic code can relocate it. So, beyond your changes, I'd suggest to change: /* 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) { w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx"); CloseHandle(mmap_handle); return -1; } IMHO you can just drop the loop, sleep of half a second is almost certainly slower than the relocation handling, so I'd just 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; } addr = mmap_addr; This, if it mmaps the file at the right address, nice, if not, let the caller know (through updating addr) that it needs to relocate it, but if the mapping failed, fail. Jakub