This patch changes libgo so that the cmd/go TestScript test passes down the newly built gccgo in TestScript. This permits TestScript to work when gccgo is not installed. Previous testing was using a previously installed gccgo, not the newly built one.
This revealed that the testing of whether an internal package is permitted was incorrect for standard library packages, since the uninstalled gccgo can see internal packages in the uninstalled libgo. This patch fixes the internal package tests. This permitted removing a couple of gccgo-specific changes in the testsuite. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 264546) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -7b25b4dff4778fc4d6b5d6e10594814146b3e5dd +1dbc5b805a1665079008d1ce341991c3554c1eeb 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/internal/load/pkg.go =================================================================== --- libgo/go/cmd/go/internal/load/pkg.go (revision 264546) +++ libgo/go/cmd/go/internal/load/pkg.go (working copy) @@ -953,8 +953,14 @@ func disallowInternal(srcDir string, imp } // We can't check standard packages with gccgo. - if cfg.BuildContext.Compiler == "gccgo" && p.Standard { - return p + if cfg.BuildContext.Compiler == "gccgo" { + if importer == nil { + if p.Standard { + return p + } + } else if importer.Standard || strings.HasPrefix(importerPath, "cmd/") { + return p + } } // The stack includes p.ImportPath. Index: libgo/go/cmd/go/script_test.go =================================================================== --- libgo/go/cmd/go/script_test.go (revision 264546) +++ libgo/go/cmd/go/script_test.go (working copy) @@ -78,6 +78,7 @@ var extraEnvKeys = []string{ // For gccgo testing. "GO_TESTING_GOTOOLS", + "GCCGO", "GCCGOTOOLDIR", } Index: libgo/go/cmd/go/testdata/script/mod_internal.txt =================================================================== --- libgo/go/cmd/go/testdata/script/mod_internal.txt (revision 264546) +++ libgo/go/cmd/go/testdata/script/mod_internal.txt (working copy) @@ -16,11 +16,11 @@ stderr 'use of internal package golang.o # Internal packages in the standard library should not leak into modules. ! go build ./fromstd -[!gccgo] stderr 'use of internal package internal/testenv not allowed' +stderr 'use of internal package internal/testenv not allowed' # Packages found via standard-library vendoring should not leak. ! go build ./fromstdvendor -[!gccgo] stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' +stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' env GO111MODULE=off ! go build ./fromstdvendor