summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/go')
-rw-r--r--meta/recipes-devtools/go/go-1.19.inc19
-rw-r--r--meta/recipes-devtools/go/go-1.22.2.inc18
-rw-r--r--meta/recipes-devtools/go/go-binary-native_1.22.2.bb (renamed from meta/recipes-devtools/go/go-binary-native_1.19.bb)8
-rw-r--r--meta/recipes-devtools/go/go-common.inc3
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian.inc14
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian_1.22.2.bb (renamed from meta/recipes-devtools/go/go-cross-canadian_1.19.bb)0
-rw-r--r--meta/recipes-devtools/go/go-cross_1.22.2.bb (renamed from meta/recipes-devtools/go/go-cross_1.19.bb)0
-rw-r--r--meta/recipes-devtools/go/go-crosssdk.inc6
-rw-r--r--meta/recipes-devtools/go/go-crosssdk_1.22.2.bb (renamed from meta/recipes-devtools/go/go-crosssdk_1.19.bb)0
-rw-r--r--meta/recipes-devtools/go/go-native_1.22.2.bb (renamed from meta/recipes-devtools/go/go-native_1.19.bb)2
-rw-r--r--meta/recipes-devtools/go/go-runtime.inc6
-rw-r--r--meta/recipes-devtools/go/go-runtime_1.22.2.bb (renamed from meta/recipes-devtools/go/go-runtime_1.19.bb)0
-rw-r--r--meta/recipes-devtools/go/go-target.inc6
-rw-r--r--meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch91
-rw-r--r--meta/recipes-devtools/go/go/0001-exec.go-do-not-write-linker-flags-into-buildids.patch36
-rw-r--r--meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch (renamed from meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch)42
-rw-r--r--meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch (renamed from meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch)17
-rw-r--r--meta/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch (renamed from meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch)20
-rw-r--r--meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch221
-rw-r--r--meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch282
-rw-r--r--meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch (renamed from meta/recipes-devtools/go/go/0007-cmd-go-make-GOROOT-precious-by-default.patch)40
-rw-r--r--meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch61
-rw-r--r--meta/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch (renamed from meta/recipes-devtools/go/go/0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch)17
-rw-r--r--meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch (renamed from meta/recipes-devtools/go/go/filter-build-paths.patch)30
-rw-r--r--meta/recipes-devtools/go/go/stack-protector.patch32
-rw-r--r--meta/recipes-devtools/go/go_1.22.2.bb (renamed from meta/recipes-devtools/go/go_1.19.bb)6
26 files changed, 477 insertions, 500 deletions
diff --git a/meta/recipes-devtools/go/go-1.19.inc b/meta/recipes-devtools/go/go-1.19.inc
deleted file mode 100644
index f733a807b4..0000000000
--- a/meta/recipes-devtools/go/go-1.19.inc
+++ /dev/null
@@ -1,19 +0,0 @@
-require go-common.inc
-
-FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go:"
-
-LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707"
-
-SRC_URI += "\
- file://0001-cmd-go-make-content-based-hash-generation-less-pedan.patch \
- file://0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch \
- file://0004-ld-add-soname-to-shareable-objects.patch \
- file://0005-make.bash-override-CC-when-building-dist-and-go_boot.patch \
- file://0006-cmd-dist-separate-host-and-target-builds.patch \
- file://0007-cmd-go-make-GOROOT-precious-by-default.patch \
- file://0001-exec.go-do-not-write-linker-flags-into-buildids.patch \
- file://0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \
- file://filter-build-paths.patch \
- file://stack-protector.patch \
-"
-SRC_URI[main.sha256sum] = "9419cc70dc5a2523f29a77053cafff658ed21ef3561d9b6b020280ebceab28b9"
diff --git a/meta/recipes-devtools/go/go-1.22.2.inc b/meta/recipes-devtools/go/go-1.22.2.inc
new file mode 100644
index 0000000000..b399207311
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.22.2.inc
@@ -0,0 +1,18 @@
+require go-common.inc
+
+FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go:"
+
+LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707"
+
+SRC_URI += "\
+ file://0001-cmd-go-make-content-based-hash-generation-less-pedan.patch \
+ file://0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch \
+ file://0003-ld-add-soname-to-shareable-objects.patch \
+ file://0004-make.bash-override-CC-when-building-dist-and-go_boot.patch \
+ file://0005-cmd-dist-separate-host-and-target-builds.patch \
+ file://0006-cmd-go-make-GOROOT-precious-by-default.patch \
+ file://0007-exec.go-filter-out-build-specific-paths-from-linker-.patch \
+ file://0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \
+ file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \
+"
+SRC_URI[main.sha256sum] = "374ea82b289ec738e968267cac59c7d5ff180f9492250254784b2044e90df5a9"
diff --git a/meta/recipes-devtools/go/go-binary-native_1.19.bb b/meta/recipes-devtools/go/go-binary-native_1.22.2.bb
index ca424a66b8..0f00509f03 100644
--- a/meta/recipes-devtools/go/go-binary-native_1.19.bb
+++ b/meta/recipes-devtools/go/go-binary-native_1.22.2.bb
@@ -7,13 +7,17 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707"
PROVIDES = "go-native"
+# Checksums available at https://go.dev/dl/
SRC_URI = "https://dl.google.com/go/go${PV}.${BUILD_GOOS}-${BUILD_GOARCH}.tar.gz;name=go_${BUILD_GOTUPLE}"
-SRC_URI[go_linux_amd64.sha256sum] = "464b6b66591f6cf055bc5df90a9750bf5fbc9d038722bb84a9d56a2bea974be6"
-SRC_URI[go_linux_arm64.sha256sum] = "efa97fac9574fc6ef6c9ff3e3758fb85f1439b046573bf434cccb5e012bd00c8"
+SRC_URI[go_linux_amd64.sha256sum] = "5901c52b7a78002aeff14a21f93e0f064f74ce1360fce51c6ee68cd471216a17"
+SRC_URI[go_linux_arm64.sha256sum] = "36e720b2d564980c162a48c7e97da2e407dfcc4239e1e58d98082dfa2486a0c1"
+SRC_URI[go_linux_ppc64le.sha256sum] = "251a8886c5113be6490bdbb955ddee98763b49c9b1bf4c8364c02d3b482dab00"
UPSTREAM_CHECK_URI = "https://golang.org/dl/"
UPSTREAM_CHECK_REGEX = "go(?P<pver>\d+(\.\d+)+)\.linux"
+CVE_PRODUCT = "golang:go"
+
S = "${WORKDIR}/go"
inherit goarch native
diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc
index 83f8db7b39..db165792dc 100644
--- a/meta/recipes-devtools/go/go-common.inc
+++ b/meta/recipes-devtools/go/go-common.inc
@@ -19,6 +19,9 @@ S = "${WORKDIR}/go"
B = "${S}"
UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)\.src\.tar"
+# all recipe variants are created from the same product
+CVE_PRODUCT = "golang:go"
+
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
SSTATE_SCAN_CMD = "true"
diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc
index c1aa987427..dd485b6799 100644
--- a/meta/recipes-devtools/go/go-cross-canadian.inc
+++ b/meta/recipes-devtools/go/go-cross-canadian.inc
@@ -1,14 +1,14 @@
inherit cross-canadian
-DEPENDS = "go-native virtual/${HOST_PREFIX}go-crosssdk virtual/nativesdk-${HOST_PREFIX}go-runtime \
- virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-libc \
+DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go-runtime \
+ virtual/${HOST_PREFIX}gcc virtual/nativesdk-libc \
virtual/nativesdk-${HOST_PREFIX}compilerlibs"
PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
# it uses gcc on build machine during go-cross-canadian bootstrap, but
# the gcc version may be old and not support option '-fmacro-prefix-map'
# which is one of default values of DEBUG_PREFIX_MAP
-DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR} \
-fdebug-prefix-map=${STAGING_DIR_HOST}= \
-fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
"
@@ -16,15 +16,15 @@ DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDP
export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}"
export CGO_CFLAGS = "${CFLAGS}"
export CGO_LDFLAGS = "${LDFLAGS}"
-export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"'
+export GO_LDFLAGS = '-extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"'
do_configure[noexec] = "1"
do_compile() {
- export CC_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}"
- export CXX_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}"
+ export CC_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS}"
+ export CXX_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS}"
cd src
- ./make.bash --host-only --no-banner
+ ./make.bash --target-only --no-banner
cd ${B}
}
do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.19.bb b/meta/recipes-devtools/go/go-cross-canadian_1.22.2.bb
index 7ac9449e47..7ac9449e47 100644
--- a/meta/recipes-devtools/go/go-cross-canadian_1.19.bb
+++ b/meta/recipes-devtools/go/go-cross-canadian_1.22.2.bb
diff --git a/meta/recipes-devtools/go/go-cross_1.19.bb b/meta/recipes-devtools/go/go-cross_1.22.2.bb
index 80b5a03f6c..80b5a03f6c 100644
--- a/meta/recipes-devtools/go/go-cross_1.19.bb
+++ b/meta/recipes-devtools/go/go-cross_1.22.2.bb
diff --git a/meta/recipes-devtools/go/go-crosssdk.inc b/meta/recipes-devtools/go/go-crosssdk.inc
index cd23cca2fe..12939005c0 100644
--- a/meta/recipes-devtools/go/go-crosssdk.inc
+++ b/meta/recipes-devtools/go/go-crosssdk.inc
@@ -1,8 +1,10 @@
inherit crosssdk
-DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils-crosssdk"
+DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils"
PN = "go-crosssdk-${SDK_SYS}"
-PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk"
+PROVIDES = "virtual/${TARGET_PREFIX}go"
+
+export GOCACHE = "${B}/.cache"
do_configure[noexec] = "1"
diff --git a/meta/recipes-devtools/go/go-crosssdk_1.19.bb b/meta/recipes-devtools/go/go-crosssdk_1.22.2.bb
index 1857c8a577..1857c8a577 100644
--- a/meta/recipes-devtools/go/go-crosssdk_1.19.bb
+++ b/meta/recipes-devtools/go/go-crosssdk_1.22.2.bb
diff --git a/meta/recipes-devtools/go/go-native_1.19.bb b/meta/recipes-devtools/go/go-native_1.22.2.bb
index 76c0ab73a6..ddf25b2c9b 100644
--- a/meta/recipes-devtools/go/go-native_1.19.bb
+++ b/meta/recipes-devtools/go/go-native_1.22.2.bb
@@ -5,7 +5,7 @@ require go-${PV}.inc
inherit native
-SRC_URI:append = " https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz;name=bootstrap;subdir=go1.4"
+SRC_URI += "https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz;name=bootstrap;subdir=go1.4"
SRC_URI[bootstrap.sha256sum] = "f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52"
export GOOS = "${BUILD_GOOS}"
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index e18339cddb..413cf6d33f 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -1,5 +1,5 @@
DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
-DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk"
+DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go"
PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
DEBUG_PREFIX_MAP = "\
@@ -15,7 +15,7 @@ export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-pr
export GOCACHE = "${B}/.cache"
GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
-GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
+GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
do_configure() {
:
@@ -50,6 +50,8 @@ do_install() {
rm -rf ${D}${libdir}/go/pkg/tool
rm -rf ${D}${libdir}/go/pkg/obj
rm -rf ${D}${libdir}/go/pkg/bootstrap
+ # the cmd directory is built for the native arch so if BUILD == TARGET
+ rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}/cmd
find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
done
diff --git a/meta/recipes-devtools/go/go-runtime_1.19.bb b/meta/recipes-devtools/go/go-runtime_1.22.2.bb
index 63464a1501..63464a1501 100644
--- a/meta/recipes-devtools/go/go-runtime_1.19.bb
+++ b/meta/recipes-devtools/go/go-runtime_1.22.2.bb
diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc
index ed09cfe806..981c7abd31 100644
--- a/meta/recipes-devtools/go/go-target.inc
+++ b/meta/recipes-devtools/go/go-target.inc
@@ -1,5 +1,5 @@
DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
-DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
+DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go go-native"
DEBUG_PREFIX_MAP = "\
-fdebug-prefix-map=${STAGING_DIR_HOST}= \
@@ -13,9 +13,7 @@ export CGO_CXXFLAGS = "${CXXFLAGS}"
export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
export GOCACHE = "${B}/.cache"
-GO_LDFLAGS = ""
-GO_LDFLAGS:class-nativesdk = " -linkmode external"
-export GO_LDFLAGS
+export GO_LDFLAGS = ""
export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath"
CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}"
diff --git a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch b/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
index 8cbed93017..564837c7cd 100644
--- a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
+++ b/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
@@ -1,7 +1,7 @@
-From a3db4da51df37d163ff9e8c1e1057280c648c545 Mon Sep 17 00:00:00 2001
+From 9a6c5040cbcd88b10ceb8ceaebc8d6158c086670 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 28 Mar 2022 10:59:03 -0700
-Subject: [PATCH] cmd/go: make content-based hash generation less pedantic
+Subject: [PATCH 1/9] cmd/go: make content-based hash generation less pedantic
Go 1.10's build tool now uses content-based hashes to
determine when something should be built or re-built.
@@ -25,30 +25,30 @@ Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Alex Kube <alexander.j.kube@gmail.com>
Signed-off-by: Matt Madison <matt@madison.systems>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/go/internal/envcmd/env.go | 2 +-
- src/cmd/go/internal/work/exec.go | 42 ++++++++++++++++++++++++-------
- 2 files changed, 34 insertions(+), 10 deletions(-)
+ src/cmd/go/internal/work/exec.go | 44 ++++++++++++++++++++++++-------
+ 2 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go
-index 529351d..df791b0 100644
+index c7c2e83e0f..4a90d9da5c 100644
--- a/src/cmd/go/internal/envcmd/env.go
+++ b/src/cmd/go/internal/envcmd/env.go
-@@ -176,7 +176,7 @@ func ExtraEnvVars() []cfg.EnvVar {
- func ExtraEnvVarsCostly() []cfg.EnvVar {
- var b work.Builder
- b.Init()
+@@ -189,7 +189,7 @@ func ExtraEnvVarsCostly() []cfg.EnvVar {
+ }
+ }()
+
- cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{})
+ cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}, false)
if err != nil {
// Should not happen - b.CFlags was given an empty package.
fmt.Fprintf(os.Stderr, "go: invalid cflags: %v\n", err)
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
-index c88b315..a06455c 100644
+index e05471b06c..9724cd07d0 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
-@@ -213,6 +213,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
+@@ -232,6 +232,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
writeActionGraph()
}
@@ -57,7 +57,7 @@ index c88b315..a06455c 100644
// buildActionID computes the action ID for a build action.
func (b *Builder) buildActionID(a *Action) cache.ActionID {
p := a.Package
-@@ -234,7 +236,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
+@@ -253,7 +255,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
if p.Module != nil {
fmt.Fprintf(h, "module %s@%s\n", p.Module.Path, p.Module.Version)
}
@@ -66,7 +66,7 @@ index c88b315..a06455c 100644
// The Go compiler always hides the exact value of $GOROOT
// when building things in GOROOT.
//
-@@ -266,9 +268,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
+@@ -285,9 +287,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
}
if len(p.CgoFiles)+len(p.SwigFiles)+len(p.SwigCXXFiles) > 0 {
fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo"))
@@ -74,50 +74,52 @@ index c88b315..a06455c 100644
+ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
- ccExe := b.ccExe()
-+ ccExe := filterCompilerFlags(b.ccExe())
++ ccExe := filterCompilerFlags(b.ccExe(), true)
fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
// Include the C compiler tool ID so that if the C
// compiler changes we rebuild the package.
-@@ -281,14 +283,14 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
- }
+@@ -295,14 +297,14 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
+ fmt.Fprintf(h, "CC ID=%q\n", ccID)
}
if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
- cxxExe := b.cxxExe()
-+ cxxExe := filterCompilerFlags(b.cxxExe())
++ cxxExe := filterCompilerFlags(b.cxxExe(), true)
fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
- if cxxID, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
+ if cxxID, _, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
}
}
if len(p.FFiles) > 0 {
- fcExe := b.fcExe()
-+ fcExe := filterCompilerFlags(b.fcExe())
++ fcExe := filterCompilerFlags(b.fcExe(), true)
fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
- if fcID, err := b.gccToolID(fcExe[0], "f95"); err == nil {
+ if fcID, _, err := b.gccToolID(fcExe[0], "f95"); err == nil {
fmt.Fprintf(h, "FC ID=%q\n", fcID)
-@@ -305,7 +307,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
+@@ -319,7 +321,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
}
}
- if p.Internal.BuildInfo != "" {
-- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo)
-+ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo)
+ if p.Internal.BuildInfo != nil {
+- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
++ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
}
// Configuration specific to compiler toolchain.
-@@ -2705,8 +2707,23 @@ func envList(key, def string) []string {
+@@ -2679,8 +2681,25 @@ func envList(key, def string) []string {
return args
}
+var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
+
-+func filterCompilerFlags(flags []string) []string {
++func filterCompilerFlags(flags []string, keepfirst bool) []string {
+ var newflags []string
++ var realkeepfirst bool = keepfirst
+ if !filterFlags {
+ return flags
+ }
+ for _, flag := range flags {
-+ if strings.HasPrefix(flag, "-m") {
++ if strings.HasPrefix(flag, "-m") || realkeepfirst {
+ newflags = append(newflags, flag)
++ realkeepfirst = false
+ }
+ }
+ return newflags
@@ -126,38 +128,41 @@ index c88b315..a06455c 100644
// CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo.
-func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
+func (b *Builder) CFlags(p *load.Package, filtered bool) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
- defaults := "-g -O2"
-
if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
-@@ -2724,6 +2741,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
- if ldflags, err = buildFlags("LDFLAGS", defaults, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
+ return
+ }
+@@ -2696,6 +2715,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
+ if ldflags, err = buildFlags("LDFLAGS", defaultCFlags, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
return
}
+ if filtered {
-+ cppflags = filterCompilerFlags(cppflags)
-+ cflags = filterCompilerFlags(cflags)
-+ cxxflags = filterCompilerFlags(cxxflags)
-+ fflags = filterCompilerFlags(fflags)
-+ ldflags = filterCompilerFlags(ldflags)
++ cppflags = filterCompilerFlags(cppflags, false)
++ cflags = filterCompilerFlags(cflags, false)
++ cxxflags = filterCompilerFlags(cxxflags, false)
++ fflags = filterCompilerFlags(fflags, false)
++ ldflags = filterCompilerFlags(ldflags, false)
+ }
return
}
-@@ -2739,7 +2763,7 @@ var cgoRe = lazyregexp.New(`[/\\:]`)
-
- func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
+@@ -2713,7 +2739,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
p := a.Package
+ sh := b.Shell(a)
+
- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p)
+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p, false)
if err != nil {
return nil, nil, err
}
-@@ -3246,7 +3270,7 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
+@@ -3268,7 +3294,7 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
+ p := a.Package
+ sh := b.Shell(a)
- // Run SWIG on one SWIG input file.
- func (b *Builder) swigOne(a *Action, p *load.Package, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p)
+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p, false)
if err != nil {
return "", "", err
}
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/0001-exec.go-do-not-write-linker-flags-into-buildids.patch b/meta/recipes-devtools/go/go/0001-exec.go-do-not-write-linker-flags-into-buildids.patch
deleted file mode 100644
index f117152f2a..0000000000
--- a/meta/recipes-devtools/go/go/0001-exec.go-do-not-write-linker-flags-into-buildids.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From bdd69b55387f80c8df18d0af5008bf5e1a66be6a Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Mon, 23 Nov 2020 19:22:04 +0000
-Subject: [PATCH] exec.go: do not write linker flags into buildids
-
-The flags can contain build-specific paths, breaking reproducibility.
-
-To make this acceptable to upstream, we probably need to trim the flags,
-removing those known to be buildhost-specific.
-
-Upstream-Status: Inappropriate [needs upstream discussion]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- src/cmd/go/internal/work/exec.go | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/cmd/go/internal/work/exec.go
-+++ b/src/cmd/go/internal/work/exec.go
-@@ -1274,7 +1274,7 @@ func (b *Builder) linkActionID(a *Action
- }
-
- // Toolchain-dependent configuration, shared with b.linkSharedActionID.
-- b.printLinkerConfig(h, p)
-+ //b.printLinkerConfig(h, p)
-
- // Input files.
- for _, a1 := range a.Deps {
-@@ -1568,7 +1568,7 @@ func (b *Builder) linkSharedActionID(a *
- fmt.Fprintf(h, "goos %s goarch %s\n", cfg.Goos, cfg.Goarch)
-
- // Toolchain-dependent configuration, shared with b.linkActionID.
-- b.printLinkerConfig(h, nil)
-+ //b.printLinkerConfig(h, nil)
-
- // Input files.
- for _, a1 := range a.Deps {
diff --git a/meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch b/meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch
index 30068d8e74..001c94a4e7 100644
--- a/meta/recipes-devtools/go/go/0003-allow-GOTOOLDIR-to-be-overridden-in-the-environment.patch
+++ b/meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch
@@ -1,7 +1,8 @@
-From 7e0136a882757da0a374ab8592209586eced0e1c Mon Sep 17 00:00:00 2001
+From e3f9a8a69d3a340c1a1d0bba566e71f20f635a43 Mon Sep 17 00:00:00 2001
From: Alex Kube <alexander.j.kube@gmail.com>
Date: Wed, 23 Oct 2019 21:15:37 +0430
-Subject: [PATCH] cmd/go: Allow GOTOOLDIR to be overridden in the environment
+Subject: [PATCH 2/9] cmd/go: Allow GOTOOLDIR to be overridden in the
+ environment
to allow for split host/target build roots
@@ -12,17 +13,17 @@ Matt Madison <matt@madison.systems>.
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
-
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/dist/build.go | 4 +++-
src/cmd/go/internal/cfg/cfg.go | 6 +++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
-index 7c44c4a..3024d0c 100644
+index 32e59b446a..06ee4de8a9 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
-@@ -264,7 +264,9 @@ func xinit() {
+@@ -259,7 +259,9 @@ func xinit() {
}
xatexit(rmworkdir)
@@ -30,23 +31,26 @@ index 7c44c4a..3024d0c 100644
+ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
+ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
+ }
- }
- // compilerEnv returns a map from "goos/goarch" to the
+ goversion := findgoversion()
+ isRelease = strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go")
diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
-index c6ddfe5..605adb1 100644
+index a8daa2dfc3..393ada39c9 100644
--- a/src/cmd/go/internal/cfg/cfg.go
+++ b/src/cmd/go/internal/cfg/cfg.go
-@@ -162,7 +162,11 @@ func SetGOROOT(goroot string) {
- // variables. This matches the initialization of ToolDir in
- // go/build, except for using BuildContext.GOROOT rather than
- // runtime.GOROOT.
-- build.ToolDir = filepath.Join(goroot, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
-+ if s := os.Getenv("GOTOOLDIR"); s != "" {
-+ build.ToolDir = filepath.Clean(s)
-+ } else {
-+ build.ToolDir = filepath.Join(goroot, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
-+ }
+@@ -230,7 +230,11 @@ func SetGOROOT(goroot string, isTestGo bool) {
+ // This matches the initialization of ToolDir in go/build, except for
+ // using ctxt.GOROOT and the installed GOOS and GOARCH rather than the
+ // GOROOT, GOOS, and GOARCH reported by the runtime package.
+- build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH)
++ if s := os.Getenv("GOTOOLDIR"); s != "" {
++ build.ToolDir = filepath.Clean(s)
++ } else {
++ build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH)
++ }
+ }
}
}
-
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch
index b700634910..9cab2969c8 100644
--- a/meta/recipes-devtools/go/go/0004-ld-add-soname-to-shareable-objects.patch
+++ b/meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch
@@ -1,7 +1,7 @@
-From 68867eae5d3a51f32b2a2e16374323338408781e Mon Sep 17 00:00:00 2001
+From 7dde77b3ce8138314dd2736604b1b110dbcc0ac1 Mon Sep 17 00:00:00 2001
From: Alex Kube <alexander.j.kube@gmail.com>
Date: Wed, 23 Oct 2019 21:16:32 +0430
-Subject: [PATCH] ld: add soname to shareable objects
+Subject: [PATCH 3/9] ld: add soname to shareable objects
so that OE's shared library dependency handling
can find them.
@@ -13,16 +13,16 @@ Matt Madison <matt@madison.systems>.
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
-
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/link/internal/ld/lib.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
-index 18910dd..b2e1d36 100644
+index eab74dc328..ae9bbc9093 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
-@@ -1459,6 +1459,7 @@ func (ctxt *Link) hostlink() {
+@@ -1576,6 +1576,7 @@ func (ctxt *Link) hostlink() {
argv = append(argv, "-Wl,-z,relro")
}
argv = append(argv, "-shared")
@@ -30,7 +30,7 @@ index 18910dd..b2e1d36 100644
if ctxt.HeadType == objabi.Hwindows {
argv = addASLRargs(argv, *flagAslr)
} else {
-@@ -1474,6 +1475,7 @@ func (ctxt *Link) hostlink() {
+@@ -1591,6 +1592,7 @@ func (ctxt *Link) hostlink() {
argv = append(argv, "-Wl,-z,relro")
}
argv = append(argv, "-shared")
@@ -38,7 +38,7 @@ index 18910dd..b2e1d36 100644
case BuildModePlugin:
if ctxt.HeadType == objabi.Hdarwin {
argv = append(argv, "-dynamiclib")
-@@ -1482,6 +1484,7 @@ func (ctxt *Link) hostlink() {
+@@ -1599,6 +1601,7 @@ func (ctxt *Link) hostlink() {
argv = append(argv, "-Wl,-z,relro")
}
argv = append(argv, "-shared")
@@ -46,3 +46,6 @@ index 18910dd..b2e1d36 100644
}
}
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch b/meta/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch
index 608f1eb5a0..8889aef1cf 100644
--- a/meta/recipes-devtools/go/go/0005-make.bash-override-CC-when-building-dist-and-go_boot.patch
+++ b/meta/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch
@@ -1,7 +1,8 @@
-From 8f020921c464e95ded850950382115154448580a Mon Sep 17 00:00:00 2001
+From 9f59e46991074d3e3c4d00f3971e62bfcd707167 Mon Sep 17 00:00:00 2001
From: Alex Kube <alexander.j.kube@gmail.com>
Date: Wed, 23 Oct 2019 21:17:16 +0430
-Subject: [PATCH] make.bash: override CC when building dist and go_bootstrap
+Subject: [PATCH 4/9] make.bash: override CC when building dist and
+ go_bootstrap
for handling OE cross-canadian builds.
@@ -12,30 +13,33 @@ Matt Madison <matt@madison.systems>.
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
-
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/make.bash | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/make.bash b/src/make.bash
-index ab2ce19..37ec1fb 100755
+index 76ad51624a..074e129a24 100755
--- a/src/make.bash
+++ b/src/make.bash
-@@ -198,7 +198,7 @@ if [ "$GOROOT_BOOTSTRAP" = "$GOROOT" ]; then
+@@ -198,7 +198,7 @@ if [[ "$GOROOT_BOOTSTRAP" == "$GOROOT" ]]; then
exit 1
fi
rm -f cmd/dist/dist
--GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off GOEXPERIMENT="" GOENV=off GOFLAGS="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
-+CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" GO111MODULE=off GOEXPERIMENT="" GOENV=off GOFLAGS="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
+-GOROOT="$GOROOT_BOOTSTRAP" nogoenv "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
++CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" nogoenv "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist
# -e doesn't propagate out of eval, so check success by hand.
eval $(./cmd/dist/dist env -p || echo FAIL=true)
@@ -223,7 +223,7 @@ fi
# Run dist bootstrap to complete make.bash.
# Bootstrap installs a proper cmd/dist, built with the new toolchain.
- # Throw ours, built with Go 1.4, away after bootstrap.
+ # Throw ours, built with the bootstrap toolchain, away after bootstrap.
-./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@"
+CC="${BUILD_CC:-${CC}}" ./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@"
rm -f ./cmd/dist/dist
# DO NOT ADD ANY NEW CODE HERE.
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
new file mode 100644
index 0000000000..364fce907a
--- /dev/null
+++ b/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
@@ -0,0 +1,221 @@
+From 6dda78d528e60993a4688cd9d49440a726378ac8 Mon Sep 17 00:00:00 2001
+From: Alex Kube <alexander.j.kube@gmail.com>
+Date: Wed, 23 Oct 2019 21:18:12 +0430
+Subject: [PATCH 5/9] cmd/dist: separate host and target builds
+
+Change the dist tool to allow for OE-style cross-
+and cross-canadian builds:
+
+ - command flags --host-only and --target only are added;
+ if one is present, the other changes mentioned below
+ take effect, and arguments may also be specified on
+ the command line to enumerate the package(s) to be
+ built.
+
+ - for OE cross builds, go_bootstrap is always built for
+ the current build host, and is moved, along with the supporting
+ toolchain (asm, compile, etc.) to a separate 'native_native'
+ directory under GOROOT/pkg/tool.
+
+ - go_bootstrap is not automatically removed after the build,
+ so it can be reused later (e.g., building both static and
+ shared runtime).
+
+Note that for --host-only builds, it would be nice to specify
+just the "cmd" package to build only the go commands/tools,
+the staleness checks in the dist tool will fail if the "std"
+library has not also been built. So host-only builds have to
+build everything anyway.
+
+Adapted to Go 1.13 from patches originally submitted to
+the meta/recipes-devtools/go tree by
+Matt Madison <matt@madison.systems>.
+
+Rework the patch to avoid identation, it breaks formatting rules but
+makes the changes more obvious and maintainable.
+Jose Quaresma <jose.quaresma@foundries.io>
+Richard Purdie <richard.purdie@linuxfoundation.org>
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
+---
+ src/cmd/dist/build.go | 76 ++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 75 insertions(+), 1 deletion(-)
+
+diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
+index 06ee4de8a9..74b7c7098f 100644
+--- a/src/cmd/dist/build.go
++++ b/src/cmd/dist/build.go
+@@ -46,6 +46,7 @@ var (
+ goexperiment string
+ workdir string
+ tooldir string
++ build_tooldir string
+ oldgoos string
+ oldgoarch string
+ oldgocache string
+@@ -58,6 +59,7 @@ var (
+ rebuildall bool
+ noOpt bool
+ isRelease bool
++ crossBuild bool
+
+ vflag int // verbosity
+ )
+@@ -265,6 +267,8 @@ func xinit() {
+
+ goversion := findgoversion()
+ isRelease = strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go")
++
++ build_tooldir = pathf("%s/pkg/tool/native_native", goroot)
+ }
+
+ // compilerEnv returns a map from "goos/goarch" to the
+@@ -499,8 +503,10 @@ func setup() {
+ goosGoarch := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch)
+ if rebuildall {
+ xremoveall(goosGoarch)
++ xremoveall(build_tooldir)
+ }
+ xmkdirall(goosGoarch)
++ xmkdirall(build_tooldir)
+ xatexit(func() {
+ if files := xreaddir(goosGoarch); len(files) == 0 {
+ xremove(goosGoarch)
+@@ -1338,14 +1344,20 @@ func cmdbootstrap() {
+ defer timelog("end", "dist bootstrap")
+
+ var debug, distpack, force, noBanner, noClean bool
++ var hostOnly bool
++ var targetOnly bool
++ var toBuild = []string{"std", "cmd"}
++
+ flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all")
+ flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process")
+ flag.BoolVar(&distpack, "distpack", distpack, "write distribution files to pkg/distpack")
+ flag.BoolVar(&force, "force", force, "build even if the port is marked as broken")
+ flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner")
+ flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning")
++ flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target")
++ flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host")
+
+- xflagparse(0)
++ xflagparse(-1)
+
+ if noClean {
+ xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n")
+@@ -1357,6 +1369,18 @@ func cmdbootstrap() {
+ "Use the -force flag to build anyway.\n", goos, goarch)
+ }
+
++ if hostOnly && targetOnly {
++ fatalf("specify only one of --host-only or --target-only\n")
++ }
++ crossBuild = hostOnly || targetOnly
++ if flag.NArg() > 0 {
++ if crossBuild {
++ toBuild = flag.Args()
++ } else {
++ fatalf("package names not permitted without --host-only or --target-only\n")
++ }
++ }
++
+ // Set GOPATH to an internal directory. We shouldn't actually
+ // need to store files here, since the toolchain won't
+ // depend on modules outside of vendor directories, but if
+@@ -1434,9 +1458,14 @@ func cmdbootstrap() {
+ xprintf("\n")
+ }
+
++ // For split host/target cross/cross-canadian builds, we don't
++ // want to be setting these flags until after we have compiled
++ // the toolchain that runs on the build host.
++if !crossBuild {
+ gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
+ setNoOpt()
+ goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now
++}
+ goBootstrap := pathf("%s/go_bootstrap", tooldir)
+ if debug {
+ run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
+@@ -1464,7 +1493,11 @@ func cmdbootstrap() {
+ xprintf("\n")
+ }
+ xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n")
++if !crossBuild {
+ os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch))
++} else {
++ os.Setenv("CC", defaultcc[""])
++}
+ // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT.
+ os.Setenv("GOEXPERIMENT", goexperiment)
+ // No need to enable PGO for toolchain2.
+@@ -1517,6 +1550,7 @@ func cmdbootstrap() {
+ os.Setenv("GOCACHE", oldgocache)
+ }
+
++if !crossBuild {
+ if goos == oldgoos && goarch == oldgoarch {
+ // Common case - not setting up for cross-compilation.
+ timelog("build", "toolchain")
+@@ -1560,6 +1594,42 @@ func cmdbootstrap() {
+ checkNotStale(toolenv(), goBootstrap, toolchain...)
+ copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
+ }
++} else {
++ gogcflags = os.Getenv("GO_GCFLAGS")
++ goldflags = os.Getenv("GO_LDFLAGS")
++ tool_files, _ := filepath.Glob(pathf("%s/*", tooldir))
++ for _, f := range tool_files {
++ copyfile(pathf("%s/%s", build_tooldir, filepath.Base(f)), f, writeExec)
++ xremove(f)
++ }
++ os.Setenv("GOTOOLDIR", build_tooldir)
++ goBootstrap = pathf("%s/go_bootstrap", build_tooldir)
++ if hostOnly {
++ timelog("build", "host toolchain")
++ if vflag > 0 {
++ xprintf("\n")
++ }
++ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
++ goInstall(toolenv(), goBootstrap, toBuild...)
++ checkNotStale(toolenv(), goBootstrap, toBuild...)
++ // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary
++
++ timelog("build", "target toolchain")
++ if vflag > 0 {
++ xprintf("\n")
++ }
++ } else if targetOnly {
++ goos = oldgoos
++ goarch = oldgoarch
++ os.Setenv("GOOS", goos)
++ os.Setenv("GOARCH", goarch)
++ os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch))
++ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
++ goInstall(toolenv(), goBootstrap, toBuild...)
++ checkNotStale(toolenv(), goBootstrap, toBuild...)
++ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary
++ }
++}
+
+ // Check that there are no new files in $GOROOT/bin other than
+ // go and gofmt and $GOOS_$GOARCH (target bin when cross-compiling).
+@@ -1582,8 +1652,12 @@ func cmdbootstrap() {
+ }
+ }
+
++ // Except that for split host/target cross-builds, we need to
++ // keep it.
++if !crossBuild {
+ // Remove go_bootstrap now that we're done.
+ xremove(pathf("%s/go_bootstrap"+exe, tooldir))
++}
+
+ if goos == "android" {
+ // Make sure the exec wrapper will sync a fresh $GOROOT to the device.
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch b/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch
deleted file mode 100644
index 2c864baa0e..0000000000
--- a/meta/recipes-devtools/go/go/0006-cmd-dist-separate-host-and-target-builds.patch
+++ /dev/null
@@ -1,282 +0,0 @@
-From ef5fddafdec78cab9963d21736e64d71ca520bcc Mon Sep 17 00:00:00 2001
-From: Alex Kube <alexander.j.kube@gmail.com>
-Date: Wed, 23 Oct 2019 21:18:12 +0430
-Subject: [PATCH] cmd/dist: separate host and target builds
-
-Upstream-Status: Inappropriate [OE specific]
-
-Change the dist tool to allow for OE-style cross-
-and cross-canadian builds:
-
- - command flags --host-only and --target only are added;
- if one is present, the other changes mentioned below
- take effect, and arguments may also be specified on
- the command line to enumerate the package(s) to be
- built.
-
- - for OE cross builds, go_bootstrap is always built for
- the current build host, and is moved, along with the supporting
- toolchain (asm, compile, etc.) to a separate 'native_native'
- directory under GOROOT/pkg/tool.
-
- - go_bootstrap is not automatically removed after the build,
- so it can be reused later (e.g., building both static and
- shared runtime).
-
-Note that for --host-only builds, it would be nice to specify
-just the "cmd" package to build only the go commands/tools,
-the staleness checks in the dist tool will fail if the "std"
-library has not also been built. So host-only builds have to
-build everything anyway.
-
-Adapted to Go 1.13 from patches originally submitted to
-the meta/recipes-devtools/go tree by
-Matt Madison <matt@madison.systems>.
-
-Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
-
----
- src/cmd/dist/build.go | 154 ++++++++++++++++++++++++++++++------------
- 1 file changed, 112 insertions(+), 42 deletions(-)
-
-diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
-index 3024d0c..45ebee0 100644
---- a/src/cmd/dist/build.go
-+++ b/src/cmd/dist/build.go
-@@ -45,6 +45,7 @@ var (
- goexperiment string
- workdir string
- tooldir string
-+ build_tooldir string
- oldgoos string
- oldgoarch string
- exe string
-@@ -55,6 +56,7 @@ var (
-
- rebuildall bool
- defaultclang bool
-+ crossBuild bool
-
- vflag int // verbosity
- )
-@@ -267,6 +269,8 @@ func xinit() {
- if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
- }
-+
-+ build_tooldir = pathf("%s/pkg/tool/native_native", goroot)
- }
-
- // compilerEnv returns a map from "goos/goarch" to the
-@@ -468,8 +472,10 @@ func setup() {
- p := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch)
- if rebuildall {
- xremoveall(p)
-+ xremoveall(build_tooldir)
- }
- xmkdirall(p)
-+ xmkdirall(build_tooldir)
-
- if goos != gohostos || goarch != gohostarch {
- p := pathf("%s/pkg/%s_%s", goroot, goos, goarch)
-@@ -1248,17 +1254,35 @@ func cmdbootstrap() {
-
- var noBanner, noClean bool
- var debug bool
-+ var hostOnly bool
-+ var targetOnly bool
-+ var toBuild = []string{"std", "cmd"}
-+
- flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all")
- flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process")
- flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner")
- flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning")
-+ flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target")
-+ flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host")
-
-- xflagparse(0)
-+ xflagparse(-1)
-
- if noClean {
- xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n")
- }
-
-+ if hostOnly && targetOnly {
-+ fatalf("specify only one of --host-only or --target-only\n")
-+ }
-+ crossBuild = hostOnly || targetOnly
-+ if flag.NArg() > 0 {
-+ if crossBuild {
-+ toBuild = flag.Args()
-+ } else {
-+ fatalf("package names not permitted without --host-only or --target-only\n")
-+ }
-+ }
-+
- // Set GOPATH to an internal directory. We shouldn't actually
- // need to store files here, since the toolchain won't
- // depend on modules outside of vendor directories, but if
-@@ -1326,8 +1350,13 @@ func cmdbootstrap() {
- xprintf("\n")
- }
-
-- gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
-- goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now
-+ // For split host/target cross/cross-canadian builds, we don't
-+ // want to be setting these flags until after we have compiled
-+ // the toolchain that runs on the build host.
-+ if !crossBuild {
-+ gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
-+ goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now
-+ }
- goBootstrap := pathf("%s/go_bootstrap", tooldir)
- cmdGo := pathf("%s/go", gorootBin)
- if debug {
-@@ -1356,7 +1385,11 @@ func cmdbootstrap() {
- xprintf("\n")
- }
- xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n")
-- os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
-+ if crossBuild {
-+ os.Setenv("CC", defaultcc[""])
-+ } else {
-+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
-+ }
- // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT.
- os.Setenv("GOEXPERIMENT", goexperiment)
- goInstall(goBootstrap, append([]string{"-i"}, toolchain...)...)
-@@ -1395,50 +1428,84 @@ func cmdbootstrap() {
- }
- checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...)
-
-- if goos == oldgoos && goarch == oldgoarch {
-- // Common case - not setting up for cross-compilation.
-- timelog("build", "toolchain")
-- if vflag > 0 {
-- xprintf("\n")
-+ if crossBuild {
-+ gogcflags = os.Getenv("GO_GCFLAGS")
-+ goldflags = os.Getenv("GO_LDFLAGS")
-+ tool_files, _ := filepath.Glob(pathf("%s/*", tooldir))
-+ for _, f := range tool_files {
-+ copyfile(pathf("%s/%s", build_tooldir, filepath.Base(f)), f, writeExec)
-+ xremove(f)
-+ }
-+ os.Setenv("GOTOOLDIR", build_tooldir)
-+ goBootstrap = pathf("%s/go_bootstrap", build_tooldir)
-+ if hostOnly {
-+ timelog("build", "host toolchain")
-+ if vflag > 0 {
-+ xprintf("\n")
-+ }
-+ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
-+ goInstall(goBootstrap, toBuild...)
-+ checkNotStale(goBootstrap, toBuild...)
-+ // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary
-+
-+ timelog("build", "target toolchain")
-+ if vflag > 0 {
-+ xprintf("\n")
-+ }
-+ } else if targetOnly {
-+ goos = oldgoos
-+ goarch = oldgoarch
-+ os.Setenv("GOOS", goos)
-+ os.Setenv("GOARCH", goarch)
-+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
-+ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
-+ goInstall(goBootstrap, toBuild...)
-+ checkNotStale(goBootstrap, toBuild...)
-+ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary
- }
-- xprintf("Building packages and commands for %s/%s.\n", goos, goarch)
- } else {
-- // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH.
-- // Finish GOHOSTOS/GOHOSTARCH installation and then
-- // run GOOS/GOARCH installation.
-- timelog("build", "host toolchain")
-- if vflag > 0 {
-- xprintf("\n")
-+
-+ if goos == oldgoos && goarch == oldgoarch {
-+ // Common case - not setting up for cross-compilation.
-+ timelog("build", "toolchain")
-+ if vflag > 0 {
-+ xprintf("\n")
-+ }
-+ xprintf("Building packages and commands for %s/%s.\n", goos, goarch)
-+ } else {
-+ // GOOS/GOARCH does not match GOHOSTOS/GOHOSTARCH.
-+ // Finish GOHOSTOS/GOHOSTARCH installation and then
-+ // run GOOS/GOARCH installation.
-+ timelog("build", "host toolchain")
-+ if vflag > 0 {
-+ xprintf("\n")
-+ }
-+ xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch)
-+ goInstall(goBootstrap, "std", "cmd")
-+ checkNotStale(goBootstrap, "std", "cmd")
-+ checkNotStale(cmdGo, "std", "cmd")
-+
-+ timelog("build", "target toolchain")
-+ if vflag > 0 {
-+ xprintf("\n")
-+ }
-+ goos = oldgoos
-+ goarch = oldgoarch
-+ os.Setenv("GOOS", goos)
-+ os.Setenv("GOARCH", goarch)
-+ os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
-+ xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch)
- }
-- xprintf("Building packages and commands for host, %s/%s.\n", goos, goarch)
- goInstall(goBootstrap, "std", "cmd")
- checkNotStale(goBootstrap, "std", "cmd")
- checkNotStale(cmdGo, "std", "cmd")
-
-- timelog("build", "target toolchain")
-- if vflag > 0 {
-- xprintf("\n")
-+ if debug {
-+ run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
-+ run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch))
-+ checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...)
-+ copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
- }
-- goos = oldgoos
-- goarch = oldgoarch
-- os.Setenv("GOOS", goos)
-- os.Setenv("GOARCH", goarch)
-- os.Setenv("CC", compilerEnvLookup(defaultcc, goos, goarch))
-- xprintf("Building packages and commands for target, %s/%s.\n", goos, goarch)
-- }
-- targets := []string{"std", "cmd"}
-- if goos == "js" && goarch == "wasm" {
-- // Skip the cmd tools for js/wasm. They're not usable.
-- targets = targets[:1]
-- }
-- goInstall(goBootstrap, targets...)
-- checkNotStale(goBootstrap, targets...)
-- checkNotStale(cmdGo, targets...)
-- if debug {
-- run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
-- run("", ShowOutput|CheckExit, pathf("%s/buildid", tooldir), pathf("%s/pkg/%s_%s/runtime/internal/sys.a", goroot, goos, goarch))
-- checkNotStale(goBootstrap, append(toolchain, "runtime/internal/sys")...)
-- copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
- }
-
- // Check that there are no new files in $GOROOT/bin other than
-@@ -1455,8 +1522,11 @@ func cmdbootstrap() {
- }
- }
-
-- // Remove go_bootstrap now that we're done.
-- xremove(pathf("%s/go_bootstrap", tooldir))
-+ // Except that for split host/target cross-builds, we need to
-+ // keep it.
-+ if !crossBuild {
-+ xremove(pathf("%s/go_bootstrap", tooldir))
-+ }
-
- if goos == "android" {
- // Make sure the exec wrapper will sync a fresh $GOROOT to the device.
diff --git a/meta/recipes-devtools/go/go/0007-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch
index 534d431045..262f1e96b8 100644
--- a/meta/recipes-devtools/go/go/0007-cmd-go-make-GOROOT-precious-by-default.patch
+++ b/meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch
@@ -1,9 +1,7 @@
-From 9ba507e076c744f4d394418e4a849e68cd426a4a Mon Sep 17 00:00:00 2001
+From aff5a740d6286c04beb0593fc68b0aea5a95ad39 Mon Sep 17 00:00:00 2001
From: Alex Kube <alexander.j.kube@gmail.com>
Date: Wed, 23 Oct 2019 21:18:56 +0430
-Subject: [PATCH 7/9] cmd/go: make GOROOT precious by default
-
-Upstream-Status: Inappropriate [OE specific]
+Subject: [PATCH 6/9] cmd/go: make GOROOT precious by default
The go build tool normally rebuilds whatever it detects is
stale. This can be a problem when GOROOT is intended to
@@ -20,16 +18,21 @@ Adapted to Go 1.13 from patches originally submitted to
the meta/recipes-devtools/go tree by
Matt Madison <matt@madison.systems>.
+Upstream-Status: Inappropriate [OE specific]
+
Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/go/internal/work/action.go | 3 +++
src/cmd/go/internal/work/build.go | 6 ++++++
src/cmd/go/internal/work/exec.go | 25 +++++++++++++++++++++++++
3 files changed, 34 insertions(+)
+diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
+index a59072e591..9e35ebde0c 100644
--- a/src/cmd/go/internal/work/action.go
+++ b/src/cmd/go/internal/work/action.go
-@@ -673,6 +673,9 @@ func (b *Builder) addTransitiveLinkDeps(
+@@ -754,6 +754,9 @@ func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) {
if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] {
continue
}
@@ -39,9 +42,11 @@ Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
haveShlib[filepath.Base(p1.Shlib)] = true
// TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild,
// we'll end up building an overall library or executable that depends at runtime
+diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
+index 408edb5119..3d60252127 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
-@@ -197,6 +197,8 @@ See also: go install, go get, go clean.
+@@ -233,6 +233,8 @@ See also: go install, go get, go clean.
const concurrentGCBackendCompilationEnabledByDefault = true
@@ -50,10 +55,10 @@ Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
func init() {
// break init cycle
CmdBuild.Run = runBuild
-@@ -209,6 +211,10 @@ func init() {
-
- AddBuildFlags(CmdBuild, DefaultBuildFlags)
- AddBuildFlags(CmdInstall, DefaultBuildFlags)
+@@ -246,6 +248,10 @@ func init() {
+ AddCoverFlags(CmdBuild, nil)
+ AddCoverFlags(CmdInstall, nil)
+ }
+
+ if x := os.Getenv("GOROOT_OVERRIDE"); x != "" {
+ goRootPrecious = false
@@ -61,10 +66,12 @@ Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
}
// Note that flags consulted by other parts of the code
+diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
+index 9724cd07d0..544df461a2 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
-@@ -535,6 +535,23 @@ func (b *Builder) build(ctx context.Cont
- return errors.New("binary-only packages are no longer supported")
+@@ -544,6 +544,23 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) {
+ return err
}
+ if goRootPrecious && (a.Package.Standard || a.Package.Goroot) {
@@ -84,10 +91,10 @@ Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
+ }
+ }
+
- if err := b.Mkdir(a.Objdir); err != nil {
+ if err := sh.Mkdir(a.Objdir); err != nil {
return err
}
-@@ -1585,6 +1602,14 @@ func (b *Builder) linkShared(ctx context
+@@ -1737,6 +1754,14 @@ func (b *Builder) linkShared(ctx context.Context, a *Action) (err error) {
return err
}
@@ -99,6 +106,9 @@ Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
+ }
+ }
+
- if err := b.Mkdir(a.Objdir); err != nil {
+ if err := b.Shell(a).Mkdir(a.Objdir); err != nil {
return err
}
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch b/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch
new file mode 100644
index 0000000000..c5bf28f54a
--- /dev/null
+++ b/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch
@@ -0,0 +1,61 @@
+From 083b5c74b12a1abeb11dd7f58a1cb1593d0000c0 Mon Sep 17 00:00:00 2001
+From: Changqing Li <changqing.li@windriver.com>
+Date: Tue, 27 Feb 2024 18:06:51 +0800
+Subject: [PATCH] exec.go: filter out build-specific paths from linker flags
+
+The flags can contain build-specific paths, breaking reproducibility.
+Filter out options that have build-specific paths.
+
+Upstream-Status: Inappropriate [ Not perfect for upstream ]
+
+Signed-off-by: Changqing Li <changqing.li@windriver.com>
+---
+ src/cmd/go/internal/work/exec.go | 25 ++++++++++++++++++++++++-
+ 1 file changed, 24 insertions(+), 1 deletion(-)
+
+diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
+index cde867b..e3ce17d 100644
+--- a/src/cmd/go/internal/work/exec.go
++++ b/src/cmd/go/internal/work/exec.go
+@@ -1358,6 +1358,29 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID {
+ return h.Sum()
+ }
+
++func filterLinkerFlags(flags []string) []string {
++ var newflags []string
++ var skipflag bool
++ skipflag = false
++ for i, flag := range flags {
++ if skipflag == true {
++ skipflag = false
++ continue
++ }
++ if strings.HasPrefix(flag, "--sysroot") || strings.HasPrefix(flag, "-fmacro-prefix-map") || strings.HasPrefix(flag, "-fdebug-prefix-map") || strings.HasPrefix(flag, "-ffile-prefix-map") || strings.HasPrefix(flag, "-fcanon-prefix-map") || strings.HasPrefix(flag, "-fprofile-prefix-map") || strings.HasPrefix(flag, "-Wl,-rpath-link"){
++ continue
++ } else if strings.HasPrefix(flag, "-extldflags") {
++ skipflag = true
++ newflags = append(newflags, flag)
++ var filterd_Extldflags []string = filterLinkerFlags(strings.Split(flags[i+1], " "))
++ newflags = append(newflags, strings.Join(filterd_Extldflags, " "))
++ } else {
++ newflags = append(newflags, flag)
++ }
++ }
++ return newflags
++}
++
+ // printLinkerConfig prints the linker config into the hash h,
+ // as part of the computation of a linker-related action ID.
+ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
+@@ -1368,7 +1391,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
+ case "gc":
+ fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode)
+ if p != nil {
+- fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags)
++ fmt.Fprintf(h, "linkflags %q\n", filterLinkerFlags(p.Internal.Ldflags))
+ }
+
+ // GOARM, GOMIPS, etc.
+--
+2.25.1
+
diff --git a/meta/recipes-devtools/go/go/0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch b/meta/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch
index ef1cc6716a..0662f66af5 100644
--- a/meta/recipes-devtools/go/go/0001-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch
+++ b/meta/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch
@@ -1,21 +1,25 @@
-From 2055a46b396e272616c0b2273903e02c3b49a2ff Mon Sep 17 00:00:00 2001
+From e0999902687e2e394499f7153db8d62440c4dab0 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Tue, 10 Nov 2020 16:33:27 +0000
-Subject: [PATCH] src/cmd/dist/buildgo.go: do not hardcode host compilers into
- target binaries
+Subject: [PATCH 8/9] src/cmd/dist/buildgo.go: do not hardcode host compilers
+ into target binaries
These come from $CC/$CXX on the build host and are not useful on targets;
additionally as they contain host specific paths, this helps reproducibility.
Upstream-Status: Inappropriate [needs upstream discussion]
+
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/dist/buildgo.go | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
+diff --git a/src/cmd/dist/buildgo.go b/src/cmd/dist/buildgo.go
+index 884e9d729a..2f52edacfe 100644
--- a/src/cmd/dist/buildgo.go
+++ b/src/cmd/dist/buildgo.go
-@@ -34,8 +34,8 @@ func mkzdefaultcc(dir, file string) {
+@@ -51,8 +51,8 @@ func mkzdefaultcc(dir, file string) {
fmt.Fprintf(&buf, "package cfg\n")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "const DefaultPkgConfig = `%s`\n", defaultpkgconfig)
@@ -26,7 +30,7 @@ Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
writefile(buf.String(), file, writeSkipSame)
return
}
-@@ -46,8 +46,8 @@ func mkzdefaultcc(dir, file string) {
+@@ -62,8 +62,8 @@ func mkzdefaultcc(dir, file string) {
fmt.Fprintf(&buf, "package main\n")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "const defaultPkgConfig = `%s`\n", defaultpkgconfig)
@@ -37,3 +41,6 @@ Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
writefile(buf.String(), file, writeSkipSame)
}
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/filter-build-paths.patch b/meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch
index a1aa37c2a4..cc45496e9c 100644
--- a/meta/recipes-devtools/go/go/filter-build-paths.patch
+++ b/meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch
@@ -1,27 +1,28 @@
-From 3bdbce685c688a27eece36ccc8be9b50b4849498 Mon Sep 17 00:00:00 2001
+From 6c2438f187ca912c54a71b4ac65ab98999a019d2 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Sat, 2 Jul 2022 23:08:13 +0100
-Subject: [PATCH] go: Filter build paths on staticly linked arches
+Subject: [PATCH 9/9] go: Filter build paths on staticly linked arches
Filter out build time paths from ldflags and other flags variables when they're
embedded in the go binary so that builds are reproducible regardless of build
location. This codepath is hit for statically linked go binaries such as those
on mips/ppc.
-Upstream-Status: Pending
-Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+Upstream-Status: Submitted [https://github.com/golang/go/pull/56410]
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
---
src/cmd/go/internal/load/pkg.go | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
-index 046f508..353cbc4 100644
+index 1549800afb..f41fb2c4ef 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
-@@ -2256,6 +2256,17 @@ func (p *Package) collectDeps() {
- // to their VCS information (vcsStatusError).
- var vcsStatusCache par.Cache
+@@ -2277,6 +2277,17 @@ func appendBuildSetting(info *debug.BuildInfo, key, value string) {
+ info.Settings = append(info.Settings, debug.BuildSetting{Key: key, Value: value})
+ }
+func filterCompilerFlags(flags string) string {
+ var newflags []string
@@ -34,10 +35,10 @@ index 046f508..353cbc4 100644
+ return strings.Join(newflags, " ")
+}
+
- // setBuildInfo gathers build information, formats it as a string to be
- // embedded in the binary, then sets p.Internal.BuildInfo to that string.
- // setBuildInfo should only be called on a main package with no errors.
-@@ -2353,7 +2364,7 @@ func (p *Package) setBuildInfo(includeVCS bool) {
+ // setBuildInfo gathers build information and sets it into
+ // p.Internal.BuildInfo, which will later be formatted as a string and embedded
+ // in the binary. setBuildInfo should only be called on a main package with no
+@@ -2384,7 +2395,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
if gcflags := BuildGcflags.String(); gcflags != "" && cfg.BuildContext.Compiler == "gc" {
appendSetting("-gcflags", gcflags)
}
@@ -46,7 +47,7 @@ index 046f508..353cbc4 100644
// https://go.dev/issue/52372: only include ldflags if -trimpath is not set,
// since it can include system paths through various linker flags (notably
// -extar, -extld, and -extldflags).
-@@ -2392,7 +2403,7 @@ func (p *Package) setBuildInfo(includeVCS bool) {
+@@ -2427,7 +2438,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
// subset of flags that are known not to be paths?
if cfg.BuildContext.CgoEnabled && !cfg.BuildTrimpath {
for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} {
@@ -55,3 +56,6 @@ index 046f508..353cbc4 100644
}
}
appendSetting("GOARCH", cfg.BuildContext.GOARCH)
+--
+2.44.0
+
diff --git a/meta/recipes-devtools/go/go/stack-protector.patch b/meta/recipes-devtools/go/go/stack-protector.patch
deleted file mode 100644
index cc92a444a7..0000000000
--- a/meta/recipes-devtools/go/go/stack-protector.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From c537b87782293fe222f2ef5eb1ae818092118e97 Mon Sep 17 00:00:00 2001
-From: Ian Lance Taylor <iant@golang.org>
-Date: Sun, 07 Aug 2022 19:21:15 -0700
-Subject: [PATCH] runtime/cgo: add -fno-stack-protector to CFLAGS
-
-Some compilers default to having -fstack-protector on, which breaks
-when using internal linking because the linker doesn't know how to
-find the support functions.
-
-Fixes #52919
-Fixes #54313
-
-Change-Id: I6f51d5e906503f61fc768ad8e30c163bad135087
-Upstream-Status: Submitted [https://github.com/golang/go/issues/54313]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
-
-diff --git a/src/runtime/cgo/cgo.go b/src/runtime/cgo/cgo.go
-index 298aa63..4b7046e 100644
---- a/src/runtime/cgo/cgo.go
-+++ b/src/runtime/cgo/cgo.go
-@@ -23,7 +23,9 @@
- #cgo solaris LDFLAGS: -lxnet
- #cgo solaris LDFLAGS: -lsocket
-
--#cgo CFLAGS: -Wall -Werror
-+// We use -fno-stack-protector because internal linking won't find
-+// the support functions. See issues #52919 and #54313.
-+#cgo CFLAGS: -Wall -Werror -fno-stack-protector
-
- #cgo solaris CPPFLAGS: -D_POSIX_PTHREAD_SEMANTICS
-
diff --git a/meta/recipes-devtools/go/go_1.19.bb b/meta/recipes-devtools/go/go_1.22.2.bb
index 98977673ee..46f5fbc6be 100644
--- a/meta/recipes-devtools/go/go_1.19.bb
+++ b/meta/recipes-devtools/go/go_1.22.2.bb
@@ -3,7 +3,7 @@ require go-target.inc
inherit linuxloader
-CGO_LDFLAGS:append:mips = " -no-pie"
+CGO_LDFLAGS:append = " -no-pie"
export GO_LDSO = "${@get_linuxloader(d)}"
export CC_FOR_TARGET = "gcc"
@@ -12,7 +12,7 @@ export CXX_FOR_TARGET = "g++"
# mips/rv64 doesn't support -buildmode=pie, so skip the QA checking for mips/riscv32 and its
# variants.
python() {
- if 'mips' in d.getVar('TARGET_ARCH',True) or 'riscv32' in d.getVar('TARGET_ARCH',True):
- d.appendVar('INSANE_SKIP:%s' % d.getVar('PN',True), " textrel")
+ if 'mips' in d.getVar('TARGET_ARCH') or 'riscv32' in d.getVar('TARGET_ARCH'):
+ d.appendVar('INSANE_SKIP:%s' % d.getVar('PN'), " textrel")
}