Skip to content

Fix CGO_CFLAGS and static-link errors in release workflow#161

Merged
steffenfritz merged 1 commit intomainfrom
fix/release-workflow-cgo
Apr 1, 2026
Merged

Fix CGO_CFLAGS and static-link errors in release workflow#161
steffenfritz merged 1 commit intomainfrom
fix/release-workflow-cgo

Conversation

@steffenfritz
Copy link
Copy Markdown
Owner

Summary

Fixes two bugs introduced with the release workflow that surfaced during pre-release test runs (v1.0.0-beta.5, v1.0.0-beta.6).

macOS — clang: error: no such file or directory: 'arm64'

CGO_CFLAGS was set using find ... -name "yara_x_capi.h" to locate the include directory. On M-chip runners the YARA-X install prefix is not always /usr/local, so find returned empty, leaving CGO_CFLAGS=-I (a bare -I with no path). Clang then consumed the next flag (-arch) as the include path, with arm64 left as a dangling file argument — exactly the error observed.

Fix: derive the include path from pkg-config --variable=prefix, which is the same approach already used in buildstatus.yml and the local setup_mac task.

Linux (amd64 + arm64) — cannot find -lgcc_s

task build triggers the build-static subtask, which passes -extldflags '-static ...' to the external linker. That requires libgcc_s.a (the static GCC runtime), which Ubuntu runners do not ship. The .deb package only contains the dynamic binary, so the static build step is unnecessary in CI.

Fix: replace task build with direct go build commands that produce the dynamic binary only, skipping the static build entirely.

Test plan

  • Push a new pre-release tag to trigger the workflow
  • Confirm all three jobs complete: build-linux amd64, build-linux arm64, build-macos-arm64
  • Confirm the release job attaches all three assets to the GitHub Release

🤖 Generated with Claude Code

macOS: CGO_CFLAGS was set via `find ... -name yara_x_capi.h` which
returns empty on M-chip runners where the install prefix differs.
An empty -I flag causes clang to consume the following -arch flag as
the include path, leaving 'arm64' as a dangling file argument.
Fix: derive the include path from `pkg-config --variable=prefix`,
matching the approach already used in buildstatus.yml.

Linux: `task build` triggers the build-static subtask which links with
-extldflags '-static', requiring libgcc_s.a. Ubuntu runners do not
ship the static GCC runtime library. The .deb package only contains
the dynamic binary, so the static build is unnecessary in CI.
Fix: run `go build` directly for the dynamic binary only, skipping
the static build step entirely.

Both jobs now use the same YARA-X env var derivation pattern as the
existing buildstatus.yml workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@steffenfritz steffenfritz self-assigned this Apr 1, 2026
@steffenfritz steffenfritz added the bug Something isn't working label Apr 1, 2026
@steffenfritz steffenfritz merged commit 28a4b09 into main Apr 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant