Repository navigation
Add a Zig package for the C ABI library - #120
Draft
joshbainbridge wants to merge 1 commit into
Draft
joshbainbridge wants to merge 1 commit into
joshbainbridge wants to merge 1 commit into
Conversation
Zig projects can't depend on OpenQMC without CMake, and the C ABI has no Zig bindings. Zig can translate the C header itself, so a package that builds the library is enough for Zig to call the samplers, and the same build can later produce the library for C and C++ users. Add build.zig and build.zig.zon for Zig 0.17, building liboqmc as a static archive with hidden visibility, the sampler chosen with the sampler option. Translate oqmc_c.h with the translate-c package, pinned to 2.0.2, into an oqmc module that links the library, and limit the package paths to the files it needs. Add a separate example project in examples/zig that depends on the package by path and calls every function in the C ABI, mirroring the C example. Add zig and zls to the flake, updating the locked nixpkgs revision, and ignore and clean the Zig cache, output and package directories. Signed-off-by: Josh Bainbridge <josh.bainbridge@gmail.com>
joshbainbridge
marked this pull request as draft
November 17, 2026 00:52
This branch has not been deployed
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.
Builds on #119. Lets Zig projects depend on OpenQMC with the Zig package manager, using the C ABI without hand-written bindings.
Overview
build.zigandbuild.zig.zon(Zig 0.17) buildliboqmcas a static archive with hidden visibility. Thesampleroption chooses the sampler (defaultpmjbn).oqmc_c.his translated with the translate-c package (pinned to2.0.2) into anoqmcmodule. Importing the module also links the library.examples/zigis a separate project that depends on the package by path and calls every C ABI function, mirroringcmake/examples/cabi.zigandzls, and the Zig output directories are ignored and removed byjust clean.Testing
zig build runinexamples/zigpasses for all six samplers, in Debug and ReleaseFast.free,malloc,memcpy), and all their symbols are hidden.To do