Skip to content

Commit

Permalink
makefile: Set CC explicitly in go build (#9784)
Browse files Browse the repository at this point in the history
This is required because Go does not pull CC from the make variable. This uses
whatever Go's default CC unless CC is overridden, as it is for the ARM targets.

This also makes it easier to build Nomad on a native ARM device, via:

```
make CC= pkg/linux_arm/nomad
```
  • Loading branch information
Kris Hicks authored and backspace committed Jan 22, 2021
1 parent 5f3a937 commit a4479f2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ SUPPORTED_OSES = Darwin Linux FreeBSD Windows MSYS_NT
-include GNUMakefile.local

pkg/%/nomad: GO_OUT ?= $@
pkg/%/nomad: CC ?= $(shell go env CC)
pkg/%/nomad: ## Build Nomad for GOOS_GOARCH, e.g. pkg/linux_amd64/nomad
ifeq (,$(findstring $(THIS_OS),$(SUPPORTED_OSES)))
$(warning WARNING: Building Nomad is only supported on $(SUPPORTED_OSES); not $(THIS_OS))
Expand All @@ -63,6 +64,7 @@ endif
@CGO_ENABLED=1 \
GOOS=$(firstword $(subst _, ,$*)) \
GOARCH=$(lastword $(subst _, ,$*)) \
CC=$(CC) \
go build -trimpath -ldflags $(GO_LDFLAGS) -tags "$(GO_TAGS)" -o $(GO_OUT)

pkg/linux_arm/nomad: CC = arm-linux-gnueabihf-gcc-5
Expand Down

0 comments on commit a4479f2

Please sign in to comment.