Skip to content

Commit 091f867

Browse files
authored
Ensure libdispatch is always initialized before CoreFoundation (#4666)
This has been causing async functions to not return when using static linking. rdar://96642321
1 parent 0787ce6 commit 091f867

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CoreFoundation/Base.subproj/CFRuntime.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,20 @@ CF_EXPORT
11711171

11721172
CF_PRIVATE os_unfair_recursive_lock CFPlugInGlobalDataLock;
11731173

1174+
#if __HAS_DISPATCH__
1175+
extern void libdispatch_init();
1176+
#endif
1177+
11741178
void __CFInitialize(void) {
11751179
if (!__CFInitialized && !__CFInitializing) {
11761180
__CFInitializing = 1;
11771181

1182+
#if __HAS_DISPATCH__
1183+
// libdispatch has to be initialized before CoreFoundation, so to avoid
1184+
// issues with static initializer ordering, we are doing it explicitly.
1185+
libdispatch_init();
1186+
#endif
1187+
11781188
// This is a no-op on Darwin, but is needed on Linux and Windows.
11791189
_CFPerformDynamicInitOfOSRecursiveLock(&CFPlugInGlobalDataLock);
11801190

0 commit comments

Comments
 (0)