diff options
author | Jose Quaresma <quaresma.jose@gmail.com> | 2023-03-22 11:19:19 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-03-23 22:36:46 +0000 |
commit | d5c79ca6a77af1a04992fff4300333e02d94d84d (patch) | |
tree | 146f5cba0a56989cc0a6c6a337520f4396d2851c /meta/recipes-devtools/go | |
parent | 1908193b81a1a5dbe04ccf296c2daa15bfac7000 (diff) | |
download | poky-d5c79ca6a77af1a04992fff4300333e02d94d84d.tar.gz |
go: fix some linkshared regression introduced in go 1.20
Since go 1.20 some packages fails to link [1][2]
and only build staticaly with GO_LINKSHARED = ""
[1] https://lists.yoctoproject.org/g/meta-virtualization/topic/97182310
[2] https://github.com/golang/go/issues/58966
(From OE-Core rev: eb40d6c2ef72814336365208722e2dc96322e07d)
Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
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.20.1.inc | 1 | ||||
-rw-r--r-- | meta/recipes-devtools/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch | 90 |
2 files changed, 91 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.20.1.inc b/meta/recipes-devtools/go/go-1.20.1.inc index aa3e2dadf1..ffde7ed732 100644 --- a/meta/recipes-devtools/go/go-1.20.1.inc +++ b/meta/recipes-devtools/go/go-1.20.1.inc | |||
@@ -14,5 +14,6 @@ SRC_URI += "\ | |||
14 | file://0007-exec.go-do-not-write-linker-flags-into-buildids.patch \ | 14 | file://0007-exec.go-do-not-write-linker-flags-into-buildids.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-compile-re-compile-instantiated-generic-methods-.patch \ | ||
17 | " | 18 | " |
18 | SRC_URI[main.sha256sum] = "b5c1a3af52c385a6d1c76aed5361cf26459023980d0320de7658bae3915831a2" | 19 | SRC_URI[main.sha256sum] = "b5c1a3af52c385a6d1c76aed5361cf26459023980d0320de7658bae3915831a2" |
diff --git a/meta/recipes-devtools/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch b/meta/recipes-devtools/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch new file mode 100644 index 0000000000..f9ac202421 --- /dev/null +++ b/meta/recipes-devtools/go/go/0010-cmd-compile-re-compile-instantiated-generic-methods-.patch | |||
@@ -0,0 +1,90 @@ | |||
1 | From 7a3bb16b43efba73674629eae4369f9004e37f22 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cuong Manh Le <cuong.manhle.vn@gmail.com> | ||
3 | Date: Sat, 18 Mar 2023 00:53:07 +0700 | ||
4 | Subject: [PATCH] cmd/compile: re-compile instantiated generic methods in | ||
5 | linkshared mode | ||
6 | |||
7 | For G[T] that was seen and compiled in imported package, it is not added | ||
8 | to typecheck.Target.Decls, prevent wasting compile time re-creating | ||
9 | DUPOKS symbols. However, the linker do not support a type symbol | ||
10 | referencing a method symbol across DSO boundary. That causes unreachable | ||
11 | sym error when building under -linkshared mode. | ||
12 | |||
13 | To fix it, always re-compile generic methods in linkshared mode. | ||
14 | |||
15 | Fixes #58966 | ||
16 | |||
17 | Change-Id: I894b417cfe8234ae1fe809cc975889345df22cef | ||
18 | Reviewed-on: https://go-review.googlesource.com/c/go/+/477375 | ||
19 | Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> | ||
20 | Reviewed-by: Cherry Mui <cherryyz@google.com> | ||
21 | Reviewed-by: Matthew Dempsky <mdempsky@google.com> | ||
22 | TryBot-Result: Gopher Robot <gobot@golang.org> | ||
23 | |||
24 | Upstream-Status: Backport [https://github.com/golang/go/commit/bcd82125f85c7c552493e863fa1bb14e6c444557] | ||
25 | |||
26 | Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> | ||
27 | --- | ||
28 | misc/cgo/testshared/shared_test.go | 7 ++++++- | ||
29 | misc/cgo/testshared/testdata/issue58966/main.go | 15 +++++++++++++++ | ||
30 | src/cmd/compile/internal/noder/unified.go | 6 +++++- | ||
31 | 3 files changed, 26 insertions(+), 2 deletions(-) | ||
32 | create mode 100644 misc/cgo/testshared/testdata/issue58966/main.go | ||
33 | |||
34 | diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go | ||
35 | index b14fb1cb3a..03da8f9435 100644 | ||
36 | --- a/misc/cgo/testshared/shared_test.go | ||
37 | +++ b/misc/cgo/testshared/shared_test.go | ||
38 | @@ -1112,8 +1112,13 @@ func TestStd(t *testing.T) { | ||
39 | t.Skip("skip in short mode") | ||
40 | } | ||
41 | t.Parallel() | ||
42 | + tmpDir := t.TempDir() | ||
43 | // Use a temporary pkgdir to not interfere with other tests, and not write to GOROOT. | ||
44 | // Cannot use goCmd as it runs with cloned GOROOT which is incomplete. | ||
45 | runWithEnv(t, "building std", []string{"GOROOT=" + oldGOROOT}, | ||
46 | - filepath.Join(oldGOROOT, "bin", "go"), "install", "-buildmode=shared", "-pkgdir="+t.TempDir(), "std") | ||
47 | + filepath.Join(oldGOROOT, "bin", "go"), "install", "-buildmode=shared", "-pkgdir="+tmpDir, "std") | ||
48 | + | ||
49 | + // Issue #58966. | ||
50 | + runWithEnv(t, "testing issue #58966", []string{"GOROOT=" + oldGOROOT}, | ||
51 | + filepath.Join(oldGOROOT, "bin", "go"), "run", "-linkshared", "-pkgdir="+tmpDir, "./issue58966/main.go") | ||
52 | } | ||
53 | diff --git a/misc/cgo/testshared/testdata/issue58966/main.go b/misc/cgo/testshared/testdata/issue58966/main.go | ||
54 | new file mode 100644 | ||
55 | index 0000000000..2d923c3607 | ||
56 | --- /dev/null | ||
57 | +++ b/misc/cgo/testshared/testdata/issue58966/main.go | ||
58 | @@ -0,0 +1,15 @@ | ||
59 | +// Copyright 2023 The Go Authors. All rights reserved. | ||
60 | +// Use of this source code is governed by a BSD-style | ||
61 | +// license that can be found in the LICENSE file. | ||
62 | + | ||
63 | +package main | ||
64 | + | ||
65 | +import "crypto/elliptic" | ||
66 | + | ||
67 | +var curve elliptic.Curve | ||
68 | + | ||
69 | +func main() { | ||
70 | + switch curve { | ||
71 | + case elliptic.P224(): | ||
72 | + } | ||
73 | +} | ||
74 | diff --git a/src/cmd/compile/internal/noder/unified.go b/src/cmd/compile/internal/noder/unified.go | ||
75 | index ed97a09302..25136e6aad 100644 | ||
76 | --- a/src/cmd/compile/internal/noder/unified.go | ||
77 | +++ b/src/cmd/compile/internal/noder/unified.go | ||
78 | @@ -158,7 +158,11 @@ func readBodies(target *ir.Package, duringInlining bool) { | ||
79 | // Instantiated generic function: add to Decls for typechecking | ||
80 | // and compilation. | ||
81 | if fn.OClosure == nil && len(pri.dict.targs) != 0 { | ||
82 | - if duringInlining { | ||
83 | + // cmd/link does not support a type symbol referencing a method symbol | ||
84 | + // across DSO boundary, so force re-compiling methods on a generic type | ||
85 | + // even it was seen from imported package in linkshared mode, see #58966. | ||
86 | + canSkipNonGenericMethod := !(base.Ctxt.Flag_linkshared && ir.IsMethod(fn)) | ||
87 | + if duringInlining && canSkipNonGenericMethod { | ||
88 | inlDecls = append(inlDecls, fn) | ||
89 | } else { | ||
90 | target.Decls = append(target.Decls, fn) | ||