From 8af359c857144d5d428d9c2f51ea85f909b23264 Mon Sep 17 00:00:00 2001 From: Artur Troian Date: Tue, 8 Aug 2023 11:19:50 -0400 Subject: [PATCH] build(macos): disable linker deprecated warnings on macOS Sonoma Signed-off-by: Artur Troian --- make/init.mk | 29 ++++++++++++++++++++++++++--- make/releasing.mk | 11 ----------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/make/init.mk b/make/init.mk index 60364417a6..5847e81042 100644 --- a/make/init.mk +++ b/make/init.mk @@ -21,13 +21,15 @@ ifndef AKASH_ROOT PATH := $(AKASH_DEVCACHE_BIN):$(AKASH_DEVCACHE_NODE_BIN):$(PATH) endif +SEMVER := $(ROOT_DIR)/script/semver.sh + # require go. to be equal GO_MIN_REQUIRED := $(shell echo $(GOLANG_VERSION) | cut -f1-2 -d ".") -DETECTED_GO_VERSION := $(shell go version | cut -d ' ' -f 3 | sed 's/go*//' | cut -f1-2 -d ".") +DETECTED_GO_VERSION := $(shell go version | cut -d ' ' -f 3 | sed 's/go*//') STRIPPED_GO_VERSION := $(shell echo $(DETECTED_GO_VERSION) | cut -f1-2 -d ".") -__IS_GO_UPTODATE := $(shell $(ROOT_DIR)/script/semver.sh compare $(STRIPPED_GO_VERSION) $(GO_MIN_REQUIRED) && echo $?) +__IS_GO_UPTODATE := $(shell $(ROOT_DIR)/script/semver.sh compare $(STRIPPED_GO_VERSION) $(GO_MIN_REQUIRED); echo $?) GO_MOD_VERSION := $(shell go mod edit -json | jq -r .Go | cut -f1-2 -d ".") -__IS_GO_MOD_MATCHING := $(shell $(ROOT_DIR)/script/semver.sh compare $(GO_MOD_VERSION) $(GO_MIN_REQUIRED) && echo $?) +__IS_GO_MOD_MATCHING := $(shell $(SEMVER) compare $(GO_MOD_VERSION) $(GO_MIN_REQUIRED) && echo $?) ifneq (0, $(__IS_GO_MOD_MATCHING)) $(error go version $(GO_MOD_VERSION) from go.mod does not match GO_MIN_REQUIRED=$(GO_MIN_REQUIRED)) @@ -55,6 +57,27 @@ GO_VET := $(GO) vet -mod=$(GO_MOD) GO_MOD_NAME := $(shell go list -m 2>/dev/null) +ifeq ($(OS),Windows_NT) + DETECTED_OS := Windows +else + DETECTED_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown') +endif + +# on MacOS disable deprecation warnings security framework +ifeq ($(DETECTED_OS), Darwin) + export CGO_CFLAGS=-Wno-deprecated-declarations + + # on MacOS Sonoma Beta there is a bit of discrepancy between Go and new prime linker + clang_version := $(shell echo | clang -dM -E - | grep __clang_major__ | cut -d ' ' -f 3 | tr -d '\n') + go_has_ld_fix := $(shell $(SEMVER) compare "v$(DETECTED_GO_VERSION)" "v1.21.0" | tr -d '\n') + + ifeq (15,$(clang_version)) + ifeq (-1,$(go_has_ld_fix)) + export CGO_LDFLAGS=-Wl,-ld_classic -Wno-deprecated-declarations + endif + endif +endif + # ==== Build tools versions ==== # Format _VERSION GOLANGCI_LINT_VERSION ?= v1.51.2 diff --git a/make/releasing.mk b/make/releasing.mk index c6d5372713..1967f5d876 100644 --- a/make/releasing.mk +++ b/make/releasing.mk @@ -21,17 +21,6 @@ ifeq ($(GORELEASER_MOUNT_CONFIG),true) GORELEASER_IMAGE := -v $(HOME)/.docker/config.json:/root/.docker/config.json $(GORELEASER_IMAGE) endif -ifeq ($(OS),Windows_NT) - DETECTED_OS := Windows -else - DETECTED_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown') -endif - -# on MacOS disable deprecation warnings security framework -ifeq ($(DETECTED_OS), Darwin) - export CGO_CFLAGS=-Wno-deprecated-declarations -endif - # if go.mod contains replace for any modules on local filesystem # mount them into docker during goreleaser build to exactly same path #REPLACED_MODULES := $(shell go list -mod=readonly -m -f '{{ .Replace }}' all 2>/dev/null | grep -v -x -F "" | grep "^/")