mirror of https://github.com/golang/go.git
go/build: support Import of local import path in standard library for gccgo
It's possible for a local import path to refer to a standard library package. This was not being correctly handled for gccgo. When using gccgo, change the code to permit the existing lexical test, and to accept a missing directory for a standard package found via a local impor path. Change-Id: Ia9829e55c0ff62e7d1f01a1d6dc9fcff521501ca Reviewed-on: https://go-review.googlesource.com/137439 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
93ad702251
commit
699da6bd13
|
|
@ -544,7 +544,7 @@ func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Packa
|
|||
inTestdata := func(sub string) bool {
|
||||
return strings.Contains(sub, "/testdata/") || strings.HasSuffix(sub, "/testdata") || strings.HasPrefix(sub, "testdata/") || sub == "testdata"
|
||||
}
|
||||
if ctxt.GOROOT != "" && ctxt.Compiler != "gccgo" {
|
||||
if ctxt.GOROOT != "" {
|
||||
root := ctxt.joinPath(ctxt.GOROOT, "src")
|
||||
if sub, ok := ctxt.hasSubdir(root, p.Dir); ok && !inTestdata(sub) {
|
||||
p.Goroot = true
|
||||
|
|
@ -715,6 +715,11 @@ Found:
|
|||
// non-nil *Package returned when an error occurs.
|
||||
// We need to do this before we return early on FindOnly flag.
|
||||
if IsLocalImport(path) && !ctxt.isDir(p.Dir) {
|
||||
if ctxt.Compiler == "gccgo" && p.Goroot {
|
||||
// gccgo has no sources for GOROOT packages.
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// package was not found
|
||||
return p, fmt.Errorf("cannot find package %q in:\n\t%s", path, p.Dir)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue