Skip to content

Commit

Permalink
Fix Building of Static Binaries With Go 1.20
Browse files Browse the repository at this point in the history
Explicitly disable CGO when building binaries.  As of Go 1.20, we get
dynamic executables when using standard libary packages that have both
cgo and pure Go implementations.

Fixes errors in which release binaries may fail because the correct
version of libc can't be linked at runtime.

See golang/go#58550
  • Loading branch information
cwarden committed Apr 19, 2023
1 parent db2c023 commit 81b325b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ install-debug:
go install ${LDFLAGS} ${GCFLAGS}

$(WINDOWS):
env GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) ${LDFLAGS}
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) ${LDFLAGS}

$(LINUX):
env GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) ${LDFLAGS}
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) ${LDFLAGS}

$(OSX_AMD64):
env GOOS=darwin GOARCH=amd64 go build -v -o $(OSX_AMD64) ${LDFLAGS}
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -o $(OSX_AMD64) ${LDFLAGS}

$(OSX_ARM64):
env GOOS=darwin GOARCH=arm64 go build -v -o $(OSX_ARM64) ${LDFLAGS}
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -v -o $(OSX_ARM64) ${LDFLAGS}

$(basename $(WINDOWS)).zip: $(WINDOWS)
zip $@ $<
Expand Down

0 comments on commit 81b325b

Please sign in to comment.