endif
endif
+ifdef CONFIG_GOLANG_SPECTRE
+ ifeq ($(GO_TARGET_SPECTRE_SUPPORTED),1)
+ GO_PKG_ENABLE_SPECTRE:=1
+ else
+ $(warning Spectre mitigations are not supported for $(GO_ARCH))
+ endif
+endif
+
# sstrip causes corrupted section header size
ifneq ($(CONFIG_USE_SSTRIP),)
ifneq ($(CONFIG_DEBUG),)
$(GO_PKG_TARGET_VARS) \
$(GO_PKG_BUILD_VARS)
+GO_PKG_DEFAULT_GCFLAGS= \
+ $(if $(GO_PKG_ENABLE_SPECTRE),-spectre all)
+
+GO_PKG_DEFAULT_ASMFLAGS= \
+ $(if $(GO_PKG_ENABLE_SPECTRE),-spectre all)
+
GO_PKG_DEFAULT_LDFLAGS= \
-buildid '$(SOURCE_DATE_EPOCH)' \
-linkmode external \
-v \
-trimpath \
-ldflags "all=$(GO_PKG_DEFAULT_LDFLAGS)" \
+ $(if $(GO_PKG_DEFAULT_GCFLAGS),-gcflags "all=$(GO_PKG_DEFAULT_GCFLAGS)") \
+ $(if $(GO_PKG_DEFAULT_ASMFLAGS),-asmflags "all=$(GO_PKG_DEFAULT_ASMFLAGS)") \
$(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie) \
$(if $(filter $(GO_ARCH),arm),-installsuffix "v$(GO_ARM)") \
$(if $(filter $(GO_ARCH),mips mipsle),-installsuffix "$(GO_MIPS)") \
$(if $(filter $(GO_ARCH),mips64 mips64le),-installsuffix "$(GO_MIPS64)") \
- $(if $(GO_PKG_GCFLAGS),-gcflags "$(GO_PKG_GCFLAGS)") \
+ $(if $(GO_PKG_GCFLAGS),-gcflags "$(GO_PKG_GCFLAGS) $(GO_PKG_DEFAULT_GCFLAGS)") \
$(if $(GO_PKG_CUSTOM_LDFLAGS),-ldflags "$(GO_PKG_CUSTOM_LDFLAGS) $(GO_PKG_DEFAULT_LDFLAGS)") \
$(if $(GO_PKG_TAGS),-tags "$(GO_PKG_TAGS)")
ifneq ($(strip $(GO_PKG)),)
+ ifeq ($(GO_TARGET_SPECTRE_SUPPORTED),1)
+ PKG_CONFIG_DEPENDS+=CONFIG_GOLANG_SPECTRE
+ endif
+
Build/Configure=$(call GoPackage/Build/Configure)
Build/Compile=$(call GoPackage/Build/Compile)
Hooks/Compile/Post+=Go/CacheCleanup
endif
+# Spectre mitigations
+
+GO_SPECTRE_SUPPORTED_ARCH:=amd64
+
+ifneq ($(filter $(GO_HOST_ARCH),$(GO_SPECTRE_SUPPORTED_ARCH)),)
+ GO_HOST_SPECTRE_SUPPORTED:=1
+endif
+
+ifneq ($(filter $(GO_ARCH),$(GO_SPECTRE_SUPPORTED_ARCH)),)
+ GO_TARGET_SPECTRE_SUPPORTED:=1
+endif
+
+
# General build info
GO_BUILD_CACHE_DIR:=$(or $(call qstrip,$(CONFIG_GOLANG_BUILD_CACHE_DIR)),$(TOPDIR)/.go-build)
RSTRIP:=:
STRIP:=:
+ifeq ($(GO_TARGET_SPECTRE_SUPPORTED),1)
+ PKG_CONFIG_DEPENDS+=CONFIG_GOLANG_SPECTRE
+endif
+
define Package/golang/Default
$(call GoPackage/GoSubMenu)
TITLE:=Go programming language
PKG_CONFIG=pkg-config \
PATH="$(HOST_GO_ROOT)/openwrt:$$$$PATH"
+PKG_GO_GCFLAGS= \
+ $(if $(GO_PKG_ENABLE_SPECTRE),-spectre all)
+
+PKG_GO_ASMFLAGS= \
+ $(if $(GO_PKG_ENABLE_SPECTRE),-spectre all)
+
PKG_GO_LDFLAGS= \
-buildid '$(SOURCE_DATE_EPOCH)' \
-linkmode external \
# static / not dependent on the build environment
PKG_GO_INSTALL_ARGS= \
-ldflags "all=$(PKG_GO_LDFLAGS)" \
+ $(if $(PKG_GO_GCFLAGS),-gcflags "all=$(PKG_GO_GCFLAGS)") \
+ $(if $(PKG_GO_ASMFLAGS),-asmflags "all=$(PKG_GO_ASMFLAGS)") \
$(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie)
define Build/Compile