"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssa"
"cmd/compile/internal/ssagen"
- "cmd/compile/internal/staticdata"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/compile/internal/walk"
typecheck.Target = new(ir.Package)
- typecheck.NeedFuncSym = staticdata.NeedFuncSym
typecheck.NeedITab = func(t, iface *types.Type) { reflectdata.ITabAddr(t, iface) }
typecheck.NeedRuntimeType = reflectdata.NeedRuntimeType // TODO(rsc): typenamesym for lock?
"cmd/compile/internal/base"
"cmd/compile/internal/escape"
"cmd/compile/internal/ir"
+ "cmd/compile/internal/staticdata"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
// For body-less functions, we only create the LSym; for functions
// with bodies call a helper to setup up / populate the LSym.
func InitLSym(f *ir.Func, hasBody bool) {
+ staticdata.NeedFuncSym(f.Sym())
+
// FIXME: for new-style ABI wrappers, we set up the lsym at the
// point the wrapper is created.
if f.LSym != nil && base.Flag.ABIWrap {
// makes calls to helpers to create ABI wrappers if needed.
func selectLSym(f *ir.Func, hasBody bool) {
if f.LSym != nil {
- base.Fatalf("Func.initLSym called twice")
+ base.FatalfAt(f.Pos(), "Func.initLSym called twice on %v", f)
}
if nam := f.Nname; !ir.IsBlank(nam) {
return FuncSym(n.Sym()).Linksym()
}
-// NeedFuncSym ensures that s·f is exported.
+// NeedFuncSym ensures that s·f is exported, if needed.
// It is only used with -dynlink.
// When not compiling for dynamic linking,
// the funcsyms are created as needed by
// So instead, when dynamic linking, we only create
// the s·f stubs in s's package.
func NeedFuncSym(s *types.Sym) {
+ if base.Ctxt.InParallel {
+ // The append below probably just needs to lock
+ // funcsymsmu, like in FuncSym.
+ base.Fatalf("NeedFuncSym must be called in serial")
+ }
if !base.Ctxt.Flag_dynlink {
- base.Fatalf("NeedFuncSym: dynlink")
+ return
}
if s.IsBlank() {
return
// get funcsyms.
return
}
- if _, existed := s.Pkg.LookupOK(ir.FuncSymName(s)); !existed {
- funcsyms = append(funcsyms, s)
- }
+ funcsyms = append(funcsyms, s)
}
func WriteFuncSyms() {
n.Nname.SetSym(ir.MethodSym(rcvr.Type, n.Shortname))
Declare(n.Nname, ir.PFUNC)
}
-
- if base.Ctxt.Flag_dynlink && !inimport && n.Nname != nil {
- NeedFuncSym(n.Sym())
- }
}
// tcCall typechecks an OCALL node.
var TypecheckAllowed bool
var (
- NeedFuncSym = func(*types.Sym) {}
NeedITab = func(t, itype *types.Type) {}
NeedRuntimeType = func(*types.Type) {}
)
n.SetOp(ir.OMETHEXPR)
n.Selection = m
n.SetType(NewMethodType(m.Type, n.X.Type()))
-
- // Issue 25065. Make sure that we emit the symbol for a local method.
- if base.Ctxt.Flag_dynlink && !inimport && (t.Sym() == nil || t.Sym().Pkg == types.LocalPkg) {
- NeedFuncSym(n.FuncName().Sym())
- }
-
return n
}