Skip to content

Commit a8edd5c

Browse files
authored
(makefile) Dynamically set GOARCH flag while building binaries (#2871)
The GOARCH flag was hardcoded to "386", which causes the binaries to not work properly on machines with arm64 arch. This PR dynamically sets the GOARCH flag to arm64 if the machine arch is arm64, or to 386 for all other arch. Signed-off-by: anik120 <[email protected]> Signed-off-by: anik120 <[email protected]>
1 parent caab6c5 commit a8edd5c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go
2929
GINKGO := $(GO) run github.com/onsi/ginkgo/v2/ginkgo
3030
BINDATA := $(GO) run github.com/go-bindata/go-bindata/v3/go-bindata
3131
GIT_COMMIT := $(shell git rev-parse HEAD)
32-
32+
ifeq ($(shell arch), arm64)
33+
ARCH := arm64
34+
else
35+
ARCH := 386
36+
endif
3337
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
3438
.PHONY: build test clean vendor \
3539
coverage coverage-html e2e \
@@ -82,15 +86,15 @@ build-coverage: build_cmd=test -c -covermode=count -coverpkg ./pkg/controller/..
8286
build-coverage: clean $(CMDS)
8387

8488
build-linux: build_cmd=build
85-
build-linux: arch_flags=GOOS=linux GOARCH=386
89+
build-linux: arch_flags=GOOS=linux GOARCH=$(ARCH)
8690
build-linux: clean $(CMDS)
8791

8892
build-wait: clean bin/wait
8993

9094
bin/wait: FORCE
91-
GOOS=linux GOARCH=386 go build $(MOD_FLAGS) -o $@ $(PKG)/test/e2e/wait
95+
GOOS=linux GOARCH=$(ARCH) go build $(MOD_FLAGS) -o $@ $(PKG)/test/e2e/wait
9296

93-
build-util-linux: arch_flags=GOOS=linux GOARCH=386
97+
build-util-linux: arch_flags=GOOS=linux GOARCH=$(ARCH)
9498
build-util-linux: build-util
9599

96100
build-util: bin/cpb

0 commit comments

Comments
 (0)