Skip to content

Commit

Permalink
build(macos): disable linker deprecated warnings on macOS Sonoma
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Aug 8, 2023
1 parent b8dabb2 commit 894a8d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
24 changes: 21 additions & 3 deletions make/init.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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<major>.<minor> 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))
Expand Down Expand Up @@ -55,6 +57,22 @@ 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
ifeq (-1,$(shell $(SEMVER) compare "v$(DETECTED_GO_VERSION)" "v1.21.0" | tr -d '\n'))
export CGO_LDFLAGS=-Wl,-ld_classic -Wno-deprecated-declarations
endif
endif

# ==== Build tools versions ====
# Format <TOOL>_VERSION
GOLANGCI_LINT_VERSION ?= v1.51.2
Expand Down
11 changes: 0 additions & 11 deletions make/releasing.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<nil>" | grep "^/")
Expand Down

0 comments on commit 894a8d7

Please sign in to comment.