PR 65462 points out a problem with the way that the gccgo version of
go get handles dependencies, a problem due to the fact that with gccgo
the source code of the standard packages is not normally available.
This patch from Lynn Boger fixes the problem.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

gotools/ChangeLog:

2015-03-24  Ian Lance Taylor  <i...@google.com>

PR go/65462
* Makefile.am (go_cmd_go_files): Add $(libgodir)/zstdpkglist.go.
* Makefile.in: Rebuild.
Index: libgo/Makefile.am
===================================================================
--- libgo/Makefile.am   (revision 221440)
+++ libgo/Makefile.am   (working copy)
@@ -978,6 +978,20 @@ s-version: Makefile
        $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
        $(STAMP) $@
 
+noinst_DATA = zstdpkglist.go
+
+# Generate the list of go std packages that were included in libgo
+zstdpkglist.go: s-zstdpkglist; @true
+s-zstdpkglist: Makefile
+       rm -f zstdpkglist.go.tmp
+       echo 'package main' > zstdpkglist.go.tmp
+       echo "" >> zstdpkglist.go.tmp
+       echo 'var stdpkg = map[string]bool{' >> zstdpkglist.go.tmp
+       echo $(libgo_go_objs) 'unsafe.lo' | sed 's/\.lo /\": true,\n/g' | sed 
's/\.lo/\": true,/' | sed 's/-go//' | grep -v _c | sed 's/^/\t\"/' | sort | 
uniq >> zstdpkglist.go.tmp
+       echo '}' >> zstdpkglist.go.tmp
+       $(SHELL) $(srcdir)/mvifdiff.sh zstdpkglist.go.tmp zstdpkglist.go
+       $(STAMP) $@
+
 go_sort_files = \
        go/sort/search.go \
        go/sort/sort.go
Index: libgo/go/cmd/go/build.go
===================================================================
--- libgo/go/cmd/go/build.go    (revision 221440)
+++ libgo/go/cmd/go/build.go    (working copy)
@@ -132,7 +132,8 @@ var buildLdflags []string    // -ldflags
 var buildGccgoflags []string // -gccgoflags flag
 var buildRace bool           // -race flag
 
-var reqPkgSrc bool // req src for Imports
+// Require the source for go std packages
+var reqStdPkgSrc bool
 var buildContext = build.Default
 var buildToolchain toolchain = noToolchain{}
 
@@ -187,9 +188,9 @@ func addBuildFlags(cmd *Command) {
        cmd.Flag.BoolVar(&buildRace, "race", false, "")
        switch build.Default.Compiler {
        case "gc":
-               reqPkgSrc = true
+               reqStdPkgSrc = true
        case "gccgo":
-               reqPkgSrc = false
+               reqStdPkgSrc = false
        }
 }
 
@@ -579,7 +580,7 @@ func (b *builder) action(mode buildMode,
        // are writing is not the cgo we need to use.
 
        if goos == runtime.GOOS && goarch == runtime.GOARCH && !buildRace {
-               if reqPkgSrc {
+               if reqStdPkgSrc {
                        if len(p.CgoFiles) > 0 || p.Standard && p.ImportPath == 
"runtime/cgo" {
                                var stk importStack
                                p1 := loadPackage("cmd/cgo", &stk)
Index: libgo/go/cmd/go/pkg.go
===================================================================
--- libgo/go/cmd/go/pkg.go      (revision 221440)
+++ libgo/go/cmd/go/pkg.go      (working copy)
@@ -112,7 +112,11 @@ func (p *Package) copyBuild(pp *build.Pa
        p.ConflictDir = pp.ConflictDir
        // TODO? Target
        p.Goroot = pp.Goroot
-       p.Standard = p.Goroot && p.ImportPath != "" && 
!strings.Contains(p.ImportPath, ".")
+       if buildContext.Compiler == "gccgo" {
+               p.Standard = stdpkg[p.ImportPath]
+       } else {
+               p.Standard = p.Goroot && p.ImportPath != "" && 
!strings.Contains(p.ImportPath, ".")
+       }
        p.GoFiles = pp.GoFiles
        p.CgoFiles = pp.CgoFiles
        p.IgnoredGoFiles = pp.IgnoredGoFiles
@@ -582,7 +586,7 @@ func (p *Package) load(stk *importStack,
                        continue
                }
                p1 := loadImport(path, p.Dir, stk, p.build.ImportPos[path])
-               if !reqPkgSrc && p1.Root == "" {
+               if !reqStdPkgSrc && p1.Standard {
                        continue
                }
                if p1.local {
Index: libgo/go/cmd/go/test.go
===================================================================
--- libgo/go/cmd/go/test.go     (revision 221440)
+++ libgo/go/cmd/go/test.go     (working copy)
@@ -384,17 +384,18 @@ func runTest(cmd *Command, args []string
                delete(deps, "unsafe")
 
                all := []string{}
-               if reqPkgSrc {
-                       for path := range deps {
-                               if !build.IsLocalImport(path) {
-                                       all = append(all, path)
-                               }
+               for path := range deps {
+                       if !build.IsLocalImport(path) {
+                               all = append(all, path)
                        }
                }
                sort.Strings(all)
 
                a := &action{}
                for _, p := range packagesForBuild(all) {
+                       if !reqStdPkgSrc && p.Standard {
+                               continue
+                       }
                        a.deps = append(a.deps, b.action(modeInstall, 
modeInstall, p))
                }
                b.do(a)
@@ -563,7 +564,7 @@ func (b *builder) test(p *Package) (buil
        stk.push(p.ImportPath + " (test)")
        for _, path := range p.TestImports {
                p1 := loadImport(path, p.Dir, &stk, p.build.TestImportPos[path])
-               if !reqPkgSrc && p1.Root == "" {
+               if !reqStdPkgSrc && p1.Standard {
                        continue
                }
                if p1.Error != nil {
@@ -591,7 +592,7 @@ func (b *builder) test(p *Package) (buil
                        continue
                }
                p1 := loadImport(path, p.Dir, &stk, 
p.build.XTestImportPos[path])
-               if !reqPkgSrc && p1.Root == "" {
+               if !reqStdPkgSrc && p1.Standard {
                        continue
                }
                if p1.Error != nil {
@@ -722,7 +723,7 @@ func (b *builder) test(p *Package) (buil
                        pmain.imports = append(pmain.imports, ptest)
                } else {
                        p1 := loadImport(dep, "", &stk, nil)
-                       if !reqPkgSrc && p1.Root == "" {
+                       if !reqStdPkgSrc && p1.Standard {
                                continue
                        }
                        if p1.Error != nil {
Index: gotools/Makefile.am
===================================================================
--- gotools/Makefile.am (revision 221642)
+++ gotools/Makefile.am (working copy)
@@ -67,7 +67,8 @@ go_cmd_go_files = \
        $(cmdsrcdir)/go/tool.go \
        $(cmdsrcdir)/go/vcs.go \
        $(cmdsrcdir)/go/version.go \
-       $(cmdsrcdir)/go/vet.go
+       $(cmdsrcdir)/go/vet.go \
+       $(libgodir)/zstdpkglist.go
 
 go_cmd_gofmt_files = \
        $(cmdsrcdir)/gofmt/doc.go \

Reply via email to