From 103307218e966f16eb4c79d2806cccf9f6652c96 Mon Sep 17 00:00:00 2001 From: typebasedio Date: Thu, 7 May 2026 19:22:54 -0400 Subject: [PATCH] fix(v0.5.1): force CGO_ENABLED=0 in cross-build targets A native Linux build of build-linux defaulted to CGO_ENABLED=1 and produced a glibc-linked binary, which would not run in minimal containers (Alpine, distroless, scratch). The Windows cross-compile was already pure-Go because Go disables cgo when no host C toolchain is available; making CGO_ENABLED=0 explicit keeps both targets statically linked regardless of build host. Verified on WSL: file reports "statically linked", ldd reports "not a dynamic executable". --- justfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index a394cd2..d9a1388 100644 --- a/justfile +++ b/justfile @@ -10,15 +10,19 @@ default: build: go build -o ctask.exe . -# Cross-compile a Linux amd64 binary into dist/ +# Cross-compile a Linux amd64 binary into dist/. CGO_ENABLED=0 forces a +# pure-Go static link so the binary works in minimal containers (Alpine, +# distroless, scratch). Without this, native Linux builds default to +# CGO_ENABLED=1 and link against the host glibc. build-linux: mkdir -p dist - GOOS=linux GOARCH=amd64 go build -o dist/ctask-linux-amd64 ./ + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dist/ctask-linux-amd64 ./ -# Cross-compile a Windows amd64 binary into dist/ +# Cross-compile a Windows amd64 binary into dist/. CGO_ENABLED=0 keeps +# the artifact pure Go, matching the spec's "no cgo" rule. build-windows: mkdir -p dist - GOOS=windows GOARCH=amd64 go build -o dist/ctask-windows-amd64.exe ./ + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dist/ctask-windows-amd64.exe ./ # Build both Windows and Linux artifacts into dist/ build-all: build-windows build-linux