Skip to content

Commit

Permalink
(makefile) Dynamically set GOARCH flag while building binaries
Browse files Browse the repository at this point in the history
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 instead of hardcoding to a particular value.
  • Loading branch information
anik120 committed Oct 6, 2022
1 parent caab6c5 commit af4d351
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PKG := $(ORG)/operator-lifecycle-manager
MOD_FLAGS := $(shell (go version | grep -q -E "1\.1[1-9]") && echo -mod=vendor)
BUILD_TAGS := "json1"
CMDS := $(shell go list $(MOD_FLAGS) ./cmd/...)
ARCH := $(shell arch)
TCMDS := $(shell go list $(MOD_FLAGS) ./test/e2e/...)
MOCKGEN := ./scripts/update_mockgen.sh
CODEGEN := ./scripts/update_codegen.sh
Expand Down Expand Up @@ -82,15 +83,15 @@ build-coverage: build_cmd=test -c -covermode=count -coverpkg ./pkg/controller/..
build-coverage: clean $(CMDS)

build-linux: build_cmd=build
build-linux: arch_flags=GOOS=linux GOARCH=386
build-linux: arch_flags=GOOS=linux GOARCH=$(ARCH)
build-linux: clean $(CMDS)

build-wait: clean bin/wait

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

build-util-linux: arch_flags=GOOS=linux GOARCH=386
build-util-linux: arch_flags=GOOS=linux GOARCH=$(ARCH)
build-util-linux: build-util

build-util: bin/cpb
Expand Down

0 comments on commit af4d351

Please sign in to comment.