Skip to content

[CMAKE] Fix layering issue between Concurrency and Darwin overlay #82973

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Runtimes/Core/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_library(swift_Concurrency
Actor.cpp
AsyncLet.cpp
AsyncStream.cpp
CFExecutor.cpp
Clock.cpp
ConcurrencyHooks.cpp
EmbeddedSupport.cpp
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/Concurrency/AsyncStreamBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Swift
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
#if ASYNC_STREAM_STANDALONE
@_exported import _Concurrency
import Darwin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What API is this import Darwin pulling in?

Copy link
Contributor Author

@justice-adams-apple justice-adams-apple Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's pulling in the Darwin.os functionality it looks like, you're right I was too zealous in removing this. I'm going to restore this and handle it in a separate PR


func _lockWordCount() -> Int {
let sz =
Expand Down
28 changes: 28 additions & 0 deletions stdlib/public/Concurrency/CFExecutor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===--- CFExecutor.cpp ----------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include "swift/Runtime/Concurrency.h"

#if !defined(_WIN32) && !defined(__wasi__) && __has_include(<dlfcn.h>)
#include <dlfcn.h>
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if !defined(_WIN32) && !defined(__wasi__) && __has_include(<dlfcn.h>)
#include <dlfcn.h>
#endif
#include <dlfcn.h>

This seems like we shouldn't bother with the guards as this is now Darwin specific.


using namespace swift;

SWIFT_CC(swift)
extern "C" void * swift_concurrency_dlopen_noload(const char * __path) {
return dlopen( __path, RTLD_NOLOAD);
}

SWIFT_CC(swift)
extern "C" void * swift_concurrency_dlsym(void * __handle, const char * __symbol) {
return dlsym(__handle, __symbol);
}
8 changes: 6 additions & 2 deletions stdlib/public/Concurrency/CFExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

import Swift

internal import Darwin
@_silgen_name("swift_concurrency_dlopen_noload")
private func dlopen(_ path: String) -> OpaquePointer?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this symbol is mapping in the RTLD_NOLOAD, we should likely not name this dlopen to avoid confusion.

Also, swift_concurrency_dlopen_noload is taking a const char *, not a Swift string. We're not using the automatic bridging here so I don't think you get the automatic conversion thunks. I believe this type should be an UnsafePointer<CChar>?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed it to dlopen_noload


@_silgen_name("swift_concurrency_dlsym")
private func dlsym(_ handle: OpaquePointer?, _ symbol: String) -> OpaquePointer?

// .. Dynamic binding ..........................................................

enum CoreFoundation {
static let path =
"/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"

static let handle = unsafe dlopen(path, RTLD_NOLOAD)
static let handle = unsafe dlopen(path)

static var isPresent: Bool { return unsafe handle != nil }

Expand Down
1 change: 1 addition & 0 deletions stdlib/public/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ set(SWIFT_RUNTIME_CONCURRENCY_C_SOURCES
../CompatibilityOverride/CompatibilityOverride.cpp
Actor.cpp
AsyncLet.cpp
CFExecutor.cpp
Clock.cpp
GlobalExecutor.cpp
ConcurrencyHooks.cpp
Expand Down