Skip to content

Add macOS static C API archive#477

Draft
parallaxisjones wants to merge 1 commit into
alibaba:mainfrom
parallaxisjones:pjones/static-c-api
Draft

Add macOS static C API archive#477
parallaxisjones wants to merge 1 commit into
alibaba:mainfrom
parallaxisjones:pjones/static-c-api

Conversation

@parallaxisjones

Copy link
Copy Markdown

Summary

  • Add a macOS zvec_c_api_static target that builds a fat libzvec_c_api.a from the C API object plus the zvec and bundled third-party static archives.
  • Install the static C API archive alongside the existing shared C API artifact on Apple platforms.
  • Propagate the configured compiler, archiver, ranlib, and macOS SDK root into the LZ4 ExternalProject build so raw make builds use the same toolchain as the parent CMake build.

Why

Downstream Rust consumers already support ZVEC_STATIC=1, but current zvec release artifacts do not provide libzvec_c_api.a. That means projects that want a single statically linked executable cannot use zvec without packaging a dynamic libzvec_c_api next to the binary.

This change provides a first static C API artifact for macOS by mirroring the dependency closure that is already force-loaded into libzvec_c_api.dylib.

Validation

  • Configured zvec from source with C bindings enabled and Python/tools disabled.
  • Built the existing zvec_c_api shared target successfully.
  • Built the new zvec_c_api_static target successfully, producing lib/libzvec_c_api.a.
  • Confirmed the static archive exports C API symbols such as zvec_collection_create_and_open.
  • Linked and ran a small C smoke binary against only libzvec_c_api.a plus macOS system libraries; it printed 0.2.1.
  • Verified the smoke binary does not depend on libzvec_c_api.dylib via otool -L.
  • Configured a fresh build directory and built Lz4.BUILD without an outer SDKROOT, validating the LZ4 compiler/SDK propagation.

Notes

This PR intentionally starts with macOS because /usr/bin/libtool -static provides a straightforward way to merge static archives into a single archive. Linux can follow with an ar/MRI or object-extraction implementation.

@CLAassistant

CLAassistant commented Jun 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants