summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2025-03-01 15:55:51 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-03 18:01:29 +0000
commitef1d0dea7bb330f1169e16e387df4a3ae30a4529 (patch)
tree545bf0ec1f18b2c065303a4fedf7e18c7a8936cd
parent4674fc9f7cd3fcc0af41a266f4b24c3f18613af7 (diff)
downloadpoky-ef1d0dea7bb330f1169e16e387df4a3ae30a4529.tar.gz
go: fix buildpath issue for go-runtime
In upstream commit [cmd: remove support for GOROOT_FINAL][1], it clear GOROOT for func ld when -trimpath is used But it missed to do the same thing for share libarary linking which caused building go-runtime failed with buildpath issue |ERROR: go-runtime-1.23.4-r0 do_package_qa: QA Issue: File /usr/lib/go/pkg/ linux_amd64_dynlink/libstd.so in package go-runtime contains reference to TMPDIR [buildpaths] This commit applied a patch to clear GOROOT for func ldShared when -trimpath is used and add option -trimpath to go-runtime build [1] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98 [2] https://github.com/golang/go/commit/507d1b22f4b58ac68841582d0c2c0ab6b20e5a98#diff-cab5921f94f2667bb0bc1b935d2d46b4c03541b4351b33438ab7290b94dea212R669 (From OE-Core rev: f7b05ebfdc6504a8360741f273163ef7fbb11b10) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/go/go-1.24.0.inc1
-rw-r--r--meta/recipes-devtools/go/go-runtime.inc2
-rw-r--r--meta/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch51
3 files changed, 53 insertions, 1 deletions
diff --git a/meta/recipes-devtools/go/go-1.24.0.inc b/meta/recipes-devtools/go/go-1.24.0.inc
index 26a4947caf..a52dd19e76 100644
--- a/meta/recipes-devtools/go/go-1.24.0.inc
+++ b/meta/recipes-devtools/go/go-1.24.0.inc
@@ -14,6 +14,7 @@ SRC_URI += "\
14 file://0007-exec.go-filter-out-build-specific-paths-from-linker-.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 \ 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 \ 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 \
17 file://6d265b008e3d106b2706645e5a88cd8e2fb98953.patch \ 18 file://6d265b008e3d106b2706645e5a88cd8e2fb98953.patch \
18" 19"
19SRC_URI[main.sha256sum] = "d14120614acb29d12bcab72bd689f257eb4be9e0b6f88a8fb7e41ac65f8556e5" 20SRC_URI[main.sha256sum] = "d14120614acb29d12bcab72bd689f257eb4be9e0b6f88a8fb7e41ac65f8556e5"
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
index 413cf6d33f..e5f17337bc 100644
--- a/meta/recipes-devtools/go/go-runtime.inc
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -34,7 +34,7 @@ do_compile() {
34 if [ -n "${GO_DYNLINK}" ]; then 34 if [ -n "${GO_DYNLINK}" ]; then
35 export GOTOOLDIR="${B}/pkg/tool/native_native" 35 export GOTOOLDIR="${B}/pkg/tool/native_native"
36 CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ 36 CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \
37 $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std 37 $GOTOOLDIR/go_bootstrap install -linkshared -trimpath -buildmode=shared ${GO_SHLIB_LDFLAGS} std
38 fi 38 fi
39 cd ${B} 39 cd ${B}
40} 40}
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
new file mode 100644
index 0000000000..2c2f0cbfb5
--- /dev/null
+++ b/meta/recipes-devtools/go/go/0010-cmd-go-clear-GOROOT-for-func-ldShared-when-trimpath-.patch
@@ -0,0 +1,51 @@
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@@ -728,7 +728,14 @@ 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, nil, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
38+ env := []string{}
39+ // When -trimpath is used, GOROOT is cleared
40+ if cfg.BuildTrimpath {
41+ env = append(env, "GOROOT=")
42+ } else {
43+ env = append(env, "GOROOT="+cfg.GOROOT)
44+ }
45+ return b.Shell(root).run(dir, targetPath, env, cfg.BuildToolexec, base.Tool("link"), "-o", targetPath, "-importcfg", importcfg, ldflags)
46 }
47
48 func (gcToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
49--
502.25.1
51