Use distinct Swift modules for Apple crypto static archive#128902
Closed
vcsjones wants to merge 2 commits into
Closed
Use distinct Swift modules for Apple crypto static archive#128902vcsjones wants to merge 2 commits into
vcsjones wants to merge 2 commits into
Conversation
Compile the Apple crypto Swift bindings separately for the shared library and static archive so the static archive gets a distinct Swift module name. This avoids duplicate ObjC runtime class registration when both variants are loaded into one process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Apple crypto native library build to compile the Swift bindings into two distinct object files (shared vs. static) with different Swift module names, so both variants can be loaded into the same process without Swift/ObjC class registration name collisions.
Changes:
- Split
pal_swiftbindings.swiftcompilation into two outputs:pal_swiftbindings_shared.oandpal_swiftbindings_static.o. - Pass distinct
-module-namevalues toswiftcfor shared vs. static builds. - Wire the appropriate Swift object file into each CMake target (
SHAREDvs.STATIC).
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt | Builds Swift bindings twice with distinct module names and links the correct object into the shared dylib vs. static archive to avoid class-name collisions. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
bartonjs
approved these changes
Jun 2, 2026
Member
Author
|
Closing in favor of #128917. |
This was referenced Jun 2, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the "quicker" fix for #128867 that should work. It uses a different module name between the dylib and static archive so the Swift classes can coexist in the same proces for CoreCLR and NAOT. It does not permit two NAOT libraries in the same app. It is largely this suggestion from @MichalStrehovsky
Using different module names between dylib and archives results in different exported names for the classes:
So they should be able to coexist in the same process. A longer term solution on how to resolve this broadly for loading multiple NAOT libraries in the same process is something that will be a follow up, but I think this unblocks the SDK's needs.