From b5ce184179940eb6d5823691794a759e13dbcec1 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 14 Nov 2024 17:43:19 -0600 Subject: [PATCH 1/2] feat(makefile): add CC switch on GOARCH --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 68d523718..ad0d73663 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,12 @@ endif # Disable cgo by default to make the binary statically linked. CGO_ENABLED:=0 +ifeq ($(GOARCH), arm64) + CC:=aarch64-linux-gnu-gcc +else + CC:=gcc +endif + # Set default Go architecture to AMD64. GOARCH ?= amd64 @@ -181,7 +187,7 @@ output/linux_arm64/test/bin/%: $(PKG_SOURCES) # In the future these targets should be deprecated. ./bin/log-counter: $(PKG_SOURCES) ifeq ($(ENABLE_JOURNALD), 1) - CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) go build \ + CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) CC=$(CC) go build \ -o bin/log-counter \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ -tags "$(LINUX_BUILD_TAGS)" \ @@ -191,7 +197,7 @@ else endif ./bin/node-problem-detector: $(PKG_SOURCES) - CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) go build \ + CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) CC=$(CC) go build \ -o bin/node-problem-detector \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ -tags "$(LINUX_BUILD_TAGS)" \ @@ -199,13 +205,13 @@ endif ./test/bin/problem-maker: $(PKG_SOURCES) cd test && \ - CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) go build \ + CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) CC=$(CC) go build \ -o bin/problem-maker \ -tags "$(LINUX_BUILD_TAGS)" \ ./e2e/problemmaker/problem_maker.go ./bin/health-checker: $(PKG_SOURCES) - CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) go build \ + CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(GOARCH) CC=$(CC) go build \ -o bin/health-checker \ -ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \ -tags "$(LINUX_BUILD_TAGS)" \ From 45dde88c98e6baef27eeb661ac281bf06fc75536 Mon Sep 17 00:00:00 2001 From: Dave Young Date: Thu, 14 Nov 2024 17:54:50 -0600 Subject: [PATCH 2/2] chore: update cc def for amd64 to match --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ad0d73663..bcee7ff56 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ CGO_ENABLED:=0 ifeq ($(GOARCH), arm64) CC:=aarch64-linux-gnu-gcc else - CC:=gcc + CC:=x86_64-linux-gnu-gcc endif # Set default Go architecture to AMD64.