Fix: SwiftPM transitive linking for CNumKong via substantive shim source#354
Open
beshkenadze wants to merge 1 commit into
Open
Fix: SwiftPM transitive linking for CNumKong via substantive shim source#354beshkenadze wants to merge 1 commit into
beshkenadze wants to merge 1 commit into
Conversation
Add a single C source file (include/cnumkong_module.c) exporting one real symbol so SwiftPM/Xcode 16+ produces a CNumKong.o that satisfies transitive linking — see swiftlang/swift-package-manager#5706 (open since October 2022). Mirrors apple/swift-system's Sources/CSystem/shims.c pattern. Supersedes the ad-hoc _dummy.c approach from PR ashvardanian#352. The CNumKongDispatch target (which owns the actual runtime dispatch implementation) and downstream consumers (USearch, etc.) keep the same import surface — public header layout is unchanged. Verified locally with swift build in NumKong standalone and in a downstream macOS app (Tish) that pulls CNumKongDispatch transitively via USearch.
This was referenced May 7, 2026
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.
Refs #353. Supersedes #352.
Problem
CNumKongis declared as a regular SwiftPM target with no sources (just headers underinclude/numkong/andinclude/module.modulemap). SwiftPM/Xcode 16+ fails at link time when this target is pulled transitively — it expects aCNumKong.othat's never produced (swiftlang/swift-package-manager#5706, open since October 2022).Fix
Add a single C source file (
include/cnumkong_module.c) that exports one real symbol, and declare it as the target's source. This produces a relocatableCNumKong.othat satisfies the linker without changing any public API.New file
include/cnumkong_module.c:Why this and not the alternatives
CNumKongintoCNumKongDispatchbuild.rs/setup.py. Larger blast radius — happy to send if preferred (see #353)._dummy.c(rejected #352)Effect
CNumKongDispatchand downstream consumers (USearch, etc.) keep the same import surface — the public header layout doesn't change.CNumKong.owith one symbol → transitive linking works in Xcode 16+.nk_cnumkong_module_loadedis a single 32-bit constant.Verification
swift buildandswift testpass in NumKong (standalone).swift buildpasses in a downstream macOS app (Tish) that depends on USearch via SwiftPM, transitively pullingCNumKongDispatch→CNumKong. Without this fix, the link step fails on missingCNumKong.o.build.rs/setup.pypaths touched.Discussion
See #353 for the design walkthrough — including the merge alternative.