Files
zooqueen f2e3705e96 lx: make CGO=1 build cross-platform; honest secp256k1 GPU fallback
CGO_ENABLED=1 go build ./... failed to link every binary importing
pkg/lx: signed_order_gpu.go unconditionally force-linked the Apple-only
libsecp256k1_metal.a via a hardcoded build-tree -L path and the
signed-order Metal anchor. That archive is not built by default and has
no pkg-config bundle, so the link aborted with 'library secp256k1_metal
not found'. The GPU-vs-CPU choice must be a runtime decision, never a
hard build-time link dependency on an absent accelerator.

- Gate the secp256k1 Metal force-link anchor (.go + .c) behind the
  opt-in 'lux_secp256k1_metal' build tag and move the Metal/Foundation
  LDFLAGS there. Default CGO builds now link and run the secp256k1 CPU
  ecrecover pipeline (via the working lux-crypto-secp256k1 .pc); the
  Metal accelerator, when its archive is built and the tag is set, is
  still resolved at runtime by cpp/ecrecover.cpp via dlsym gated on
  LUX_SECP256K1_METALLIB / LUX_SECP256K1_BACKEND.
- signed_order_gpu.go keeps only the CPU pkg-config; the anchor file
  documents the build + opt-in recipe.
- signed_order_cpu.go: verifyOrdersCPU returns nil for empty input,
  matching the cgo BatchVerifyOrders contract so CPU and cgo paths agree
  byte-for-byte (fixes TestBatchVerifyOrders_Empty under CGO=0).
- README: remove the non-existent 'dex_gpu' build-tag claim; document
  the real model — AMM/CLOB GPU paths live in pkg/lx, bind the luxcpp
  DEX kernels via pkg-config (lux-dex-amm-metal / -amm-cuda / -clob-cuda),
  and select GPU-vs-CPU at runtime via crypto/backend detection with a
  logged, honest CPU fallback.

The DEX AMM Metal bridge (amm_xyk_batch_metal) now compiles, links, and
its dispatch is byte-identical to the CPU oracle (parity test green
under CGO=1). CLOB GPU primitive (MatchOrderGPU) stays a flat-buffer
parity/backtest primitive, intentionally not wired into the live
linked-list MatchOrders() engine.

Verified: CGO_ENABLED=0 go test ./... green (16 pkgs, 1360 cases);
CGO_ENABLED=1 go build ./... exit 0.
2026-06-21 22:37:05 -07:00
..