Skip to content

fix(build): tighten Touch ID build tags for cgo-disabled cross-builds#37

Merged
jklaassenjc merged 1 commit into
mainfrom
juergen/fix-cgo-build-tags
May 26, 2026
Merged

fix(build): tighten Touch ID build tags for cgo-disabled cross-builds#37
jklaassenjc merged 1 commit into
mainfrom
juergen/fix-cgo-build-tags

Conversation

@jklaassenjc
Copy link
Copy Markdown
Collaborator

@jklaassenjc jklaassenjc commented May 26, 2026

Summary

PR #36's workflow fix got the auto-release running again, but it failed at make dist with:

internal/mcp/stepup.go:247:11: undefined: touchIDAvailable
internal/mcp/stepup.go:314:13: undefined: newTouchIDStepUpIfSupported

Root cause: KLA-412 added stepup_touchid_darwin.go (cgo wrapper around LocalAuthentication.framework) with //go:build darwin, plus stepup_touchid_other.go with //go:build !darwin. That works for native darwin and native non-darwin builds — but cross-builds default to CGO_ENABLED=0, which silently excludes the cgo file without the stub being picked up. Cross-darwin builds (Linux runner → darwin, or local darwin/arm64 → darwin/amd64) end up with neither.

This is why every release run since KLA-412 has failed at make dist.

Fix

Tighten the tags so the stub covers cgo-disabled darwin too:

File Old New
stepup_touchid_darwin.go darwin darwin && cgo
stepup_touchid_darwin_test.go darwin darwin && cgo
stepup_touchid_other.go !darwin !darwin || !cgo
stepup_touchid_other_test.go !darwin !darwin || !cgo

A darwin binary built without cgo now compiles cleanly and falls back to TTY at runtime — same behavior already exhibited on Macs without Touch ID hardware. Touch ID itself only works in native cgo-enabled darwin builds, which is what make install and go install produce on developer machines anyway.

What ships after this merges

Labeled minor so the (now-working) release workflow produces v1.17.0 with auto-generated notes covering every PR since 1.16.0:

  • KLA-411 — Ed25519 op-envelope signing
  • KLA-412 — Touch ID step-up
  • KLA-417 — Self-describing step-up errors
  • KLA-404 — device_view MCP App
  • KLA-405 — compliance_view MCP App
  • KLA-406 — recipe_runner_view + recipe_run execute path
  • KLA-413 — Webhook out-of-band approval (closes KLA-408 step-up trilogy)
  • KLA-399 — Recipe edit via $EDITOR
  • CI label-check + release workflow fixes

Test plan

  • make dist locally produces all 5 archives (darwin amd64/arm64, linux amd64/arm64, windows amd64)
  • go test ./internal/mcp/ -run "Touch|StepUp" passes natively (cgo on, darwin path exercised)
  • On merge, release workflow successfully publishes v1.17.0 with all 5 binaries attached

🤖 Generated with Claude Code


Note

Low Risk
Build-tag-only change with no runtime logic edits; native cgo darwin builds still get real Touch ID.

Overview
Fixes release make dist failures where darwin cross-builds (CGO_ENABLED=0) compiled neither the cgo Touch ID implementation nor the non-darwin stub, leaving touchIDAvailable / newTouchIDStepUpIfSupported undefined in stepup.go.

Build tags are aligned so one path always provides those symbols: the LocalAuthentication-backed files require darwin && cgo; the stub and its tests compile for !darwin || !cgo (including cgo-disabled darwin). Runtime behavior for shipped cross-compiled darwin binaries is unchanged—TTY step-up fallback, same as Macs without Touch ID.

Reviewed by Cursor Bugbot for commit b442232. Bugbot is set up for automated code reviews on this repo. Configure here.

…work

KLA-412 added stepup_touchid_darwin.go (cgo wrapper around
LocalAuthentication.framework) with //go:build darwin and a
sibling stepup_touchid_other.go with //go:build !darwin holding the
non-darwin stubs.

That worked for native darwin builds (cgo on) and native non-darwin
builds, but broke cross-compilation: any cross-build (e.g. Linux
runner → darwin/amd64, or local darwin/arm64 → darwin/amd64)
defaults to CGO_ENABLED=0. With cgo off, the darwin file is silently
excluded (it uses `import "C"`), and the //go:build !darwin tag on
the stub doesn't match either → touchIDAvailable +
newTouchIDStepUpIfSupported end up undefined.

This is why every release run since KLA-412 merged has failed at
`make dist` — the GHA ubuntu runner cross-builds the darwin
artifacts with cgo off, and the build aborted before producing any
binaries.

Fix: tighten the constraints so the stub picks up the cgo-off case:

  stepup_touchid_darwin.go      → //go:build darwin && cgo
  stepup_touchid_darwin_test.go → //go:build darwin && cgo
  stepup_touchid_other.go       → //go:build !darwin || !cgo
  stepup_touchid_other_test.go  → //go:build !darwin || !cgo

A darwin binary built without cgo now compiles cleanly and falls
back to TTY at runtime — the same behavior already exhibited on
Macs without Touch ID hardware. Touch ID itself only works in
native cgo-enabled darwin builds, which is what `make install` and
`go install` produce on developer machines anyway.

Verified locally: `make dist` now produces all five archives
(darwin amd64/arm64, linux amd64/arm64, windows amd64).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jklaassenjc jklaassenjc merged commit c2b1315 into main May 26, 2026
7 of 8 checks passed
@jklaassenjc jklaassenjc deleted the juergen/fix-cgo-build-tags branch May 26, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants