From 33e0611d6431536122c315161e6896baae55ea67 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 28 Sep 2021 15:14:52 -0400 Subject: [PATCH] crosscompile to amd64 when building on darwin/arm64 (#2381) --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e6bf429dc..c2808ce33 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,10 @@ endif ifeq ($(detected_OS),Darwin) GOBIN_SHARED_LIB_EXT := dylib + ifeq ("$(shell sysctl -nq hw.optional.arm64)","1") + # Building on M1 is still not supported, so in the meantime we crosscompile to amd64 + GOBIN_SHARED_LIB_CFLAGS=CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 + endif else ifeq ($(detected_OS),Windows) # on Windows need `--export-all-symbols` flag else expected symbols will not be found in libstatus.dll GOBIN_SHARED_LIB_CGO_LDFLAGS := CGO_LDFLAGS="-Wl,--export-all-symbols" @@ -151,7 +155,7 @@ statusgo-shared-library: ##@cross-compile Build status-go as shared library for mkdir -p $(GOBIN)/statusgo-lib go run cmd/library/*.go > $(GOBIN)/statusgo-lib/main.go @echo "Building shared library..." - $(GOBIN_SHARED_LIB_CGO_LDFLAGS) go build \ + $(GOBIN_SHARED_LIB_CFLAGS) $(GOBIN_SHARED_LIB_CGO_LDFLAGS) go build \ $(BUILD_FLAGS) \ -buildmode=c-shared \ -o $(GOBIN)/libstatus.$(GOBIN_SHARED_LIB_EXT) \