--- id: "bug-1441" status: "fixed" status_updated: "2026-09-24" status_note: "wire_dispatch_support.go direct Go call" component: "apiserver" severity: "unknown" timestamp: "2026-07-15T09:40:00Z" last_seen: "2026-09-19T09:00:00Z" occurrences: 1 files: ["src/frontend/apiserver/backend/wire_dispatch_support.go"] tags: ["cgo", "wire_dispatch", "go_push_handler", "cross-file-declaration", "job-array-single-wal-record", "test-backend", "CGO_CFLAGS"] related: ["bug-1440"] legacy: true --- # bug-1441: backend/wire_dispatch_support.go:154:8: could not determine what C.go_push_handler refers to /… ## Description backend/wire_dispatch_support.go:154:8: could not determine what C.go_push_handler refers to / FAIL apiserver/backend [build failed] ## Environment _Not recorded (migrated from buglog.json)._ ## Reproduction _Not recorded (migrated from buglog.json)._ ## Root cause cgo declaration visibility is per-file, not per-package: go_push_handler is exported to C only via clib.go's own preamble comment ("extern int go_push_handler(xce_request_t*, void*);" immediately followed by "//export go_push_handler" on the Go func), and that extern declaration lives nowhere in any shared header -- it is a plain comment inside clib.go's /* ... */ block, not client.h/netio.h/request.h/controller.capnp.h. cgo processes each file's own preamble independently to build that file's C.xxx symbol table, so wire_dispatch_support.go (which #includes client.h/netio.h/request.h/controller.capnp.h but does NOT itself declare go_push_handler) has no visibility into that extern, even though both files are in the same Go package and both carry //go:build cgo. This surfaced only after fixing bug-1440's toolchain-level rejection (moving import "C" out of the _test.go file) and after separately discovering make test-backend also needs CGO_CFLAGS/CGO_LDFLAGS manually derived to match src/frontend/apiserver/meson.build (pkg-config --cflags/--libs for librtti, c-capnproto, openssl, tinylog, plus -I/src/include -I/src/build/lib -L/src/build/lib -lxce -pthread -lm) since the nix devshell itself does not export them and make test-backend invokes go test directly rather than through the meson/go_build path that normally injects them. ## Fix NOT FIXED -- user explicitly instructed build/run/report only, no source edits. Reported fix path for the user: add the same "extern int go_push_handler(xce_request_t*, void*);" declaration to wire_dispatch_support.go's own cgo preamble (matching clib.go's exact signature), OR move that extern declaration into a shared header both files already include. Because the toolchain stops at first error, it is unknown whether wire_dispatch_support.go/wire_dispatch_test.go have any FURTHER errors (e.g. C.free_JobSubmit_ptr signature, C.extract_data, C.xce_encode/xce_decode field access) beyond this first blocking one -- those can only be discovered after this fix. Separately (env-only, no source change): make test-backend also requires CGO_CFLAGS/CGO_LDFLAGS to be exported manually before invoking make, mirroring meson.build's pkg-config-derived flags -- the bare Makefile command alone (as documented) does not produce a working CGO_ENABLED=1 build in this worktree. ## Verification _Not recorded (migrated from buglog.json)._ ## References - Related: bug-1440