From 1b85e7c057e0ac20881099eee036cef1d7f2fbb0 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 4 Jan 2021 14:24:40 -0800 Subject: [PATCH] cmd/go: don't scan gccgo standard library packages for imports In a gccgo installation the standard library sources are not available. Change-Id: I929f3645e3ac95a1fa7047d6a3d243159a86ba66 Reviewed-on: https://go-review.googlesource.com/c/go/+/281493 Trust: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Jay Conrod Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modload/load.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index 27f47fad4d3558..9a8b0cf177abe0 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -1083,14 +1083,21 @@ func (ld *loader) load(pkg *loadPkg) { } } - imports, testImports, err := scanDir(pkg.dir, ld.Tags) - if err != nil { - pkg.err = err - return - } - pkg.inStd = (search.IsStandardImportPath(pkg.path) && search.InDir(pkg.dir, cfg.GOROOTsrc) != "") + var imports, testImports []string + + if cfg.BuildContext.Compiler == "gccgo" && pkg.inStd { + // We can't scan standard packages for gccgo. + } else { + var err error + imports, testImports, err = scanDir(pkg.dir, ld.Tags) + if err != nil { + pkg.err = err + return + } + } + pkg.imports = make([]*loadPkg, 0, len(imports)) var importFlags loadPkgFlags if pkg.flags.has(pkgInAll) {