From 19144187614837aa811b2afb45526cdb34b7fbce Mon Sep 17 00:00:00 2001 From: Sergey Zolotarev Date: Sun, 28 Apr 2024 23:20:13 +0600 Subject: [PATCH] Fix cross-compilation errors when CGO_CFLAGS/CGO_LDFLAGS is set When you cross-compile Gitea and you specify one of the envrionment variables related to C flags, cgo will fail to build the generator programs (e.g. generate-bindata) because GOOS and GOARCH are unset, but those additional flags variables are not unset together with those. To solve this issue, the simplest way that I've found is to disable cgo in the `go generate` command as it's not really used there. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0cd6abb81e6d6..e8006e40311b3 100644 --- a/Makefile +++ b/Makefile @@ -778,7 +778,7 @@ generate-backend: $(TAGS_PREREQ) generate-go .PHONY: generate-go generate-go: $(TAGS_PREREQ) @echo "Running go generate..." - @CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' ./... + @CC= GOOS= GOARCH= CGO_ENABLED=0 $(GO) generate -tags '$(TAGS)' ./... .PHONY: security-check security-check: