Repository navigation
Conversation
users now required to set PACT_LD_LIBRARY_PATH env var with location of download pact ffi lib. It can exist anywhere on the filesystem
to automatically set PACT_LD_LIBRARY_PATH
Add a third libpact_ffi backend built on github.com/go-webgpu/goffi, selected with -tags pact_goffi. It shares the symbol table, library search and stub-on-failure behaviour of the purego backend (ffi_dynamic.go) and binds each symbol through reflection. Backends are mutually exclusive by build tag: cgo cgo && !pact_purego && !pact_goffi (default, CGO_ENABLED=1) purego (!cgo || pact_purego) && !pact_goffi (default, CGO_ENABLED=0) goffi pact_goffi Also: - purego: look symbols up through a per-platform helper, so the backend builds on Windows (purego.Dlsym is unix only) - wrap loader errors, drop unused declarations, keep the package comment in an untagged file - golangci: scope gosec G103/G115 out of internal/native, the FFI boundary, where cgo conversions previously hid the same narrowing
pactffi_verifier_execute runs the verification on the calling thread and needs more stack than a Go-created thread has on musl (Alpine), where the default is 128 KiB. The provider tests crashed with SIGSEGV intermittently, and almost always under -race. On Linux, every backend (cgo, purego, goffi) now calls it on a pthread created with an 8 MiB stack and waits for it, falling back to a direct call if the thread cannot be created. Other platforms are unchanged.
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.
Summary
pact-go can now load
libpact_ffiwithout cgo. There are three backends, chosen by build tag, and cgo stays the default.CGO_ENABLED=1and no backend tag (default)CGO_ENABLED=0, or-tags pact_purego-tags pact_goffipurego and goffi share one symbol table and loader (
internal/native/ffi_dynamic.go). The dynamic backends find the library throughPACT_LD_LIBRARY_PATH.This branch also fixes the intermittent SIGSEGV in provider tests on Alpine, which happened on every backend and almost always under
-race.pactffi_verifier_executeoverflows musl's 128 KiB default thread stack. On Linux, all three backends now call it on a pthread with an 8 MiB stack and join it, falling back to a direct call if the thread can't be created. The same fix is proposed on the Rust side in YOU54F/pact-reference (branchfix/verifier-stack-size). Either fix alone is enough; this one also covers users on FFI releases that are already out.Commits
feat: support CGO_ENABLED=0: adds the purego backend.feat: pact-go test wrapper around go test: setsPACT_LD_LIBRARY_PATHautomatically.feat: goffi backend alongside cgo and puregofix: run the verifier on a thread with an 8 MiB stack on LinuxThis is rebased on upstream master at 2.9.1 (
0eaee3d5). The only conflicts were ingo.mod, and they were resolved to upstream's dependency versions plus purego and goffi.Testing
internal/native,consumer,providerandmessagetests pass on cgo, purego and goffi, andinternal/nativealso passes withCGO_ENABLED=0.CGO_ENABLED=0builds pass for Linux and Windows.internal/nativeprovider tests passed 10/10 on all six configurations (three backends, with and without-race). Without it they passed between 0 and 5 of 10.🤖 Generated with Claude Code