mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: eliminate fallback code for missing -p flag
cmd/compile has required the -p flag since go.dev/cl/391014. It's safe to eliminate the fallback code that tried to cope without. Change-Id: I9a62ff829e34a6fa5bfe6ae6a836610cc3f0cd33 Reviewed-on: https://go-review.googlesource.com/c/go/+/523337 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
22f9e0ef52
commit
cf338eb890
6 changed files with 16 additions and 24 deletions
|
|
@ -524,9 +524,7 @@ func createComplexVar(fnsym *obj.LSym, fn *ir.Func, varID ssa.VarID) *dwarf.Var
|
||||||
// in the DWARF info.
|
// in the DWARF info.
|
||||||
func RecordFlags(flags ...string) {
|
func RecordFlags(flags ...string) {
|
||||||
if base.Ctxt.Pkgpath == "" {
|
if base.Ctxt.Pkgpath == "" {
|
||||||
// We can't record the flags if we don't know what the
|
panic("missing pkgpath")
|
||||||
// package name is.
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BoolFlag interface {
|
type BoolFlag interface {
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,10 @@ func resolveImportPath(path string) (string, error) {
|
||||||
return "", errors.New("cannot import \"main\"")
|
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)
|
return "", fmt.Errorf("import %q while compiling that package (import cycle)", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,8 +265,7 @@ func (p *noder) pragma(pos syntax.Pos, blankLine bool, text string, old syntax.P
|
||||||
// user didn't provide one.
|
// user didn't provide one.
|
||||||
target = objabi.PathToPrefix(base.Ctxt.Pkgpath) + "." + f[1]
|
target = objabi.PathToPrefix(base.Ctxt.Pkgpath) + "." + f[1]
|
||||||
} else {
|
} else {
|
||||||
p.error(syntax.Error{Pos: pos, Msg: "//go:linkname requires linkname argument or -p compiler flag"})
|
panic("missing pkgpath")
|
||||||
break
|
|
||||||
}
|
}
|
||||||
p.linknames = append(p.linknames, linkname{pos, f[1], target})
|
p.linknames = append(p.linknames, linkname{pos, f[1], target})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -432,13 +432,7 @@ func dgopkgpath(s *obj.LSym, ot int, pkg *types.Pkg) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if pkg == types.LocalPkg && base.Ctxt.Pkgpath == "" {
|
if pkg == types.LocalPkg && base.Ctxt.Pkgpath == "" {
|
||||||
// If we don't know the full import path of the package being compiled
|
panic("missing pkgpath")
|
||||||
// (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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dimportpath(pkg)
|
dimportpath(pkg)
|
||||||
|
|
@ -451,13 +445,7 @@ func dgopkgpathOff(s *obj.LSym, ot int, pkg *types.Pkg) int {
|
||||||
return objw.Uint32(s, ot, 0)
|
return objw.Uint32(s, ot, 0)
|
||||||
}
|
}
|
||||||
if pkg == types.LocalPkg && base.Ctxt.Pkgpath == "" {
|
if pkg == types.LocalPkg && base.Ctxt.Pkgpath == "" {
|
||||||
// If we don't know the full import path of the package being compiled
|
panic("missing pkgpath")
|
||||||
// (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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dimportpath(pkg)
|
dimportpath(pkg)
|
||||||
|
|
@ -546,7 +534,9 @@ func dname(name, tag string, pkg *types.Pkg, exported, embedded bool) *obj.LSym
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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++
|
dnameCount++
|
||||||
}
|
}
|
||||||
if embedded {
|
if embedded {
|
||||||
|
|
|
||||||
|
|
@ -195,8 +195,10 @@ func calcStructOffset(t *Type, fields []*Field, offset int64) int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAtomicStdPkg(p *Pkg) bool {
|
func isAtomicStdPkg(p *Pkg) bool {
|
||||||
return (p.Prefix == "sync/atomic" || p.Prefix == `""` && base.Ctxt.Pkgpath == "sync/atomic") ||
|
if p.Prefix == `""` {
|
||||||
(p.Prefix == "runtime/internal/atomic" || p.Prefix == `""` && base.Ctxt.Pkgpath == "runtime/internal/atomic")
|
panic("bad package prefix")
|
||||||
|
}
|
||||||
|
return p.Prefix == "sync/atomic" || p.Prefix == "runtime/internal/atomic"
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcSize calculates and stores the size and alignment for t.
|
// CalcSize calculates and stores the size and alignment for t.
|
||||||
|
|
|
||||||
|
|
@ -1507,7 +1507,7 @@ func isFuncPCIntrinsic(n *ir.CallExpr) bool {
|
||||||
}
|
}
|
||||||
fn := n.X.(*ir.Name).Sym()
|
fn := n.X.(*ir.Name).Sym()
|
||||||
return (fn.Name == "FuncPCABI0" || fn.Name == "FuncPCABIInternal") &&
|
return (fn.Name == "FuncPCABI0" || fn.Name == "FuncPCABIInternal") &&
|
||||||
(fn.Pkg.Path == "internal/abi" || fn.Pkg == types.LocalPkg && base.Ctxt.Pkgpath == "internal/abi")
|
fn.Pkg.Path == "internal/abi"
|
||||||
}
|
}
|
||||||
|
|
||||||
// isIfaceOfFunc returns whether n is an interface conversion from a direct reference of a func.
|
// isIfaceOfFunc returns whether n is an interface conversion from a direct reference of a func.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue