mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: re-compile instantiated generic methods in linkshared mode
For G[T] that was seen and compiled in imported package, it is not added to typecheck.Target.Decls, prevent wasting compile time re-creating DUPOKS symbols. However, the linker do not support a type symbol referencing a method symbol across DSO boundary. That causes unreachable sym error when building under -linkshared mode. To fix it, always re-compile generic methods in linkshared mode. Fixes #58966 Change-Id: I894b417cfe8234ae1fe809cc975889345df22cef Reviewed-on: https://go-review.googlesource.com/c/go/+/477375 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
f17e7e8441
commit
bcd82125f8
3 changed files with 26 additions and 2 deletions
|
|
@ -158,7 +158,11 @@ func readBodies(target *ir.Package, duringInlining bool) {
|
|||
// Instantiated generic function: add to Decls for typechecking
|
||||
// and compilation.
|
||||
if fn.OClosure == nil && len(pri.dict.targs) != 0 {
|
||||
if duringInlining {
|
||||
// cmd/link does not support a type symbol referencing a method symbol
|
||||
// across DSO boundary, so force re-compiling methods on a generic type
|
||||
// even it was seen from imported package in linkshared mode, see #58966.
|
||||
canSkipNonGenericMethod := !(base.Ctxt.Flag_linkshared && ir.IsMethod(fn))
|
||||
if duringInlining && canSkipNonGenericMethod {
|
||||
inlDecls = append(inlDecls, fn)
|
||||
} else {
|
||||
target.Decls = append(target.Decls, fn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue