libgo patch committed: fix go test -i with gccgo

Ian Lance Taylor iant@golang.org
Mon Aug 15 18:05:00 GMT 2016


https://golang.org/issue/16701 points out that `go test -i` fails when
using gccgo.  This patch fixes the problem, by recognizing that the
go/build package will fail to load a standard import when using gccgo.
This is a gccgo-specific patch, because the standard go/build package
does not distinguish standard packages and user-written packages in
this way.  I will leave the issue open to find a better approach in
the future.  This patch bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
-------------- next part --------------
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 239443)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-24e0c4c98e0614b1892316aca787f1c564f2d269
+affb1bf5fcd7abf05993c54313d8000b93a08d4a
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/cmd/go/pkg.go
===================================================================
--- libgo/go/cmd/go/pkg.go	(revision 238662)
+++ libgo/go/cmd/go/pkg.go	(working copy)
@@ -763,6 +763,13 @@ var cgoSyscallExclude = map[string]bool{
 func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package {
 	p.copyBuild(bp)
 
+	// When using gccgo the go/build package will not be able to
+	// find a standard package.  It would be nicer to not get that
+	// error, but go/build doesn't know stdpkg.
+	if runtime.Compiler == "gccgo" && err != nil && p.Standard {
+		err = nil
+	}
+
 	// The localPrefix is the path we interpret ./ imports relative to.
 	// Synthesized main packages sometimes override this.
 	p.localPrefix = dirToImportPath(p.Dir)


More information about the Gcc-patches mailing list