Skip to content

Commit

Permalink
Set flags to cross-compile darwin/arm64 on darwin/amd64 and vice versa
Browse files Browse the repository at this point in the history
This is an attempt to fix a lack of keychain support in darwin/arm64
binaries that have been cross-compiled on other platforms as described
in #758 and hinted at in
the linked
99designs/keyring@756c48d

Given the keychain support from keyring[1] is provided by cgo, and CGO
is disabled by default in cross-compilation, we need to enable that,
and deal with dev tooling/libraries.

I dug this solution from the Go issues, specifically
golang/go#44112

Be warned, I am not familiar with the ins and outs of Go compilation,
especially when it comes to cross-compilation of CGO code, but at
least in this case, this change allows for a functional cross-compiled
binary.

I fully expect that attempting to cross-compile darwin/arm64 on
anything other than darwin/amd64 (or the opposite way around) is going
to end badly.

[1] https://github.com/99designs/keyring
  • Loading branch information
bazbremner committed Mar 26, 2021
1 parent afcf6d2 commit e141e71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ release: binaries dmgs SHA256SUMS
@echo "\nTo update homebrew-cask run\n\n brew bump-cask-pr --version $(shell echo $(VERSION) | sed 's/v\(.*\)/\1/') aws-vault\n"

aws-vault-darwin-amd64: $(SRC)
GOOS=darwin GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ .
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 SDKROOT=$(shell xcrun --sdk macosx --show-sdk-path) go build $(BUILD_FLAGS) -o $@ .

aws-vault-darwin-arm64: $(SRC)
GOOS=darwin GOARCH=arm64 go build $(BUILD_FLAGS) -o $@ .
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 SDKROOT=$(shell xcrun --sdk macosx --show-sdk-path) go build $(BUILD_FLAGS) -o $@ .

aws-vault-freebsd-amd64: $(SRC)
GOOS=freebsd GOARCH=amd64 go build $(BUILD_FLAGS) -o $@ .
Expand Down

0 comments on commit e141e71

Please sign in to comment.