return "", errors.New("cannot import \"main\"")
}
- if base.Ctxt.Pkgpath != "" && path == base.Ctxt.Pkgpath {
+ if base.Ctxt.Pkgpath == "" {
+ panic("missing pkgpath")
+ }
+ if path == base.Ctxt.Pkgpath {
return "", fmt.Errorf("import %q while compiling that package (import cycle)", path)
}
// user didn't provide one.
target = objabi.PathToPrefix(base.Ctxt.Pkgpath) + "." + f[1]
} else {
- p.error(syntax.Error{Pos: pos, Msg: "//go:linkname requires linkname argument or -p compiler flag"})
- break
+ panic("missing pkgpath")
}
p.linknames = append(p.linknames, linkname{pos, f[1], target})
}
if pkg == types.LocalPkg && base.Ctxt.Pkgpath == "" {
- // If we don't know the full import path of the package being compiled
- // (i.e. -p was not passed on the compiler command line), emit a reference to
- // type:.importpath.""., which the linker will rewrite using the correct import path.
- // Every package that imports this one directly defines the symbol.
- // See also https://groups.google.com/forum/#!topic/golang-dev/myb9s53HxGQ.
- ns := base.Ctxt.Lookup(`type:.importpath."".`)
- return objw.SymPtr(s, ot, ns, 0)
+ panic("missing pkgpath")
}
dimportpath(pkg)
return objw.Uint32(s, ot, 0)
}
if pkg == types.LocalPkg && base.Ctxt.Pkgpath == "" {
- // If we don't know the full import path of the package being compiled
- // (i.e. -p was not passed on the compiler command line), emit a reference to
- // type:.importpath.""., which the linker will rewrite using the correct import path.
- // Every package that imports this one directly defines the symbol.
- // See also https://groups.google.com/forum/#!topic/golang-dev/myb9s53HxGQ.
- ns := base.Ctxt.Lookup(`type:.importpath."".`)
- return objw.SymPtrOff(s, ot, ns)
+ panic("missing pkgpath")
}
dimportpath(pkg)
}
}
} else {
- sname = fmt.Sprintf(`%s"".%d`, sname, dnameCount)
+ // TODO(mdempsky): We should be able to share these too (except
+ // maybe when dynamic linking).
+ sname = fmt.Sprintf("%s%s.%d", sname, types.LocalPkg.Prefix, dnameCount)
dnameCount++
}
if embedded {
}
func isAtomicStdPkg(p *Pkg) bool {
- return (p.Prefix == "sync/atomic" || p.Prefix == `""` && base.Ctxt.Pkgpath == "sync/atomic") ||
- (p.Prefix == "runtime/internal/atomic" || p.Prefix == `""` && base.Ctxt.Pkgpath == "runtime/internal/atomic")
+ if p.Prefix == `""` {
+ panic("bad package prefix")
+ }
+ return p.Prefix == "sync/atomic" || p.Prefix == "runtime/internal/atomic"
}
// CalcSize calculates and stores the size and alignment for t.