fix: give the Metal anchor a package-unique symbol name

deps: gpu v1.1.2 — the older tags name the wrong pkg-config package

gpu v1.0.1/v1.1.0 declare `#cgo pkg-config: lux-gpu` while including
<lux/gpu.h>. Those are two different libraries with confusingly similar names:

  luxgpu.pc   unified GPU acceleration, -lluxgpu,   Cflags -I${includedir}
  lux-gpu.pc  the DEX order matcher,    -llux_gpu,  Cflags -I${includedir}/lux

Under lux-gpu the include resolves to .../include/lux/lux/gpu.h, so every cgo
build failed with "fatal error: lux/gpu.h file not found" — the arm64 stall
signature. libluxgpu.dylib is also what actually exports _lux_gpu_ecrecover_batch.

gpu v1.1.2 already declares luxgpu; only the pin was stale.

With that fixed the link got one step further and hit a duplicate symbol:
cevm and dex/pkg/lx both define a global lux_secp256k1_metal_anchor, so any
binary linking both refuses. The anchor exists only to keep the Metal driver
alive through linker dead-code elimination — luxcpp resolves the DRIVER symbol
(secp256k1_ecrecover_address_batch_metal) via dlsym, never the anchor, so the
anchor name is internal and safe to qualify. Named lux_cevm_secp256k1_metal_anchor
after the package that owns it.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-07-28 08:43:24 -07:00
co-authored by Hanzo Dev
parent 7a830a1666
commit 1231964a90
4 changed files with 8 additions and 8 deletions
@@ -11,5 +11,5 @@ extern int secp256k1_ecrecover_address_batch_metal(
const uint8_t* inputs, size_t n,
uint8_t* out_addr, uint8_t* out_st, const char* metallib_path);
void* const lux_secp256k1_metal_anchor =
void* const lux_cevm_secp256k1_metal_anchor =
(void*)&secp256k1_ecrecover_address_batch_metal;
@@ -8,17 +8,17 @@ package cevm
/*
#include <stddef.h>
extern void* const lux_secp256k1_metal_anchor;
extern void* const lux_cevm_secp256k1_metal_anchor;
static inline void* lux_secp256k1_metal_anchor_keep(void) {
return lux_secp256k1_metal_anchor;
static inline void* lux_cevm_secp256k1_metal_anchor_keep(void) {
return lux_cevm_secp256k1_metal_anchor;
}
*/
import "C"
// metalAnchorAddr keeps the anchor + Metal driver symbol alive through
// linker DCE. See cpp/ecrecover.cpp for the dispatch logic.
var metalAnchorAddr = C.lux_secp256k1_metal_anchor_keep()
var metalAnchorAddr = C.lux_cevm_secp256k1_metal_anchor_keep()
func init() {
if metalAnchorAddr == nil {
+1 -1
View File
@@ -154,7 +154,7 @@ require (
github.com/luxfi/genesis v1.16.2 // indirect
github.com/luxfi/go-bip32 v1.1.0 // indirect
github.com/luxfi/go-bip39 v1.2.0 // indirect
github.com/luxfi/gpu v1.0.1 // indirect
github.com/luxfi/gpu v1.1.2 // indirect
github.com/luxfi/keychain v1.1.1 // indirect
github.com/luxfi/lens v0.2.1 // indirect
github.com/luxfi/magnetar v1.2.3 // indirect
+2 -2
View File
@@ -340,8 +340,8 @@ github.com/luxfi/go-bip32 v1.1.0 h1:zjy19WKa1KJnGamRNyOZM3l/MPtV/sax7M4NMPwLHZQ=
github.com/luxfi/go-bip32 v1.1.0/go.mod h1:QyDXlzWL3xRiCbMUi4Z3J52Q/SMoCvdRLXXlYvSZor8=
github.com/luxfi/go-bip39 v1.2.0 h1:fx3pFuSGawCG4In6pA4OLLStqbgIqD1j8EygFskoHzY=
github.com/luxfi/go-bip39 v1.2.0/go.mod h1:if+2OVbG4k4jKIuBt/Rse1KV1kgWQM5j5xFbUtwbNtc=
github.com/luxfi/gpu v1.0.1 h1:7cDJTwTZ8Wk5KmyzsiGPe1nekyTgsSG6LJ+4rgKim8E=
github.com/luxfi/gpu v1.0.1/go.mod h1:8r1ReBPsLx1zmcA3GksKD4J7azP52FSTU/LpT9TyYHE=
github.com/luxfi/gpu v1.1.2 h1:xQupCMqb8L18WoBaMcTzVGP8856Nkhc+CkmqKzMw9nI=
github.com/luxfi/gpu v1.1.2/go.mod h1:26fz0M7/R8PwZIR2Z3DTZ+iZWInb2AG4v3/wKwL/44Q=
github.com/luxfi/ids v1.3.2 h1:c6Rft5kZB4XqiCtWaGH47bfhaNFm3FGRfhEzI01GVeI=
github.com/luxfi/ids v1.3.2/go.mod h1:+5l8cYMbKpORJbQ2r98CYJo9TQATgUdnmzpYFZWMwwc=
github.com/luxfi/keychain v1.1.1 h1:dTYEPy6CGVC1sogMci4iJogUvW6VdTmemplQdzRqnAs=