Files
zeekayandHanzo Dev fadcec94ad fix(crypto): make the luxcpp-linked package opt-in so the cgo test leg can pass
The `test (1)` leg of the CI matrix failed on ONE package and reported the whole
leg red:

    # [pkg-config --cflags -- lux-crypto lux-gpu lux-lattice]
    Package lux-crypto was not found in the pkg-config search path.
    FAIL github.com/luxfi/crypto/cgo [build failed]

Measured against the run log, crypto/cgo is the ONLY package that fails there --
blake3, poseidon2, kem and bindings/cabi all build on the runner. So every other
test in the repo, including everything the race detector was meant to cover, was
being reported red for this one package.

It cannot just be installed. luxfi/luxcpp publishes NO releases, so accel's
`make fetch-deps` -- the in-org precedent -- has nothing to download, and accel's
own CI consequently runs its Go tests with CGO_ENABLED=0. Requiring artifacts
that are not published would keep this leg permanently red.

So the package moves behind `//go:build cgo && luxcpp`. It exports nothing and
nothing in the repo imports it, so gating it costs no coverage; whoever has the
C++ artifacts builds it with `-tags luxcpp`.

Verified both directions:

    PKG_CONFIG_PATH=/nonexistent CGO_ENABLED=1 go build ./...  OK   (failed before)
    PKG_CONFIG_PATH=/nonexistent CGO_ENABLED=1 go vet   ./...  OK
    CGO_ENABLED=1 go build -tags luxcpp ./cgo/                 OK   (luxcpp present)
    gofmt -s -l .                                              clean

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-02 03:25:09 -07:00

37 lines
1.3 KiB
Go

//go:build cgo && luxcpp
// Centralized cgo wrapper to avoid duplicate linking
// All other packages should import this instead of having their own cgo directives
//
// The `luxcpp` tag is opt-in because this is the ONE package in the repo that
// cannot build without the luxcpp C++ artifacts installed. On the runner:
//
// # [pkg-config --cflags -- lux-crypto lux-gpu lux-lattice]
// Package lux-crypto was not found in the pkg-config search path.
// FAIL github.com/luxfi/crypto/cgo [build failed]
//
// which failed the whole cgo leg of the test matrix -- and it was the only
// package that did, so every other test was reported red for this one.
//
// It cannot simply be fetched: luxfi/luxcpp publishes NO releases, so accel's
// `make fetch-deps` has nothing to download either, which is why accel's own CI
// runs its Go tests with CGO_ENABLED=0. Until luxcpp ships artifacts, this stays
// opt-in and is built by whoever has them:
//
// go build -tags luxcpp ./cgo/
package luxlink
/*
#cgo pkg-config: lux-crypto lux-gpu lux-lattice
#include <lux/crypto/crypto.h>
#include <lux/crypto/metal_mldsa.h>
#include <lux/crypto/metal_mlkem.h>
#include <lux/crypto/metal_slhdsa.h>
#include <lux/crypto/metal_ipa.h>
#include <lux/gpu/gpu.h>
*/
import "C"
// Export Go APIs that other packages can call
// This ensures libraries are only linked once