Fix: SwiftPM transitive linking for CNumKong via substantive shim source#354
Fix: SwiftPM transitive linking for CNumKong via substantive shim source#354beshkenadze 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.
|
Independent confirmation of this bug and of the fix in this PR. Affected consumer: Desk Hound, a macOS app, pulls USearch exactly as described in #353. The shim approach in this PR fixes it. We independently worked around it by vendoring a local copy of NumKong with a trivial translation unit in Verified end-to-end: our full Would be great to get this reviewed and into a patch release within USearch's |
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.