From 812445a6b76b61a5b4d57b3495308f29684d831d Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Wed, 8 May 2024 20:55:09 -0400 Subject: [PATCH] Workaround for https://github.com/apple/swift/issues/73532 Increase the initial size of __CFReadSocketsFds to reduce the chance of resizing it which appears to lead to compiler hangs. --- CoreFoundation/RunLoop.subproj/CFSocket.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CoreFoundation/RunLoop.subproj/CFSocket.c b/CoreFoundation/RunLoop.subproj/CFSocket.c index 357dab6838..d59df93d66 100644 --- a/CoreFoundation/RunLoop.subproj/CFSocket.c +++ b/CoreFoundation/RunLoop.subproj/CFSocket.c @@ -561,6 +561,14 @@ static void __CFSocketInitializeSockets(void) { __CFReadSockets = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, NULL); __CFWriteSocketsFds = CFDataCreateMutable(kCFAllocatorSystemDefault, 0); __CFReadSocketsFds = CFDataCreateMutable(kCFAllocatorSystemDefault, 0); +#if TARGET_OS_WIN32 + // A workraround for a compiler hang issue on windows: + // https://github.com/apple/swift/issues/73532 + // Use a larger initial size so that the bit vector resize code is + // less likely used as Windows socket FD numbers are usually + // within 4 digits. + CFDataIncreaseLength(__CFReadSocketsFds, 16348 / NBBY); +#endif zeroLengthData = CFDataCreateMutable(kCFAllocatorSystemDefault, 0); #if TARGET_OS_WIN32 __CFSocketInitializeWinSock_Guts();