-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Context
We have several Go wrapper repositories that bind to Nim libraries compiled as shared libraries via CGO:
waku-org/waku-go-bindings
→ requiresnwaku
waku-org/sds-go-bindings
→ requiresnim-sds
- Future: Waku Chat SDK
- Future: Nimbus Verification Proxy
Current Approach
Binding repository has a Makefile target that clones the Nim library into a third_party/
subdirectory (e.g., third_party/nwaku
), then builds the shared library from source.
This currently works because we vendor dependencies in status-go
, so when users run make
in the vendored bindings directory, there are no permission issues.
The Problem
We are removing vendoring from status-go
(#6951). Once vendoring is removed, the current approach breaks because:
- Go module cache is read-only: When users
go get
the bindings, they're downloaded to$GOPATH/pkg/mod/
, which is read-only. The Makefile cannot clone intothird_party/
or write build artifacts. go get
doesn't run Make: Go's standard workflow doesn't execute Makefiles, so users must manually discover and run build steps.
Why Git Submodules Don't Work
- Go module incompatibility:
go get
doesn't fetch git submodules, breaking the standard Go workflow - Nested submodule issues:
status-go
is already a submodule ofstatus-desktop
. Adding Nim libraries as submodules ofstatus-go
creates deeply nested submodules (desktop → status-go → nwaku), which causes build failures and is difficult to maintain
Viable Options
Option 1: System Installation - the only Go-idiomatic approach
Document installation via package managers (apt, brew, etc.) or install scripts.
Pros | Cons |
---|---|
✅ Small repo size | ❌ Doesn't exist at the moment |
✅ Standard Unix approach | |
✅ Separation of concerns | ❌ Can't fix/define dependency version |
Option 2: Environment Variable Configuration
Use environment variables to let users specify library paths, supporting multiple installation methods.
CGO directives in the bindings:
package wakugo
/*
#cgo CFLAGS: -I${NWAKU_INCLUDE_DIR}
#cgo LDFLAGS: -L${NWAKU_LIB_DIR} -lnwaku -Wl,-rpath,${NWAKU_LIB_DIR}
#include "nwaku.h"
*/
import "C"
Option 3: Vendor Pre-compiled Binaries
Bundle pre-compiled .so
/.dylib
/.dll
files for common platforms directly in each wrapper repo.
Pros | Cons |
---|---|
✅ Works with go get out of the box |
go get ) |
✅ Zero installation steps for users | |
✅ Standard Go module experience | nwaku version |
✅ No build step required |
Option 4: Nimble Package Manager
Distribute Nim libraries via Nimble and document installation via nimble install
.
Pros | Cons |
---|---|
✅ Natural for Nim developers (our primary contributors) | go get alone |
✅ Existing ecosystem and tooling | |
✅ Easy updates via Nimble | ❌ All our dependencies are not available with Nimble yet (ETA 1-2 months?) |
Option 5: Git Subtree
Embed Nim library source using git subtree
into each wrapper repo.
Pros | Cons |
---|---|
✅ Works with go get |
|
✅ No nested submodule issues |
Option 6: Manually download libwaku
artifacts
Implement a custom solution to download libwaku
artifacts from Github Releases.
Example in waku-org/waku-go-bindings#92.
Pros | Cons |
---|---|
✅Smaller repo size (no vendored binaries) | go get alone - requires running download script first |
✅Fast implementation, no need to integrate with package managers | ❌️Still writes to read-only module cache if triggered during go get |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status