summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-11-07 13:31:53 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-11-07 13:31:53 +0000
commit8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch)
treeefdc32587159d0050a69009bdf2330a531727d95 /meta/recipes-devtools/go
parentd412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff)
downloadpoky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz
The poky repository master branch is no longer being updated.
You can either: a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs b) use the new bitbake-setup You can find information about either approach in our documentation: https://docs.yoctoproject.org/ Note that "poky" the distro setting is still available in meta-yocto as before and we continue to use and maintain that. Long live Poky! Some further information on the background of this change can be found in: https://lists.openembedded.org/g/openembedded-architecture/message/2179 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/go')
-rw-r--r--meta/recipes-devtools/go/go-1.25.3.inc21
-rw-r--r--meta/recipes-devtools/go/go-binary-native_1.25.3.bb51
-rw-r--r--meta/recipes-devtools/go/go-common.inc47
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian.inc62
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian_1.25.3.bb2
-rw-r--r--meta/recipes-devtools/go/go-cross.inc54
-rw-r--r--meta/recipes-devtools/go/go-cross_1.25.3.bb2
-rw-r--r--meta/recipes-devtools/go/go-crosssdk.inc44
-rw-r--r--meta/recipes-devtools/go/go-crosssdk_1.25.3.bb2
-rw-r--r--meta/recipes-devtools/go/go-runtime.inc94
-rw-r--r--meta/recipes-devtools/go/go-runtime_1.25.3.bb3
-rw-r--r--meta/recipes-devtools/go/go-target.inc53
-rw-r--r--meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch173
-rw-r--r--meta/recipes-devtools/go/go/0001-runtime-when-using-cgo-on-386-call-C-sigaction-funct.patch248
-rw-r--r--meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch56
-rw-r--r--meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch51
-rw-r--r--meta/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch48
-rw-r--r--meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch224
-rw-r--r--meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch114
-rw-r--r--meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch63
-rw-r--r--meta/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch46
-rw-r--r--meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch61
-rw-r--r--meta/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch50
-rw-r--r--meta/recipes-devtools/go/go/0011-cmd-link-stop-forcing-binutils-gold-dependency-on-aa.patch55
-rw-r--r--meta/recipes-devtools/go/go_1.25.3.bb18
25 files changed, 0 insertions, 1642 deletions
diff --git a/meta/recipes-devtools/go/go-1.25.3.inc b/meta/recipes-devtools/go/go-1.25.3.inc
deleted file mode 100644
index c29f4d6ece..0000000000
--- a/meta/recipes-devtools/go/go-1.25.3.inc
+++ /dev/null
@@ -1,21 +0,0 @@
1require go-common.inc
2
3FILESEXTRAPATHS:prepend := "${FILE_DIRNAME}/go:"
4
5LIC_FILES_CHKSUM = "file://LICENSE;md5=7998cb338f82d15c0eff93b7004d272a"
6
7SRC_URI += "\
8 file://0001-cmd-go-make-content-based-hash-generation-less-pedan.patch \
9 file://0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch \
10 file://0003-ld-add-soname-to-shareable-objects.patch \
11 file://0004-make.bash-override-CC-when-building-dist-and-go_boot.patch \
12 file://0005-cmd-dist-separate-host-and-target-builds.patch \
13 file://0006-cmd-go-make-GOROOT-precious-by-default.patch \
14 file://0007-exec.go-filter-out-build-specific-paths-from-linker-.patch \
15 file://0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch \
16 file://0009-go-Filter-build-paths-on-staticly-linked-arches.patch \
17 file://0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch \
18 file://0011-cmd-link-stop-forcing-binutils-gold-dependency-on-aa.patch \
19 file://0001-runtime-when-using-cgo-on-386-call-C-sigaction-funct.patch \
20"
21SRC_URI[main.sha256sum] = "a81a4ba593d0015e10c51e267de3ff07c7ac914dfca037d9517d029517097795"
diff --git a/meta/recipes-devtools/go/go-binary-native_1.25.3.bb b/meta/recipes-devtools/go/go-binary-native_1.25.3.bb
deleted file mode 100644
index b1d9522cb6..0000000000
--- a/meta/recipes-devtools/go/go-binary-native_1.25.3.bb
+++ /dev/null
@@ -1,51 +0,0 @@
1# This recipe is for bootstrapping our go-cross from a prebuilt binary of Go from golang.org.
2
3SUMMARY = "Go programming language compiler (upstream binary for bootstrap)"
4HOMEPAGE = " http://golang.org/"
5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=7998cb338f82d15c0eff93b7004d272a"
7
8PROVIDES = "go-native"
9
10# Checksums available at https://go.dev/dl/
11SRC_URI = "https://dl.google.com/go/go${PV}.${BUILD_GOOS}-${BUILD_GOARCH}.tar.gz;name=go_${BUILD_GOTUPLE}"
12SRC_URI[go_linux_amd64.sha256sum] = "0335f314b6e7bfe08c3d0cfaa7c19db961b7b99fb20be62b0a826c992ad14e0f"
13SRC_URI[go_linux_arm64.sha256sum] = "1d42ebc84999b5e2069f5e31b67d6fc5d67308adad3e178d5a2ee2c9ff2001f5"
14SRC_URI[go_linux_ppc64le.sha256sum] = "68d1a08bf3567f330717d821b266a0be1c5080bd05dc238b5a43a24ca0c47d7c"
15
16UPSTREAM_CHECK_URI = "https://golang.org/dl/"
17UPSTREAM_CHECK_REGEX = "go(?P<pver>\d+(\.\d+)+)\.linux"
18
19CVE_PRODUCT = "golang:go"
20CVE_STATUS[CVE-2024-3566] = "not-applicable-platform: Issue only applies on Windows"
21
22S = "${UNPACKDIR}/go"
23
24inherit goarch native
25
26do_compile() {
27 :
28}
29
30make_wrapper() {
31 rm -f ${D}${bindir}/$1
32 cat <<END >${D}${bindir}/$1
33#!/bin/bash
34here=\`dirname \$0\`
35export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}"
36\$here/../lib/go/bin/$1 "\$@"
37END
38 chmod +x ${D}${bindir}/$1
39}
40
41do_install() {
42 find ${S} -depth -type d -name testdata -exec rm -rf {} +
43
44 install -d ${D}${bindir} ${D}${libdir}/go
45 cp --preserve=mode,timestamps -R ${S}/ ${D}${libdir}/
46
47 for f in ${S}/bin/*
48 do
49 make_wrapper `basename $f`
50 done
51}
diff --git a/meta/recipes-devtools/go/go-common.inc b/meta/recipes-devtools/go/go-common.inc
deleted file mode 100644
index 061db4296c..0000000000
--- a/meta/recipes-devtools/go/go-common.inc
+++ /dev/null
@@ -1,47 +0,0 @@
1SUMMARY = "Go programming language compiler"
2DESCRIPTION = " The Go programming language is an open source project to make \
3 programmers more productive. Go is expressive, concise, clean, and\
4 efficient. Its concurrency mechanisms make it easy to write programs\
5 that get the most out of multicore and networked machines, while its\
6 novel type system enables flexible and modular program construction.\
7 Go compiles quickly to machine code yet has the convenience of\
8 garbage collection and the power of run-time reflection. It's a\
9 fast, statically typed, compiled language that feels like a\
10 dynamically typed, interpreted language."
11
12HOMEPAGE = " http://golang.org/"
13LICENSE = "BSD-3-Clause"
14
15inherit goarch
16
17SRC_URI = "https://golang.org/dl/go${PV}.src.tar.gz;name=main"
18S = "${UNPACKDIR}/go"
19B = "${S}"
20UPSTREAM_CHECK_REGEX = "(?P<pver>\d+(\.\d+)+)\.src\.tar"
21
22# all recipe variants are created from the same product
23CVE_PRODUCT = "golang:go"
24CVE_STATUS[CVE-2024-3566] = "not-applicable-platform: Issue only applies on Windows"
25
26INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
27SSTATE_SCAN_CMD = "true"
28
29export GOROOT_OVERRIDE = "1"
30export GOTMPDIR ?= "${WORKDIR}/build-tmp"
31GOTMPDIR[vardepvalue] = ""
32export CGO_ENABLED = "1"
33
34export GOHOSTOS ?= "${BUILD_GOOS}"
35export GOHOSTARCH ?= "${BUILD_GOARCH}"
36export GOROOT_BOOTSTRAP ?= "${STAGING_LIBDIR_NATIVE}/go"
37export GOOS ?= "${TARGET_GOOS}"
38export GOARCH ?= "${TARGET_GOARCH}"
39export GOARM ?= "${TARGET_GOARM}"
40export GO386 ?= "${TARGET_GO386}"
41export GOMIPS ?= "${TARGET_GOMIPS}"
42
43export GODEBUG = "gocachehash=1"
44
45do_compile:prepend() {
46 BUILD_CC=${BUILD_CC}
47}
diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc
deleted file mode 100644
index 4a6f2f4c36..0000000000
--- a/meta/recipes-devtools/go/go-cross-canadian.inc
+++ /dev/null
@@ -1,62 +0,0 @@
1inherit cross-canadian
2
3DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go-runtime \
4 virtual/nativesdk-cross-cc virtual/nativesdk-libc \
5 virtual/nativesdk-compilerlibs"
6PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
7
8GOARCH = "${HOST_GOARCH}"
9
10# it uses gcc on build machine during go-cross-canadian bootstrap, but
11# the gcc version may be old and not support option '-fmacro-prefix-map'
12# which is one of default values of DEBUG_PREFIX_MAP
13DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=${TARGET_DBGSRC_DIR} \
14 -fdebug-prefix-map=${STAGING_DIR_HOST}= \
15 -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
16 "
17
18export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}"
19export CGO_CFLAGS = "${CFLAGS}"
20export CGO_LDFLAGS = "${LDFLAGS}"
21export GO_LDFLAGS = '-extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"'
22
23do_configure[noexec] = "1"
24
25do_compile() {
26 export CC_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS}"
27 export CXX_FOR_${HOST_GOTUPLE}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS}"
28 cd src
29 ./make.bash --target-only --no-banner
30 cd ${B}
31}
32do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
33
34make_wrapper() {
35 rm -f ${D}${bindir}/$2
36 cat <<END >${D}${bindir}/$2
37#!/bin/sh
38here=\`dirname \$0\`
39native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\`
40export GOARCH="${TARGET_GOARCH}"
41export GOOS="${TARGET_GOOS}"
42test -n "\$GOARM" || export GOARM="${TARGET_GOARM}"
43test -n "\$GO386" || export GO386="${TARGET_GO386}"
44test -n "\$GOMIPS" || export GOMIPS="${TARGET_GOMIPS}"
45export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}"
46test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go"
47\$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@"
48END
49 chmod +x ${D}${bindir}/$2
50}
51
52do_install() {
53 install -d ${D}${libdir}/go/pkg/tool
54 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/
55 install -d ${D}${bindir} ${D}${libdir}/go/bin
56 for f in $(find ${B}/${GO_BUILD_BINDIR} -type f)
57 do
58 base=`basename $f`
59 install -m755 $f ${D}${libdir}/go/bin
60 make_wrapper $base ${TARGET_PREFIX}$base
61 done
62}
diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.25.3.bb b/meta/recipes-devtools/go/go-cross-canadian_1.25.3.bb
deleted file mode 100644
index 7ac9449e47..0000000000
--- a/meta/recipes-devtools/go/go-cross-canadian_1.25.3.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-cross-canadian.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-cross.inc b/meta/recipes-devtools/go/go-cross.inc
deleted file mode 100644
index ebee2e53cd..0000000000
--- a/meta/recipes-devtools/go/go-cross.inc
+++ /dev/null
@@ -1,54 +0,0 @@
1inherit cross
2
3PROVIDES = "virtual/${TUNE_PKGARCH}-go"
4DEPENDS = "go-native"
5
6PN = "go-cross-${TUNE_PKGARCH}"
7
8CCACHE_DISABLE = "1"
9
10export GOCACHE = "${B}/.cache"
11CC = "${@d.getVar('BUILD_CC').strip()}"
12
13do_configure[noexec] = "1"
14
15do_compile() {
16 export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
17 export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
18 cd src
19 ./make.bash --host-only --no-banner
20 cd ${B}
21}
22do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
23
24make_wrapper() {
25 rm -f ${D}${bindir}/$2
26 cat <<END >${D}${bindir}/$2
27#!/bin/bash
28here=\`dirname \$0\`
29export GOARCH="${TARGET_GOARCH}"
30export GOOS="${TARGET_GOOS}"
31export GOARM="\${GOARM:-${TARGET_GOARM}}"
32export GO386="\${GO386:-${TARGET_GO386}}"
33export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}"
34\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
35END
36 chmod +x ${D}${bindir}/$2
37}
38
39do_install() {
40 install -d ${D}${libdir}/go
41 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
42 install -d ${D}${libdir}/go/src
43 (cd ${S}/src; for d in *; do \
44 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
45 done)
46 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
47 install -d ${D}${bindir} ${D}${libdir}/go/bin
48 for f in ${B}/bin/*
49 do
50 base=`basename $f`
51 install -m755 $f ${D}${libdir}/go/bin
52 make_wrapper $base ${TARGET_PREFIX}$base
53 done
54}
diff --git a/meta/recipes-devtools/go/go-cross_1.25.3.bb b/meta/recipes-devtools/go/go-cross_1.25.3.bb
deleted file mode 100644
index 80b5a03f6c..0000000000
--- a/meta/recipes-devtools/go/go-cross_1.25.3.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-cross.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-crosssdk.inc b/meta/recipes-devtools/go/go-crosssdk.inc
deleted file mode 100644
index 4f19025ba7..0000000000
--- a/meta/recipes-devtools/go/go-crosssdk.inc
+++ /dev/null
@@ -1,44 +0,0 @@
1inherit crosssdk
2
3DEPENDS = "go-native virtual/nativesdk-cross-cc virtual/nativesdk-compilerlibs virtual/nativesdk-cross-binutils"
4PN = "go-crosssdk-${SDK_SYS}"
5PROVIDES = "virtual/${TARGET_PREFIX}go"
6
7export GOCACHE = "${B}/.cache"
8
9do_configure[noexec] = "1"
10
11do_compile() {
12 export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
13 export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
14 cd src
15 ./make.bash --host-only --no-banner
16 cd ${B}
17}
18do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
19
20make_wrapper() {
21 rm -f ${D}${bindir}/$2
22 cat <<END >${D}${bindir}/$2
23#!/bin/bash
24here=\`dirname \$0\`
25export GOARCH="${TARGET_GOARCH}"
26export GOOS="${TARGET_GOOS}"
27\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
28END
29 chmod +x ${D}${bindir}/$2
30}
31
32do_install() {
33 install -d ${D}${libdir}/go
34 install -d ${D}${libdir}/go/bin
35 install -d ${D}${libdir}/go/pkg/tool
36 install -d ${D}${bindir}
37 cp --preserve=mode,timestamps -R ${S}/pkg/tool/${BUILD_GOTUPLE} ${D}${libdir}/go/pkg/tool/
38 for f in ${B}/bin/*
39 do
40 base=`basename $f`
41 install -m755 $f ${D}${libdir}/go/bin
42 make_wrapper $base ${TARGET_PREFIX}$base
43 done
44}
diff --git a/meta/recipes-devtools/go/go-crosssdk_1.25.3.bb b/meta/recipes-devtools/go/go-crosssdk_1.25.3.bb
deleted file mode 100644
index 1857c8a577..0000000000
--- a/meta/recipes-devtools/go/go-crosssdk_1.25.3.bb
+++ /dev/null
@@ -1,2 +0,0 @@
1require go-crosssdk.inc
2require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
deleted file mode 100644
index e5f17337bc..0000000000
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ /dev/null
@@ -1,94 +0,0 @@
1DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
2DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go"
3PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
4
5DEBUG_PREFIX_MAP = "\
6 -fdebug-prefix-map=${STAGING_DIR_HOST}= \
7 -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
8"
9
10export CGO_CFLAGS = "${CFLAGS}"
11export CGO_CPPFLAGS = "${CPPFLAGS}"
12export CGO_CXXFLAGS = "${CXXFLAGS}"
13# Filter out -fdebug-prefix-map options as they clash with the GO's build system
14export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
15export GOCACHE = "${B}/.cache"
16
17GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
18GO_SHLIB_LDFLAGS ?= '-ldflags="-extldflags '${GO_EXTLDFLAGS}'"'
19
20do_configure() {
21 :
22}
23
24do_configure:libc-musl() {
25 rm -f ${S}/src/runtime/race/*.syso
26}
27
28do_compile() {
29 export CC_FOR_${TARGET_GOTUPLE}="${CC}"
30 export CXX_FOR_${TARGET_GOTUPLE}="${CXX}"
31
32 cd src
33 ./make.bash --target-only --no-banner std
34 if [ -n "${GO_DYNLINK}" ]; then
35 export GOTOOLDIR="${B}/pkg/tool/native_native"
36 CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \
37 $GOTOOLDIR/go_bootstrap install -linkshared -trimpath -buildmode=shared ${GO_SHLIB_LDFLAGS} std
38 fi
39 cd ${B}
40}
41do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
42
43do_install() {
44 install -d ${D}${libdir}/go/src
45 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
46 if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then
47 rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}
48 rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE}
49 fi
50 rm -rf ${D}${libdir}/go/pkg/tool
51 rm -rf ${D}${libdir}/go/pkg/obj
52 rm -rf ${D}${libdir}/go/pkg/bootstrap
53 # the cmd directory is built for the native arch so if BUILD == TARGET
54 rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}/cmd
55 find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
56 cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
57 done
58 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
59 rm -f ${D}${libdir}/go/src/cmd/dist/dist
60 rm -f ${D}${libdir}/go/src/cmd/cgo/zdefaultcc.go
61 rm -f ${D}${libdir}/go/src/cmd/go/internal/cfg/zdefaultcc.go
62
63}
64
65ALLOW_EMPTY:${PN} = "1"
66FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}"
67FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \
68 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \
69 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \
70 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.shlibname \
71 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.shlibname \
72 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.shlibname \
73 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.shlibname \
74 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.shlibname \
75 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.a \
76 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.a \
77 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.a \
78 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.a \
79 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.a \
80 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.a \
81 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.a \
82"
83FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}"
84
85# Go sources include some scripts and pre-built binaries for
86# multiple architectures. The static .a files for dynamically-linked
87# runtime are also required in -dev.
88INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch"
89
90INHIBIT_PACKAGE_STRIP = "1"
91INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
92INHIBIT_SYSROOT_STRIP = "1"
93
94BBCLASSEXTEND = "nativesdk"
diff --git a/meta/recipes-devtools/go/go-runtime_1.25.3.bb b/meta/recipes-devtools/go/go-runtime_1.25.3.bb
deleted file mode 100644
index 63464a1501..0000000000
--- a/meta/recipes-devtools/go/go-runtime_1.25.3.bb
+++ /dev/null
@@ -1,3 +0,0 @@
1require go-${PV}.inc
2require go-runtime.inc
3
diff --git a/meta/recipes-devtools/go/go-target.inc b/meta/recipes-devtools/go/go-target.inc
deleted file mode 100644
index 981c7abd31..0000000000
--- a/meta/recipes-devtools/go/go-target.inc
+++ /dev/null
@@ -1,53 +0,0 @@
1DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
2DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go go-native"
3
4DEBUG_PREFIX_MAP = "\
5 -fdebug-prefix-map=${STAGING_DIR_HOST}= \
6 -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
7"
8
9export CGO_CFLAGS = "${CFLAGS}"
10export CGO_CPPFLAGS = "${CPPFLAGS}"
11export CGO_CXXFLAGS = "${CXXFLAGS}"
12# Filter out -fdebug-prefix-map options as they clash with the GO's build system
13export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
14
15export GOCACHE = "${B}/.cache"
16export GO_LDFLAGS = ""
17export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath"
18CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}"
19
20do_configure[noexec] = "1"
21
22do_compile() {
23 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}"
24 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}"
25
26 cd src
27 ./make.bash --target-only --no-banner
28 cd ${B}
29}
30do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
31
32do_install() {
33 install -d ${D}${libdir}/go/pkg/tool
34 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
35 install -d ${D}${libdir}/go/src
36 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
37 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
38 install -d ${D}${libdir}/go/bin
39 install -d ${D}${bindir}
40 for f in ${B}/${GO_BUILD_BINDIR}/*; do
41 name=`basename $f`
42 install -m 0755 $f ${D}${libdir}/go/bin/
43 ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/
44 done
45 rm -rf ${D}${libdir}/go/src
46}
47
48PACKAGES = "${PN} ${PN}-dev"
49FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
50RDEPENDS:${PN} = "go-runtime"
51INSANE_SKIP:${PN} = "ldflags"
52
53BBCLASSEXTEND = "nativesdk"
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
deleted file mode 100644
index b55ad1e787..0000000000
--- a/meta/recipes-devtools/go/go/0001-cmd-go-make-content-based-hash-generation-less-pedan.patch
+++ /dev/null
@@ -1,173 +0,0 @@
1From 51c04a9a19dec5a48fa0f38324dc2480b7a859e4 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 22 Feb 2025 03:24:48 -0800
4Subject: [PATCH 01/11] cmd/go: make content-based hash generation less
5 pedantic
6
7Go 1.10's build tool now uses content-based hashes to
8determine when something should be built or re-built.
9This same mechanism is used to maintain a built-artifact
10cache for speeding up builds.
11
12However, the hashes it generates include information that
13doesn't work well with OE, nor with using a shared runtime
14library.
15
16First, it embeds path names to source files, unless
17building within GOROOT. This prevents the building
18of a package in GOPATH for later staging into GOROOT.
19
20This patch adds support for the environment variable
21GOPATH_OMIT_IN_ACTIONID. If present, path name
22embedding is disabled.
23
24Upstream-Status: Inappropriate [OE specific]
25
26Signed-off-by: Alex Kube <alexander.j.kube@gmail.com>
27Signed-off-by: Matt Madison <matt@madison.systems>
28Signed-off-by: Khem Raj <raj.khem@gmail.com>
29Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
30
31Rebase to 1.23.4
32Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
33---
34 src/cmd/go/internal/envcmd/env.go | 2 +-
35 src/cmd/go/internal/work/exec.go | 44 ++++++++++++++++++++++++-------
36 2 files changed, 36 insertions(+), 10 deletions(-)
37
38diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go
39index 7c370d427f..c2441f7695 100644
40--- a/src/cmd/go/internal/envcmd/env.go
41+++ b/src/cmd/go/internal/envcmd/env.go
42@@ -219,7 +219,7 @@ func ExtraEnvVarsCostly() []cfg.EnvVar {
43 }
44 }()
45
46- cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{})
47+ cppflags, cflags, cxxflags, fflags, ldflags, err := b.CFlags(&load.Package{}, false)
48 if err != nil {
49 // Should not happen - b.CFlags was given an empty package.
50 fmt.Fprintf(os.Stderr, "go: invalid cflags: %v\n", err)
51diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
52index 7b073165d5..1f618be0bb 100644
53--- a/src/cmd/go/internal/work/exec.go
54+++ b/src/cmd/go/internal/work/exec.go
55@@ -237,6 +237,8 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
56 writeActionGraph()
57 }
58
59+var omitGopath = os.Getenv("GOPATH_OMIT_IN_ACTIONID") != ""
60+
61 // buildActionID computes the action ID for a build action.
62 func (b *Builder) buildActionID(a *Action) cache.ActionID {
63 p := a.Package
64@@ -258,7 +260,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
65 if p.Module != nil {
66 fmt.Fprintf(h, "module %s@%s\n", p.Module.Path, p.Module.Version)
67 }
68- } else if p.Goroot {
69+ } else if p.Goroot || omitGopath {
70 // The Go compiler always hides the exact value of $GOROOT
71 // when building things in GOROOT.
72 //
73@@ -293,9 +295,9 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
74 }
75 if len(p.CgoFiles)+len(p.SwigFiles)+len(p.SwigCXXFiles) > 0 {
76 fmt.Fprintf(h, "cgo %q\n", b.toolID("cgo"))
77- cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p)
78+ cppflags, cflags, cxxflags, fflags, ldflags, _ := b.CFlags(p, true)
79
80- ccExe := b.ccExe()
81+ ccExe := filterCompilerFlags(b.ccExe(), true)
82 fmt.Fprintf(h, "CC=%q %q %q %q\n", ccExe, cppflags, cflags, ldflags)
83 // Include the C compiler tool ID so that if the C
84 // compiler changes we rebuild the package.
85@@ -305,7 +307,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
86 fmt.Fprintf(h, "CC ID ERROR=%q\n", err)
87 }
88 if len(p.CXXFiles)+len(p.SwigCXXFiles) > 0 {
89- cxxExe := b.cxxExe()
90+ cxxExe := filterCompilerFlags(b.cxxExe(), true)
91 fmt.Fprintf(h, "CXX=%q %q\n", cxxExe, cxxflags)
92 if cxxID, _, err := b.gccToolID(cxxExe[0], "c++"); err == nil {
93 fmt.Fprintf(h, "CXX ID=%q\n", cxxID)
94@@ -314,7 +316,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
95 }
96 }
97 if len(p.FFiles) > 0 {
98- fcExe := b.fcExe()
99+ fcExe := filterCompilerFlags(b.fcExe(), true)
100 fmt.Fprintf(h, "FC=%q %q\n", fcExe, fflags)
101 if fcID, _, err := b.gccToolID(fcExe[0], "f95"); err == nil {
102 fmt.Fprintf(h, "FC ID=%q\n", fcID)
103@@ -333,7 +335,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
104 }
105 }
106 if p.Internal.BuildInfo != nil {
107- fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
108+ //fmt.Fprintf(h, "modinfo %q\n", p.Internal.BuildInfo.String())
109 }
110
111 // Configuration specific to compiler toolchain.
112@@ -2631,8 +2633,25 @@ func envList(key, def string) []string {
113 return args
114 }
115
116+var filterFlags = os.Getenv("CGO_PEDANTIC") == ""
117+
118+func filterCompilerFlags(flags []string, keepfirst bool) []string {
119+ var newflags []string
120+ var realkeepfirst bool = keepfirst
121+ if !filterFlags {
122+ return flags
123+ }
124+ for _, flag := range flags {
125+ if strings.HasPrefix(flag, "-m") || realkeepfirst {
126+ newflags = append(newflags, flag)
127+ realkeepfirst = false
128+ }
129+ }
130+ return newflags
131+}
132+
133 // CFlags returns the flags to use when invoking the C, C++ or Fortran compilers, or cgo.
134-func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
135+func (b *Builder) CFlags(p *load.Package, filtered bool) (cppflags, cflags, cxxflags, fflags, ldflags []string, err error) {
136 if cppflags, err = buildFlags("CPPFLAGS", "", p.CgoCPPFLAGS, checkCompilerFlags); err != nil {
137 return
138 }
139@@ -2648,6 +2667,13 @@ func (b *Builder) CFlags(p *load.Package) (cppflags, cflags, cxxflags, fflags, l
140 if ldflags, err = buildFlags("LDFLAGS", DefaultCFlags, p.CgoLDFLAGS, checkLinkerFlags); err != nil {
141 return
142 }
143+ if filtered {
144+ cppflags = filterCompilerFlags(cppflags, false)
145+ cflags = filterCompilerFlags(cflags, false)
146+ cxxflags = filterCompilerFlags(cxxflags, false)
147+ fflags = filterCompilerFlags(fflags, false)
148+ ldflags = filterCompilerFlags(ldflags, false)
149+ }
150
151 return
152 }
153@@ -2665,7 +2691,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
154 p := a.Package
155 sh := b.Shell(a)
156
157- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p)
158+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p, false)
159 if err != nil {
160 return nil, nil, err
161 }
162@@ -3229,7 +3255,7 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
163 p := a.Package
164 sh := b.Shell(a)
165
166- cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p)
167+ cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p, false)
168 if err != nil {
169 return "", "", err
170 }
171--
1722.25.1
173
diff --git a/meta/recipes-devtools/go/go/0001-runtime-when-using-cgo-on-386-call-C-sigaction-funct.patch b/meta/recipes-devtools/go/go/0001-runtime-when-using-cgo-on-386-call-C-sigaction-funct.patch
deleted file mode 100644
index 33e3b033a1..0000000000
--- a/meta/recipes-devtools/go/go/0001-runtime-when-using-cgo-on-386-call-C-sigaction-funct.patch
+++ /dev/null
@@ -1,248 +0,0 @@
1From c5737dc21bbac9fbefc35ac9313e66291d66b382 Mon Sep 17 00:00:00 2001
2From: Ian Lance Taylor <iant@golang.org>
3Date: Fri, 5 Sep 2025 22:24:37 -0700
4Subject: [PATCH] runtime: when using cgo on 386, call C sigaction function
5
6On 386 the C sigaction function assumes that the caller does not set
7the SA_RESTORER flag. It does not copy the C sa_restorer field to
8the kernel sa_restorer field. The effect is that the kernel sees
9the SA_RESTORER flag but a NULL sa_restorer field, and the program
10crashes when returning from a signal handler.
11
12On the other hand, the C sigaction function will return the SA_RESTORER
13flag and the sa_restorer field stored in the kernel.
14
15This means that if the Go runtime installs a signal handler,
16with SA_RESTORER as is required when calling the kernel,
17and the Go program calls C code that calls the C sigaction function
18to query the current signal handler, that C code will get a result
19that it can't pass back to sigaction.
20
21This CL fixes the problem by using the C sigaction function
22for 386 programs that use cgo. This reuses the functionality
23used on amd64 and other GOARCHs to support the race detector.
24
25See #75253, or runtime/testdata/testprogcgo/eintr.go, for sample
26code that used to fail on 386. No new test case is required,
27we just remove the skip we used to have for eintr.go.
28
29Fixes #75253
30
31Change-Id: I803059b1fb9e09e9fbb43f68eccb6a59a92c2991
32Reviewed-on: https://go-review.googlesource.com/c/go/+/701375
33LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
34Reviewed-by: Cherry Mui <cherryyz@google.com>
35Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
36Auto-Submit: Ian Lance Taylor <iant@golang.org>
37Upstream-Status: Backport [https://github.com/golang/go/commit/c5737dc21bbac9fbefc35ac9313e66291d66b382]
38Signed-off-by: Randolph Sapp <rs@ti.com>
39---
40 src/runtime/cgo/gcc_sigaction.c | 8 ++++----
41 src/runtime/cgo/sigaction.go | 2 +-
42 src/runtime/cgo_sigaction.go | 6 +++++-
43 src/runtime/crash_cgo_test.go | 11 -----------
44 src/runtime/os_freebsd.go | 6 ++++++
45 src/runtime/os_linux.go | 18 +++++++++++++++++-
46 src/runtime/sigaction.go | 2 +-
47 src/runtime/sys_linux_386.s | 19 +++++++++++++++++++
48 8 files changed, 53 insertions(+), 19 deletions(-)
49
50diff --git a/src/runtime/cgo/gcc_sigaction.c b/src/runtime/cgo/gcc_sigaction.c
51index 7cbef7db11..ad48a88dc1 100644
52--- a/src/runtime/cgo/gcc_sigaction.c
53+++ b/src/runtime/cgo/gcc_sigaction.c
54@@ -2,7 +2,7 @@
55 // Use of this source code is governed by a BSD-style
56 // license that can be found in the LICENSE file.
57
58-//go:build linux && (amd64 || arm64 || loong64 || ppc64le)
59+//go:build linux && (386 || amd64 || arm64 || loong64 || ppc64le)
60
61 #include <errno.h>
62 #include <stddef.h>
63@@ -17,7 +17,7 @@
64 // to and from struct sigaction — are specific to ${goos}/${goarch}.
65 typedef struct {
66 uintptr_t handler;
67- uint64_t flags;
68+ unsigned long flags;
69 #ifdef __loongarch__
70 uint64_t mask;
71 uintptr_t restorer;
72@@ -57,7 +57,7 @@ x_cgo_sigaction(intptr_t signum, const go_sigaction_t *goact, go_sigaction_t *ol
73 sigaddset(&act.sa_mask, (int)(i+1));
74 }
75 }
76- act.sa_flags = (int)(goact->flags & ~(uint64_t)SA_RESTORER);
77+ act.sa_flags = (int)(goact->flags & ~(unsigned long)SA_RESTORER);
78 }
79
80 ret = sigaction((int)signum, goact ? &act : NULL, oldgoact ? &oldact : NULL);
81@@ -79,7 +79,7 @@ x_cgo_sigaction(intptr_t signum, const go_sigaction_t *goact, go_sigaction_t *ol
82 oldgoact->mask |= (uint64_t)(1)<<i;
83 }
84 }
85- oldgoact->flags = (uint64_t)oldact.sa_flags;
86+ oldgoact->flags = (unsigned long)oldact.sa_flags;
87 }
88
89 _cgo_tsan_release();
90diff --git a/src/runtime/cgo/sigaction.go b/src/runtime/cgo/sigaction.go
91index dc3f5fd255..90034bad32 100644
92--- a/src/runtime/cgo/sigaction.go
93+++ b/src/runtime/cgo/sigaction.go
94@@ -2,7 +2,7 @@
95 // Use of this source code is governed by a BSD-style
96 // license that can be found in the LICENSE file.
97
98-//go:build (linux && (amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
99+//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
100
101 package cgo
102
103diff --git a/src/runtime/cgo_sigaction.go b/src/runtime/cgo_sigaction.go
104index 5c644587f0..f725dbef4d 100644
105--- a/src/runtime/cgo_sigaction.go
106+++ b/src/runtime/cgo_sigaction.go
107@@ -3,8 +3,10 @@
108 // license that can be found in the LICENSE file.
109
110 // Support for sanitizers. See runtime/cgo/sigaction.go.
111+// Also used on linux/386 to clear the SA_RESTORER flag
112+// when using cgo; see issue #75253.
113
114-//go:build (linux && (amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
115+//go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64)
116
117 package runtime
118
119@@ -42,6 +44,8 @@ func sigaction(sig uint32, new, old *sigactiont) {
120
121 var ret int32
122
123+ fixSigactionForCgo(new)
124+
125 var g *g
126 if mainStarted {
127 g = getg()
128diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go
129index c5d7303261..b77ff8dafd 100644
130--- a/src/runtime/crash_cgo_test.go
131+++ b/src/runtime/crash_cgo_test.go
132@@ -842,17 +842,6 @@ func TestEINTR(t *testing.T) {
133 switch runtime.GOOS {
134 case "plan9", "windows":
135 t.Skipf("no EINTR on %s", runtime.GOOS)
136- case "linux":
137- if runtime.GOARCH == "386" {
138- // On linux-386 the Go signal handler sets
139- // a restorer function that is not preserved
140- // by the C sigaction call in the test,
141- // causing the signal handler to crash when
142- // returning the normal code. The test is not
143- // architecture-specific, so just skip on 386
144- // rather than doing a complicated workaround.
145- t.Skip("skipping on linux-386; C sigaction does not preserve Go restorer")
146- }
147 }
148 if runtime.GOOS == "freebsd" && race.Enabled {
149 t.Skipf("race + cgo freebsd not supported. See https://go.dev/issue/73788.")
150diff --git a/src/runtime/os_freebsd.go b/src/runtime/os_freebsd.go
151index ab859cfb47..68d895b95d 100644
152--- a/src/runtime/os_freebsd.go
153+++ b/src/runtime/os_freebsd.go
154@@ -457,6 +457,12 @@ func sysSigaction(sig uint32, new, old *sigactiont) {
155 }
156 }
157
158+// fixSigactionForCgo is needed for Linux.
159+//
160+//go:nosplit
161+func fixSigactionForCgo(new *sigactiont) {
162+}
163+
164 // asmSigaction is implemented in assembly.
165 //
166 //go:noescape
167diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
168index c9d25a5be8..f9fe1b5f33 100644
169--- a/src/runtime/os_linux.go
170+++ b/src/runtime/os_linux.go
171@@ -486,7 +486,8 @@ func setsig(i uint32, fn uintptr) {
172 sigfillset(&sa.sa_mask)
173 // Although Linux manpage says "sa_restorer element is obsolete and
174 // should not be used". x86_64 kernel requires it. Only use it on
175- // x86.
176+ // x86. Note that on 386 this is cleared when using the C sigaction
177+ // function via cgo; see fixSigactionForCgo.
178 if GOARCH == "386" || GOARCH == "amd64" {
179 sa.sa_restorer = abi.FuncPCABI0(sigreturn__sigaction)
180 }
181@@ -562,6 +563,21 @@ func sysSigaction(sig uint32, new, old *sigactiont) {
182 //go:noescape
183 func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32
184
185+// fixSigactionForCgo is called when we are using cgo to call the
186+// C sigaction function. On 386 the C function does not expect the
187+// SA_RESTORER flag to be set, and in some cases will fail if it is set:
188+// it will pass the SA_RESTORER flag to the kernel without passing
189+// the sa_restorer field. Since the C function will handle SA_RESTORER
190+// for us, we need not pass it. See issue #75253.
191+//
192+//go:nosplit
193+func fixSigactionForCgo(new *sigactiont) {
194+ if GOARCH == "386" && new != nil {
195+ new.sa_flags &^= _SA_RESTORER
196+ new.sa_restorer = 0
197+ }
198+}
199+
200 func getpid() int
201 func tgkill(tgid, tid, sig int)
202
203diff --git a/src/runtime/sigaction.go b/src/runtime/sigaction.go
204index 2027ae80bf..1a99f7f3ec 100644
205--- a/src/runtime/sigaction.go
206+++ b/src/runtime/sigaction.go
207@@ -2,7 +2,7 @@
208 // Use of this source code is governed by a BSD-style
209 // license that can be found in the LICENSE file.
210
211-//go:build (linux && !amd64 && !arm64 && !loong64 && !ppc64le) || (freebsd && !amd64)
212+//go:build (linux && !386 && !amd64 && !arm64 && !loong64 && !ppc64le) || (freebsd && !amd64)
213
214 package runtime
215
216diff --git a/src/runtime/sys_linux_386.s b/src/runtime/sys_linux_386.s
217index d53be243fe..8e832687e0 100644
218--- a/src/runtime/sys_linux_386.s
219+++ b/src/runtime/sys_linux_386.s
220@@ -410,6 +410,25 @@ TEXT runtime·rt_sigaction(SB),NOSPLIT,$0
221 MOVL AX, ret+16(FP)
222 RET
223
224+// Call the function stored in _cgo_sigaction using the GCC calling convention.
225+TEXT runtime·callCgoSigaction(SB),NOSPLIT,$0-16
226+ MOVL _cgo_sigaction(SB), AX
227+ MOVL sig+0(FP), BX
228+ MOVL new+4(FP), CX
229+ MOVL old+8(FP), DX
230+ MOVL SP, SI // align stack to call C function
231+ SUBL $32, SP
232+ ANDL $~15, SP
233+ MOVL BX, 0(SP)
234+ MOVL CX, 4(SP)
235+ MOVL DX, 8(SP)
236+ MOVL SI, 12(SP)
237+ CALL AX
238+ MOVL 12(SP), BX
239+ MOVL BX, SP
240+ MOVL AX, ret+12(FP)
241+ RET
242+
243 TEXT runtime·sigfwd(SB),NOSPLIT,$12-16
244 MOVL fn+0(FP), AX
245 MOVL sig+4(FP), BX
246--
2472.51.0
248
diff --git a/meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch b/meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch
deleted file mode 100644
index f6767d0d47..0000000000
--- a/meta/recipes-devtools/go/go/0002-cmd-go-Allow-GOTOOLDIR-to-be-overridden-in-the-envir.patch
+++ /dev/null
@@ -1,56 +0,0 @@
1From fdad9a0ea659cf2281a0df16b0f69f179605ec9a Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Wed, 23 Oct 2019 21:15:37 +0430
4Subject: [PATCH 02/11] cmd/go: Allow GOTOOLDIR to be overridden in the
5 environment
6
7to allow for split host/target build roots
8
9Adapted to Go 1.13 from patches originally submitted to
10the meta/recipes-devtools/go tree by
11Matt Madison <matt@madison.systems>.
12
13Upstream-Status: Inappropriate [OE specific]
14
15Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
16Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
17---
18 src/cmd/dist/build.go | 4 +++-
19 src/cmd/go/internal/cfg/cfg.go | 6 +++++-
20 2 files changed, 8 insertions(+), 2 deletions(-)
21
22diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
23index 1f467647f5..b62e518030 100644
24--- a/src/cmd/dist/build.go
25+++ b/src/cmd/dist/build.go
26@@ -271,7 +271,9 @@ func xinit() {
27 }
28 xatexit(rmworkdir)
29
30- tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
31+ if tooldir = os.Getenv("GOTOOLDIR"); tooldir == "" {
32+ tooldir = pathf("%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch)
33+ }
34
35 goversion := findgoversion()
36 isRelease = (strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go")) &&
37diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
38index 3b9f27e91d..ec043c1530 100644
39--- a/src/cmd/go/internal/cfg/cfg.go
40+++ b/src/cmd/go/internal/cfg/cfg.go
41@@ -279,7 +279,11 @@ func SetGOROOT(goroot string, isTestGo bool) {
42 // This matches the initialization of ToolDir in go/build, except for
43 // using ctxt.GOROOT and the installed GOOS and GOARCH rather than the
44 // GOROOT, GOOS, and GOARCH reported by the runtime package.
45- build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH)
46+ if s := os.Getenv("GOTOOLDIR"); s != "" {
47+ build.ToolDir = filepath.Clean(s)
48+ } else {
49+ build.ToolDir = filepath.Join(GOROOTpkg, "tool", installedGOOS+"_"+installedGOARCH)
50+ }
51 }
52 }
53 }
54--
552.25.1
56
diff --git a/meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch b/meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch
deleted file mode 100644
index 14ed617dc3..0000000000
--- a/meta/recipes-devtools/go/go/0003-ld-add-soname-to-shareable-objects.patch
+++ /dev/null
@@ -1,51 +0,0 @@
1From 1546d837c69b654754ee137af1fa1c2f7500cfa2 Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Wed, 23 Oct 2019 21:16:32 +0430
4Subject: [PATCH 03/11] ld: add soname to shareable objects
5
6so that OE's shared library dependency handling
7can find them.
8
9Adapted to Go 1.13 from patches originally submitted to
10the meta/recipes-devtools/go tree by
11Matt Madison <matt@madison.systems>.
12
13Upstream-Status: Inappropriate [OE specific]
14
15Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
16Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
17---
18 src/cmd/link/internal/ld/lib.go | 3 +++
19 1 file changed, 3 insertions(+)
20
21diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
22index 2d8f964f35..dfc72e02c0 100644
23--- a/src/cmd/link/internal/ld/lib.go
24+++ b/src/cmd/link/internal/ld/lib.go
25@@ -1628,6 +1628,7 @@ func (ctxt *Link) hostlink() {
26 argv = append(argv, "-Wl,-z,relro")
27 }
28 argv = append(argv, "-shared")
29+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile)))
30 if ctxt.HeadType == objabi.Hwindows {
31 argv = addASLRargs(argv, *flagAslr)
32 } else {
33@@ -1643,6 +1644,7 @@ func (ctxt *Link) hostlink() {
34 argv = append(argv, "-Wl,-z,relro")
35 }
36 argv = append(argv, "-shared")
37+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile)))
38 case BuildModePlugin:
39 if ctxt.HeadType == objabi.Hdarwin {
40 argv = append(argv, "-dynamiclib")
41@@ -1651,6 +1653,7 @@ func (ctxt *Link) hostlink() {
42 argv = append(argv, "-Wl,-z,relro")
43 }
44 argv = append(argv, "-shared")
45+ argv = append(argv, fmt.Sprintf("-Wl,-soname,%s", filepath.Base(*flagOutfile)))
46 }
47 }
48
49--
502.25.1
51
diff --git a/meta/recipes-devtools/go/go/0004-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
deleted file mode 100644
index abbb7bda2b..0000000000
--- a/meta/recipes-devtools/go/go/0004-make.bash-override-CC-when-building-dist-and-go_boot.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From b41aaa851f0074682fcd4bf07c891fbdf0fdf70c Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Sat, 22 Feb 2025 03:14:37 -0800
4Subject: [PATCH 04/11] make.bash: override CC when building dist and
5 go_bootstrap
6
7for handling OE cross-canadian builds.
8
9Adapted to Go 1.13 from patches originally submitted to
10the meta/recipes-devtools/go tree by
11Matt Madison <matt@madison.systems>.
12
13Upstream-Status: Inappropriate [OE specific]
14
15Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
16Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
17
18Rebase to 1.23.4
19Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
20---
21 src/make.bash | 4 ++--
22 1 file changed, 2 insertions(+), 2 deletions(-)
23
24diff --git a/src/make.bash b/src/make.bash
25index b67ae1529f..b59cdabd09 100755
26--- a/src/make.bash
27+++ b/src/make.bash
28@@ -153,7 +153,7 @@ fi
29 export GOROOT_BOOTSTRAP
30
31 bootstrapenv() {
32- GOROOT="$GOROOT_BOOTSTRAP" GO111MODULE=off GOENV=off GOOS= GOARCH= GOEXPERIMENT= GOFLAGS= "$@"
33+ CC="${BUILD_CC:-${CC}}" GOROOT="$GOROOT_BOOTSTRAP" GO111MODULE=off GOENV=off GOOS= GOARCH= GOEXPERIMENT= GOFLAGS= "$@"
34 }
35
36 export GOROOT="$(cd .. && pwd)"
37@@ -216,7 +216,7 @@ fi
38 # Run dist bootstrap to complete make.bash.
39 # Bootstrap installs a proper cmd/dist, built with the new toolchain.
40 # Throw ours, built with the bootstrap toolchain, away after bootstrap.
41-./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@"
42+CC="${BUILD_CC:-${CC}}" ./cmd/dist/dist bootstrap -a $vflag $GO_DISTFLAGS "$@"
43 rm -f ./cmd/dist/dist
44
45 # DO NOT ADD ANY NEW CODE HERE.
46--
472.25.1
48
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
deleted file mode 100644
index 42bfa8eb02..0000000000
--- a/meta/recipes-devtools/go/go/0005-cmd-dist-separate-host-and-target-builds.patch
+++ /dev/null
@@ -1,224 +0,0 @@
1From 12bf824f8b7e85f05434aa00e866e883a551aaeb Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Fri, 28 Feb 2025 19:09:17 -0800
4Subject: [PATCH 05/11] cmd/dist: separate host and target builds
5
6Change the dist tool to allow for OE-style cross-
7and cross-canadian builds:
8
9 - command flags --host-only and --target only are added;
10 if one is present, the other changes mentioned below
11 take effect, and arguments may also be specified on
12 the command line to enumerate the package(s) to be
13 built.
14
15 - for OE cross builds, go_bootstrap is always built for
16 the current build host, and is moved, along with the supporting
17 toolchain (asm, compile, etc.) to a separate 'native_native'
18 directory under GOROOT/pkg/tool.
19
20 - go_bootstrap is not automatically removed after the build,
21 so it can be reused later (e.g., building both static and
22 shared runtime).
23
24Note that for --host-only builds, it would be nice to specify
25just the "cmd" package to build only the go commands/tools,
26the staleness checks in the dist tool will fail if the "std"
27library has not also been built. So host-only builds have to
28build everything anyway.
29
30Adapted to Go 1.13 from patches originally submitted to
31the meta/recipes-devtools/go tree by
32Matt Madison <matt@madison.systems>.
33
34Rework the patch to avoid identation, it breaks formatting rules but
35makes the changes more obvious and maintainable.
36Jose Quaresma <jose.quaresma@foundries.io>
37Richard Purdie <richard.purdie@linuxfoundation.org>
38
39Upstream-Status: Inappropriate [OE specific]
40
41Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
42Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
43
44Rebase to 1.24.0
45Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
46---
47 src/cmd/dist/build.go | 76 ++++++++++++++++++++++++++++++++++++++++++-
48 1 file changed, 75 insertions(+), 1 deletion(-)
49
50diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
51index b62e518030..0c54d82300 100644
52--- a/src/cmd/dist/build.go
53+++ b/src/cmd/dist/build.go
54@@ -50,6 +50,7 @@ var (
55 gofips140 string
56 workdir string
57 tooldir string
58+ build_tooldir string
59 oldgoos string
60 oldgoarch string
61 oldgocache string
62@@ -62,6 +63,7 @@ var (
63 rebuildall bool
64 noOpt bool
65 isRelease bool
66+ crossBuild bool
67
68 vflag int // verbosity
69 )
70@@ -278,6 +280,8 @@ func xinit() {
71 goversion := findgoversion()
72 isRelease = (strings.HasPrefix(goversion, "release.") || strings.HasPrefix(goversion, "go")) &&
73 !strings.Contains(goversion, "devel")
74+
75+ build_tooldir = pathf("%s/pkg/tool/native_native", goroot)
76 }
77
78 // compilerEnv returns a map from "goos/goarch" to the
79@@ -543,8 +547,10 @@ func setup() {
80 goosGoarch := pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch)
81 if rebuildall {
82 xremoveall(goosGoarch)
83+ xremoveall(build_tooldir)
84 }
85 xmkdirall(goosGoarch)
86+ xmkdirall(build_tooldir)
87 xatexit(func() {
88 if files := xreaddir(goosGoarch); len(files) == 0 {
89 xremove(goosGoarch)
90@@ -1420,14 +1426,20 @@ func cmdbootstrap() {
91 defer timelog("end", "dist bootstrap")
92
93 var debug, distpack, force, noBanner, noClean bool
94+ var hostOnly bool
95+ var targetOnly bool
96+ var toBuild = []string{"std", "cmd"}
97+
98 flag.BoolVar(&rebuildall, "a", rebuildall, "rebuild all")
99 flag.BoolVar(&debug, "d", debug, "enable debugging of bootstrap process")
100 flag.BoolVar(&distpack, "distpack", distpack, "write distribution files to pkg/distpack")
101 flag.BoolVar(&force, "force", force, "build even if the port is marked as broken")
102 flag.BoolVar(&noBanner, "no-banner", noBanner, "do not print banner")
103 flag.BoolVar(&noClean, "no-clean", noClean, "print deprecation warning")
104+ flag.BoolVar(&hostOnly, "host-only", hostOnly, "build only host binaries, not target")
105+ flag.BoolVar(&targetOnly, "target-only", targetOnly, "build only target binaries, not host")
106
107- xflagparse(0)
108+ xflagparse(-1)
109
110 if noClean {
111 xprintf("warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead\n")
112@@ -1439,6 +1451,18 @@ func cmdbootstrap() {
113 "Use the -force flag to build anyway.\n", goos, goarch)
114 }
115
116+ if hostOnly && targetOnly {
117+ fatalf("specify only one of --host-only or --target-only\n")
118+ }
119+ crossBuild = hostOnly || targetOnly
120+ if flag.NArg() > 0 {
121+ if crossBuild {
122+ toBuild = flag.Args()
123+ } else {
124+ fatalf("package names not permitted without --host-only or --target-only\n")
125+ }
126+ }
127+
128 // Set GOPATH to an internal directory. We shouldn't actually
129 // need to store files here, since the toolchain won't
130 // depend on modules outside of vendor directories, but if
131@@ -1517,9 +1541,14 @@ func cmdbootstrap() {
132 xprintf("\n")
133 }
134
135+ // For split host/target cross/cross-canadian builds, we don't
136+ // want to be setting these flags until after we have compiled
137+ // the toolchain that runs on the build host.
138+if !crossBuild {
139 gogcflags = os.Getenv("GO_GCFLAGS") // we were using $BOOT_GO_GCFLAGS until now
140 setNoOpt()
141 goldflags = os.Getenv("GO_LDFLAGS") // we were using $BOOT_GO_LDFLAGS until now
142+}
143 goBootstrap := pathf("%s/go_bootstrap", tooldir)
144 if debug {
145 run("", ShowOutput|CheckExit, pathf("%s/compile", tooldir), "-V=full")
146@@ -1547,7 +1576,11 @@ func cmdbootstrap() {
147 xprintf("\n")
148 }
149 xprintf("Building Go toolchain2 using go_bootstrap and Go toolchain1.\n")
150+if !crossBuild {
151 os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch))
152+} else {
153+ os.Setenv("CC", defaultcc[""])
154+}
155 // Now that cmd/go is in charge of the build process, enable GOEXPERIMENT.
156 os.Setenv("GOEXPERIMENT", goexperiment)
157 // No need to enable PGO for toolchain2.
158@@ -1600,6 +1633,7 @@ func cmdbootstrap() {
159 os.Setenv("GOCACHE", oldgocache)
160 }
161
162+if !crossBuild {
163 if goos == oldgoos && goarch == oldgoarch {
164 // Common case - not setting up for cross-compilation.
165 timelog("build", "toolchain")
166@@ -1643,6 +1677,42 @@ func cmdbootstrap() {
167 checkNotStale(toolenv(), goBootstrap, toolchain...)
168 copyfile(pathf("%s/compile4", tooldir), pathf("%s/compile", tooldir), writeExec)
169 }
170+} else {
171+ gogcflags = os.Getenv("GO_GCFLAGS")
172+ goldflags = os.Getenv("GO_LDFLAGS")
173+ tool_files, _ := filepath.Glob(pathf("%s/*", tooldir))
174+ for _, f := range tool_files {
175+ copyfile(pathf("%s/%s", build_tooldir, filepath.Base(f)), f, writeExec)
176+ xremove(f)
177+ }
178+ os.Setenv("GOTOOLDIR", build_tooldir)
179+ goBootstrap = pathf("%s/go_bootstrap", build_tooldir)
180+ if hostOnly {
181+ timelog("build", "host toolchain")
182+ if vflag > 0 {
183+ xprintf("\n")
184+ }
185+ xprintf("Building %s for host, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
186+ goInstall(toolenv(), goBootstrap, toBuild...)
187+ checkNotStale(toolenv(), goBootstrap, toBuild...)
188+ // Skip cmdGo staleness checks here, since we can't necessarily run the cmdGo binary
189+
190+ timelog("build", "target toolchain")
191+ if vflag > 0 {
192+ xprintf("\n")
193+ }
194+ } else if targetOnly {
195+ goos = oldgoos
196+ goarch = oldgoarch
197+ os.Setenv("GOOS", goos)
198+ os.Setenv("GOARCH", goarch)
199+ os.Setenv("CC", compilerEnvLookup("CC", defaultcc, goos, goarch))
200+ xprintf("Building %s for target, %s/%s.\n", strings.Join(toBuild, ","), goos, goarch)
201+ goInstall(toolenv(), goBootstrap, toBuild...)
202+ checkNotStale(toolenv(), goBootstrap, toBuild...)
203+ // Skip cmdGo staleness checks here, since we can't run the target's cmdGo binary
204+ }
205+}
206
207 // Check that there are no new files in $GOROOT/bin other than
208 // go and gofmt and $GOOS_$GOARCH (target bin when cross-compiling).
209@@ -1665,8 +1735,12 @@ func cmdbootstrap() {
210 }
211 }
212
213+ // Except that for split host/target cross-builds, we need to
214+ // keep it.
215+if !crossBuild {
216 // Remove go_bootstrap now that we're done.
217 xremove(pathf("%s/go_bootstrap"+exe, tooldir))
218+}
219
220 if goos == "android" {
221 // Make sure the exec wrapper will sync a fresh $GOROOT to the device.
222--
2232.25.1
224
diff --git a/meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch b/meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch
deleted file mode 100644
index 5117379444..0000000000
--- a/meta/recipes-devtools/go/go/0006-cmd-go-make-GOROOT-precious-by-default.patch
+++ /dev/null
@@ -1,114 +0,0 @@
1From ba3caa9f969bac2b937f8f1ffed4a3679cd16ec7 Mon Sep 17 00:00:00 2001
2From: Alex Kube <alexander.j.kube@gmail.com>
3Date: Wed, 23 Oct 2019 21:18:56 +0430
4Subject: [PATCH 06/11] cmd/go: make GOROOT precious by default
5
6The go build tool normally rebuilds whatever it detects is
7stale. This can be a problem when GOROOT is intended to
8be read-only and the go runtime has been built as a shared
9library, since we don't want every application to be rebuilding
10the shared runtime - particularly in cross-build/packaging
11setups, since that would lead to 'abi mismatch' runtime errors.
12
13This patch prevents the install and linkshared actions from
14installing to GOROOT unless overridden with the GOROOT_OVERRIDE
15environment variable.
16
17Adapted to Go 1.13 from patches originally submitted to
18the meta/recipes-devtools/go tree by
19Matt Madison <matt@madison.systems>.
20
21Upstream-Status: Inappropriate [OE specific]
22
23Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com>
24Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
25---
26 src/cmd/go/internal/work/action.go | 3 +++
27 src/cmd/go/internal/work/build.go | 6 ++++++
28 src/cmd/go/internal/work/exec.go | 25 +++++++++++++++++++++++++
29 3 files changed, 34 insertions(+)
30
31diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
32index 44bb9f8c1e..87ac4e30e5 100644
33--- a/src/cmd/go/internal/work/action.go
34+++ b/src/cmd/go/internal/work/action.go
35@@ -844,6 +844,9 @@ func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) {
36 if p1 == nil || p1.Shlib == "" || haveShlib[filepath.Base(p1.Shlib)] {
37 continue
38 }
39+ if goRootPrecious && (p1.Standard || p1.Goroot) {
40+ continue
41+ }
42 haveShlib[filepath.Base(p1.Shlib)] = true
43 // TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild,
44 // we'll end up building an overall library or executable that depends at runtime
45diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
46index 3508d51fbb..77f5e7241a 100644
47--- a/src/cmd/go/internal/work/build.go
48+++ b/src/cmd/go/internal/work/build.go
49@@ -239,6 +239,8 @@ See also: go install, go get, go clean.
50
51 const concurrentGCBackendCompilationEnabledByDefault = true
52
53+var goRootPrecious bool = true
54+
55 func init() {
56 // break init cycle
57 CmdBuild.Run = runBuild
58@@ -293,6 +295,10 @@ func init() {
59 case "gc", "gccgo":
60 buildCompiler{}.Set(build.Default.Compiler)
61 }
62+
63+ if x := os.Getenv("GOROOT_OVERRIDE"); x != "" {
64+ goRootPrecious = false
65+ }
66 }
67
68 type BuildFlagMask int
69diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
70index 1f618be0bb..651fa64582 100644
71--- a/src/cmd/go/internal/work/exec.go
72+++ b/src/cmd/go/internal/work/exec.go
73@@ -558,6 +558,23 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) {
74 return err
75 }
76
77+ if goRootPrecious && (a.Package.Standard || a.Package.Goroot) {
78+ _, err := os.Stat(a.Package.Target)
79+ if err == nil {
80+ a.built = a.Package.Target
81+ a.Target = a.Package.Target
82+ a.buildID = b.fileHash(a.Package.Target)
83+ a.Package.Stale = false
84+ a.Package.StaleReason = "GOROOT-resident package"
85+ return nil
86+ }
87+ a.Package.Stale = true
88+ a.Package.StaleReason = "missing or invalid GOROOT-resident package"
89+ if b.IsCmdList {
90+ return nil
91+ }
92+ }
93+
94 if err := sh.Mkdir(a.Objdir); err != nil {
95 return err
96 }
97@@ -1731,6 +1748,14 @@ func (b *Builder) linkShared(ctx context.Context, a *Action) (err error) {
98 return err
99 }
100
101+ if goRootPrecious && a.Package != nil {
102+ p := a.Package
103+ if p.Standard || p.Goroot {
104+ err := fmt.Errorf("attempting to install package %s into read-only GOROOT", p.ImportPath)
105+ return err
106+ }
107+ }
108+
109 if err := b.Shell(a).Mkdir(a.Objdir); err != nil {
110 return err
111 }
112--
1132.25.1
114
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
deleted file mode 100644
index 7fe8d9d231..0000000000
--- a/meta/recipes-devtools/go/go/0007-exec.go-filter-out-build-specific-paths-from-linker-.patch
+++ /dev/null
@@ -1,63 +0,0 @@
1From 2197f813c9cff65eedef44473872ec5ea9ced227 Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Tue, 27 Feb 2024 18:06:51 +0800
4Subject: [PATCH 07/11] exec.go: filter out build-specific paths from linker
5 flags
6
7The flags can contain build-specific paths, breaking reproducibility.
8Filter out options that have build-specific paths.
9
10Upstream-Status: Inappropriate [ Not perfect for upstream ]
11
12Signed-off-by: Changqing Li <changqing.li@windriver.com>
13Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
14---
15 src/cmd/go/internal/work/exec.go | 25 ++++++++++++++++++++++++-
16 1 file changed, 24 insertions(+), 1 deletion(-)
17
18diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
19index 651fa64582..586079afb4 100644
20--- a/src/cmd/go/internal/work/exec.go
21+++ b/src/cmd/go/internal/work/exec.go
22@@ -1410,6 +1410,29 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID {
23 return h.Sum()
24 }
25
26+func filterLinkerFlags(flags []string) []string {
27+ var newflags []string
28+ var skipflag bool
29+ skipflag = false
30+ for i, flag := range flags {
31+ if skipflag == true {
32+ skipflag = false
33+ continue
34+ }
35+ 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"){
36+ continue
37+ } else if strings.HasPrefix(flag, "-extldflags") {
38+ skipflag = true
39+ newflags = append(newflags, flag)
40+ var filterd_Extldflags []string = filterLinkerFlags(strings.Split(flags[i+1], " "))
41+ newflags = append(newflags, strings.Join(filterd_Extldflags, " "))
42+ } else {
43+ newflags = append(newflags, flag)
44+ }
45+ }
46+ return newflags
47+}
48+
49 // printLinkerConfig prints the linker config into the hash h,
50 // as part of the computation of a linker-related action ID.
51 func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
52@@ -1420,7 +1443,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
53 case "gc":
54 fmt.Fprintf(h, "link %s %q %s\n", b.toolID("link"), forcedLdflags, ldBuildmode)
55 if p != nil {
56- fmt.Fprintf(h, "linkflags %q\n", p.Internal.Ldflags)
57+ fmt.Fprintf(h, "linkflags %q\n", filterLinkerFlags(p.Internal.Ldflags))
58 }
59
60 // GOARM, GOMIPS, etc.
61--
622.25.1
63
diff --git a/meta/recipes-devtools/go/go/0008-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
deleted file mode 100644
index 59cbff12f8..0000000000
--- a/meta/recipes-devtools/go/go/0008-src-cmd-dist-buildgo.go-do-not-hardcode-host-compile.patch
+++ /dev/null
@@ -1,46 +0,0 @@
1From e5752b239707df8ad7a72dc60420e01c5912d606 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Tue, 10 Nov 2020 16:33:27 +0000
4Subject: [PATCH 08/11] src/cmd/dist/buildgo.go: do not hardcode host compilers
5 into target binaries
6
7These come from $CC/$CXX on the build host and are not useful on targets;
8additionally as they contain host specific paths, this helps reproducibility.
9
10Upstream-Status: Inappropriate [needs upstream discussion]
11
12Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
13Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
14---
15 src/cmd/dist/buildgo.go | 8 ++++----
16 1 file changed, 4 insertions(+), 4 deletions(-)
17
18diff --git a/src/cmd/dist/buildgo.go b/src/cmd/dist/buildgo.go
19index 884e9d729a..2f52edacfe 100644
20--- a/src/cmd/dist/buildgo.go
21+++ b/src/cmd/dist/buildgo.go
22@@ -50,8 +50,8 @@ func mkzdefaultcc(dir, file string) {
23 fmt.Fprintf(&buf, "package cfg\n")
24 fmt.Fprintln(&buf)
25 fmt.Fprintf(&buf, "const DefaultPkgConfig = `%s`\n", defaultpkgconfig)
26- buf.WriteString(defaultCCFunc("DefaultCC", defaultcc))
27- buf.WriteString(defaultCCFunc("DefaultCXX", defaultcxx))
28+ buf.WriteString(defaultCCFunc("DefaultCC", map[string]string{"":"gcc"}))
29+ buf.WriteString(defaultCCFunc("DefaultCXX", map[string]string{"":"g++"}))
30 writefile(buf.String(), file, writeSkipSame)
31 return
32 }
33@@ -61,8 +61,8 @@ func mkzdefaultcc(dir, file string) {
34 fmt.Fprintf(&buf, "package main\n")
35 fmt.Fprintln(&buf)
36 fmt.Fprintf(&buf, "const defaultPkgConfig = `%s`\n", defaultpkgconfig)
37- buf.WriteString(defaultCCFunc("defaultCC", defaultcc))
38- buf.WriteString(defaultCCFunc("defaultCXX", defaultcxx))
39+ buf.WriteString(defaultCCFunc("defaultCC", map[string]string{"":"gcc"}))
40+ buf.WriteString(defaultCCFunc("defaultCXX", map[string]string{"":"g++"}))
41 writefile(buf.String(), file, writeSkipSame)
42 }
43
44--
452.25.1
46
diff --git a/meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch b/meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch
deleted file mode 100644
index 7bb9757d1b..0000000000
--- a/meta/recipes-devtools/go/go/0009-go-Filter-build-paths-on-staticly-linked-arches.patch
+++ /dev/null
@@ -1,61 +0,0 @@
1From 79a1c80ed43f2a541bcab665656a4e2bb87baab3 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Sat, 2 Jul 2022 23:08:13 +0100
4Subject: [PATCH 09/11] go: Filter build paths on staticly linked arches
5
6Filter out build time paths from ldflags and other flags variables when they're
7embedded in the go binary so that builds are reproducible regardless of build
8location. This codepath is hit for statically linked go binaries such as those
9on mips/ppc.
10
11Upstream-Status: Submitted [https://github.com/golang/go/pull/56410]
12
13Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
14Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
15---
16 src/cmd/go/internal/load/pkg.go | 15 +++++++++++++--
17 1 file changed, 13 insertions(+), 2 deletions(-)
18
19diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
20index 15f6b2e87b..47c5b865a1 100644
21--- a/src/cmd/go/internal/load/pkg.go
22+++ b/src/cmd/go/internal/load/pkg.go
23@@ -2313,6 +2313,17 @@ func appendBuildSetting(info *debug.BuildInfo, key, value string) {
24 info.Settings = append(info.Settings, debug.BuildSetting{Key: key, Value: value})
25 }
26
27+func filterCompilerFlags(flags string) string {
28+ var newflags []string
29+ for _, flag := range strings.Fields(flags) {
30+ if strings.HasPrefix(flag, "--sysroot") || strings.HasPrefix(flag, "-fmacro-prefix-map") || strings.HasPrefix(flag, "-fdebug-prefix-map") {
31+ continue
32+ }
33+ newflags = append(newflags, flag)
34+ }
35+ return strings.Join(newflags, " ")
36+}
37+
38 // setBuildInfo gathers build information and sets it into
39 // p.Internal.BuildInfo, which will later be formatted as a string and embedded
40 // in the binary. setBuildInfo should only be called on a main package with no
41@@ -2420,7 +2431,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
42 if gcflags := BuildGcflags.String(); gcflags != "" && cfg.BuildContext.Compiler == "gc" {
43 appendSetting("-gcflags", gcflags)
44 }
45- if ldflags := BuildLdflags.String(); ldflags != "" {
46+ if ldflags := filterCompilerFlags(BuildLdflags.String()); ldflags != "" {
47 // https://go.dev/issue/52372: only include ldflags if -trimpath is not set,
48 // since it can include system paths through various linker flags (notably
49 // -extar, -extld, and -extldflags).
50@@ -2466,7 +2477,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
51 // subset of flags that are known not to be paths?
52 if cfg.BuildContext.CgoEnabled && !cfg.BuildTrimpath {
53 for _, name := range []string{"CGO_CFLAGS", "CGO_CPPFLAGS", "CGO_CXXFLAGS", "CGO_LDFLAGS"} {
54- appendSetting(name, cfg.Getenv(name))
55+ appendSetting(name, filterCompilerFlags(cfg.Getenv(name)))
56 }
57 }
58 appendSetting("GOARCH", cfg.BuildContext.GOARCH)
59--
602.25.1
61
diff --git a/meta/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch b/meta/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch
deleted file mode 100644
index ac70abd90e..0000000000
--- a/meta/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch
+++ /dev/null
@@ -1,50 +0,0 @@
1From c4215b5ca69a7626d97cf9b7ebc460c2b5b9148b Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 28 Feb 2025 19:13:18 -0800
4Subject: [PATCH 10/11] cmd/go: clear GOROOT for func ldShared when -trimpath
5 is used
6
7In commit [cmd: remove support for GOROOT_FINAL][1], it clear GOROOT
8for func ld when -trimpath is used. [2]
9
10This commit do the same thing for func ldShared, otherwise run go_bootstrap
11with -trimpath does not remove build path directory from the generated share
12libarary
13
14 $ ./make.bash --target-only --no-banner std
15 $ go_bootstrap install -linkshared -buildmode=shared -trimpath std
16 $ grep "$(pwd)" ./pkg/linux_amd64_dynlink/libstd.so
17 Binary file ./pkg/linux_amd64_dynlink/libstd.so matches
18
19[1] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98
20[2] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98#diff-cab5921f94f2667bb0bc1b935d2d46b4c03541b4351b33438ab7290b94dea212R669
21
22Upstream-Status: Submitted [https://go-review.googlesource.com/c/go/+/653895]
23
24Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
25---
26 src/cmd/go/internal/work/gc.go | 9 ++++++++-
27 1 file changed, 8 insertions(+), 1 deletion(-)
28
29diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go
30index 3a173efee8..8b7a44e031 100644
31--- a/src/cmd/go/internal/work/gc.go
32+++ b/src/cmd/go/internal/work/gc.go
33@@ -727,7 +727,13 @@ func (gcToolchain) ldShared(b *Builder, root *Action, toplevelactions []*Action,
34 // the output file path is recorded in the .gnu.version_d section.
35 dir, targetPath := filepath.Split(targetPath)
36
37- return b.Shell(root).run(dir, targetPath, cfgChangedEnv, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
38+ // When -trimpath is used, GOROOT is cleared
39+ if cfg.BuildTrimpath {
40+ cfgChangedEnv = append(cfgChangedEnv, "GOROOT=")
41+ } else {
42+ cfgChangedEnv = append(cfgChangedEnv, "GOROOT="+cfg.GOROOT)
43+ }
44+ return b.Shell(root).run(dir, targetPath, cfgChangedEnv, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
45 }
46
47 func (gcToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
48--
492.25.1
50
diff --git a/meta/recipes-devtools/go/go/0011-cmd-link-stop-forcing-binutils-gold-dependency-on-aa.patch b/meta/recipes-devtools/go/go/0011-cmd-link-stop-forcing-binutils-gold-dependency-on-aa.patch
deleted file mode 100644
index 8cf645c097..0000000000
--- a/meta/recipes-devtools/go/go/0011-cmd-link-stop-forcing-binutils-gold-dependency-on-aa.patch
+++ /dev/null
@@ -1,55 +0,0 @@
1From 6d265b008e3d106b2706645e5a88cd8e2fb98953 Mon Sep 17 00:00:00 2001
2From: Dirk Müller <dirk@dmllr.de>
3Date: Wed, 09 Mar 2022 17:47:23 +0100
4Subject: [PATCH 11/11] cmd/link: stop forcing binutils-gold dependency on
5 aarch64
6
7The bfd linker appears to be working just fine at least in version
82.41 or above. Reject the known broken one instead, which
9avoids an architecture specific linker dependency that
10is cumbersome for distributions.
11
12Fixes #22040.
13
14Change-Id: I9f377e47c22ef20497479c0978c053ed5de46a38
15
16Upstream-Status: Submitted [https://go-review.googlesource.com/c/go/+/391115]
17---
18 src/cmd/link/internal/ld/lib.go | 21 ---------------------
19 1 file changed, 21 deletions(-)
20
21diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
22index dfc72e02c0..2a2a304113 100644
23--- a/src/cmd/link/internal/ld/lib.go
24+++ b/src/cmd/link/internal/ld/lib.go
25@@ -1677,27 +1677,6 @@ func (ctxt *Link) hostlink() {
26 // Use lld to avoid errors from default linker (issue #38838)
27 altLinker = "lld"
28 }
29-
30- if ctxt.Arch.InFamily(sys.ARM64) && buildcfg.GOOS == "linux" {
31- // On ARM64, the GNU linker will fail with
32- // -znocopyreloc if it thinks a COPY relocation is
33- // required. Switch to gold.
34- // https://sourceware.org/bugzilla/show_bug.cgi?id=19962
35- // https://go.dev/issue/22040
36- altLinker = "gold"
37-
38- // If gold is not installed, gcc will silently switch
39- // back to ld.bfd. So we parse the version information
40- // and provide a useful error if gold is missing.
41- name, args := flagExtld[0], flagExtld[1:]
42- args = append(args, "-fuse-ld=gold", "-Wl,--version")
43- cmd := exec.Command(name, args...)
44- if out, err := cmd.CombinedOutput(); err == nil {
45- if !bytes.Contains(out, []byte("GNU gold")) {
46- log.Fatalf("ARM64 external linker must be gold (issue #15696, 22040), but is not: %s", out)
47- }
48- }
49- }
50 }
51 if ctxt.Arch.Family == sys.ARM64 && buildcfg.GOOS == "freebsd" {
52 // Switch to ld.bfd on freebsd/arm64.
53--
542.25.1
55
diff --git a/meta/recipes-devtools/go/go_1.25.3.bb b/meta/recipes-devtools/go/go_1.25.3.bb
deleted file mode 100644
index 46f5fbc6be..0000000000
--- a/meta/recipes-devtools/go/go_1.25.3.bb
+++ /dev/null
@@ -1,18 +0,0 @@
1require go-${PV}.inc
2require go-target.inc
3
4inherit linuxloader
5
6CGO_LDFLAGS:append = " -no-pie"
7
8export GO_LDSO = "${@get_linuxloader(d)}"
9export CC_FOR_TARGET = "gcc"
10export CXX_FOR_TARGET = "g++"
11
12# mips/rv64 doesn't support -buildmode=pie, so skip the QA checking for mips/riscv32 and its
13# variants.
14python() {
15 if 'mips' in d.getVar('TARGET_ARCH') or 'riscv32' in d.getVar('TARGET_ARCH'):
16 d.appendVar('INSANE_SKIP:%s' % d.getVar('PN'), " textrel")
17}
18