From b36f27716f63c04d654e46dd115d5195f0c7cbba Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Fri, 10 Jan 2020 05:51:36 +0800 Subject: [PATCH 1/3] golang: Fix selection of GOARM value This fixes how GOARM is selected for arm platforms, based on support for VFP/VFPv3 rather than CPU version. Fixes #10967. Signed-off-by: Jeffery To --- lang/golang/golang-values.mk | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lang/golang/golang-values.mk b/lang/golang/golang-values.mk index ee4ba7f2a..aa13a8791 100644 --- a/lang/golang/golang-values.mk +++ b/lang/golang/golang-values.mk @@ -155,9 +155,31 @@ ifeq ($(GO_ARCH),386) GO_CFLAGS_TO_REMOVE:=-fno-plt else ifeq ($(GO_ARCH),arm) - ifeq ($(CONFIG_arm_v7),y) + GO_TARGET_FPU:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE)))) + + # FPU names from https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/ARM-Options.html#index-mfpu-1 + # see also https://github.com/gcc-mirror/gcc/blob/gcc-8_3_0-release/gcc/config/arm/arm-cpus.in + # + # Assumptions: + # + # * -d16 variants (16 instead of 32 double-precision registers) acceptable + # Go doesn't appear to check the HWCAP_VFPv3D16 flag in + # https://github.com/golang/go/blob/release-branch.go1.13/src/runtime/os_linux_arm.go + # + # * Double-precision required + # Based on no evidence(!) + # Excludes vfpv3xd, vfpv3xd-fp16, fpv4-sp-d16, fpv5-sp-d16 + + GO_ARM_7_FPUS:= \ + vfpv3 vfpv3-fp16 vfpv3-d16 vfpv3-d16-fp16 neon neon-vfpv3 neon-fp16 \ + vfpv4 vfpv4-d16 neon-vfpv4 \ + fpv5-d16 fp-armv8 neon-fp-armv8 crypto-neon-fp-armv8 + + GO_ARM_6_FPUS:=vfp vfpv2 + + ifneq ($(filter $(GO_TARGET_FPU),$(GO_ARM_7_FPUS)),) GO_ARM:=7 - else ifeq ($(CONFIG_arm_v6),y) + else ifneq ($(filter $(GO_TARGET_FPU),$(GO_ARM_6_FPUS)),) GO_ARM:=6 else GO_ARM:=5 From c18adadd9186af0897a49e99c290b32553e529aa Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 14 Jan 2020 22:17:21 +0800 Subject: [PATCH 2/3] golang: Add support for ASLR/PIE for Go packages This adds support to compile position-independent executables for packages that use golang-package.mk. Go packages will have PIE enabled if: * Go supports PIE on the target platform; * CONFIG_PKG_ASLR_PIE is selected; and * PKG_ASLR_PIE (for the package) is not set to 0 Go 1.13 supports PIE for x86 and arm targets; mips support is in progress[1]. [1]: https://github.com/golang/go/issues/21222#issuecomment-542064462 Signed-off-by: Jeffery To --- lang/golang/golang-package.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lang/golang/golang-package.mk b/lang/golang/golang-package.mk index ec7b0e99b..235585b20 100644 --- a/lang/golang/golang-package.mk +++ b/lang/golang/golang-package.mk @@ -120,6 +120,14 @@ GO_PKG_BUILD_BIN_DIR:=$(GO_PKG_BUILD_DIR)/bin$(if $(GO_HOST_TARGET_DIFFERENT),/$ GO_PKG_BUILD_DEPENDS_SRC:=$(STAGING_DIR)$(GO_PKG_PATH)/src +ifeq ($(CONFIG_PKG_ASLR_PIE),y) + ifeq ($(strip $(PKG_ASLR_PIE)),1) + ifeq ($(GO_TARGET_PIE_SUPPORTED),1) + GO_PKG_ENABLE_PIE:=1 + endif + endif +endif + # sstrip causes corrupted section header size ifneq ($(CONFIG_USE_SSTRIP),) ifneq ($(CONFIG_DEBUG),) @@ -281,6 +289,7 @@ define GoPackage/Build/Compile pkg_ldflags="$$$$pkg_ldflags -X $$$$def" ; \ done ; \ go install \ + $(if $(GO_PKG_ENABLE_PIE),-buildmode pie) \ $$$${installsuffix:+-installsuffix $$$$installsuffix} \ -trimpath \ -ldflags "all=$$$$ldflags" \ From 7459757039d09631ae1dde2dc1631a00c8088ae6 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Tue, 14 Jan 2020 22:34:07 +0800 Subject: [PATCH 3/3] golang: Update to 1.13.6 Signed-off-by: Jeffery To --- lang/golang/golang-version.mk | 2 +- lang/golang/golang/Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lang/golang/golang-version.mk b/lang/golang/golang-version.mk index e84520d85..55dedb69c 100644 --- a/lang/golang/golang-version.mk +++ b/lang/golang/golang-version.mk @@ -11,4 +11,4 @@ endif GO_VERSION_MAJOR_MINOR:=1.13 -GO_VERSION_PATCH:=5 +GO_VERSION_PATCH:=6 diff --git a/lang/golang/golang/Makefile b/lang/golang/golang/Makefile index 75badf953..8bfb8260f 100644 --- a/lang/golang/golang/Makefile +++ b/lang/golang/golang/Makefile @@ -10,7 +10,7 @@ include ../golang-version.mk PKG_NAME:=golang PKG_VERSION:=$(GO_VERSION_MAJOR_MINOR)$(if $(GO_VERSION_PATCH),.$(GO_VERSION_PATCH)) -PKG_RELEASE:=2 +PKG_RELEASE:=1 GO_SOURCE_URLS:=https://dl.google.com/go/ \ https://mirrors.ustc.edu.cn/golang/ \ @@ -18,7 +18,7 @@ GO_SOURCE_URLS:=https://dl.google.com/go/ \ PKG_SOURCE:=go$(PKG_VERSION).src.tar.gz PKG_SOURCE_URL:=$(GO_SOURCE_URLS) -PKG_HASH:=27d356e2a0b30d9983b60a788cf225da5f914066b37a6b4f69d457ba55a626ff +PKG_HASH:=aae5be954bdc40bcf8006eb77e8d8a5dde412722bc8effcdaf9772620d06420c PKG_LICENSE:=BSD-3-Clause PKG_LICENSE_FILES:=LICENSE