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

Conversation

justice-adams-apple
Copy link
Contributor

Concurrency from the Core project is importing the Darwin platform overlay, which in turn depends on SwiftCore from the Core project, breaking the project layering.

Concurrency only needs the Clang module, but Swift does not have a mechanism to only import a clang module. For now import the functionality needed from Darwin by importing and wrapping the associated functions from <dlfcn.h> within CFExecutor.cpp

Also remove Darwin import from AsyncStreamBuffer.swift because it is not used

@justice-adams-apple
Copy link
Contributor Author

@swift-ci please smoke test

@@ -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

@@ -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

@justice-adams-apple
Copy link
Contributor Author

@swift-ci please smoke test

@etcwilde etcwilde requested a review from al45tair July 11, 2025 18:34
Comment on lines 14 to 16
#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.

@justice-adams-apple
Copy link
Contributor Author

@swift-ci please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants