From d3762591dabb5c15c6e531a05801d0f0031fe67d Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Thu, 14 May 2020 17:45:18 +0800 Subject: [PATCH] golang: Set/reset default platform options for target Go compiler Because the first stage for building target Go is actually a host build, the default platform options (GO386, GOARM, etc.) are detected from the host. These values are written to a source file and kept when building the second stage. This modifies this source file to set the appropriate values for the target platform, and reset values for other platforms to their cross-compiling / most compatible defaults. Signed-off-by: Jeffery To (cherry picked from commit da3fb97b9cef4f705dda4b190f99536f27d0955d) --- lang/golang/golang/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lang/golang/golang/Makefile b/lang/golang/golang/Makefile index c242c1cc8f..5e26461f59 100644 --- a/lang/golang/golang/Makefile +++ b/lang/golang/golang/Makefile @@ -148,6 +148,13 @@ This package provides the Go programming language source files needed for cross-compilation. endef +PKG_GO_ZBOOTSTRAP_MODS:= \ + s/defaultGO386 = `[^`]*`/defaultGO386 = `$(if $(GO_386),$(GO_386),387)`/; \ + s/defaultGOARM = `[^`]*`/defaultGOARM = `$(if $(GO_ARM),$(GO_ARM),5)`/; \ + s/defaultGOMIPS = `[^`]*`/defaultGOMIPS = `$(if $(GO_MIPS),$(GO_MIPS),hardfloat)`/; \ + s/defaultGOMIPS64 = `[^`]*`/defaultGOMIPS64 = `$(if $(GO_MIPS64),$(GO_MIPS64),hardfloat)`/; \ + s/defaultGOPPC64 = `[^`]*`/defaultGOPPC64 = `power8`/; + define Download/golang-bootstrap FILE:=$(BOOTSTRAP_SOURCE) URL:=$(BOOTSTRAP_SOURCE_URL) @@ -233,6 +240,11 @@ define Build/Compile PATH=$(HOST_GO_ROOT)/openwrt:$$$$PATH \ ) + ifneq ($(PKG_GO_ZBOOTSTRAP_MODS),) + $(SED) '$(PKG_GO_ZBOOTSTRAP_MODS)' \ + $(PKG_BUILD_DIR)/src/cmd/internal/objabi/zbootstrap.go + endif + @echo "Building target Go second stage" ( \ -- 2.30.2