From: Ian Lance Taylor Date: Tue, 24 Mar 2015 19:50:31 +0000 (+0000) Subject: re PR go/65462 (Use of 'go get' with gccgo is not finding dependencies correctly) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab24432b9ab95cc0e12cb5ae298fffbda04b3202;p=gcc.git re PR go/65462 (Use of 'go get' with gccgo is not finding dependencies correctly) PR go/65462 cmd: Fix dependencies for 'go get' with gccgo Problem described in GCC BZ 65462. Generate the list of the standard GO package names based on what was built into libgo in the libgo Makefile. Change the var name from reqPkgSrc to reqStdPkgSrc to clarify it only affects standard GO packages. Skip the attempted loading of a package only if it is a standard GO package and the flag is set indicating its source is not required to be available. This requires a corresponding change to gotools to build and link in the new file containing the list of standard GO package names that was generated by the libgo Makefile. gotools/: PR go/65462 * Makefile.am (go_cmd_go_files): Add $(libgodir)/zstdpkglist.go. * Makefile.in: Rebuild. From-SVN: r221643 --- diff --git a/gotools/ChangeLog b/gotools/ChangeLog index fbe4d74d500..8eceb18e518 100644 --- a/gotools/ChangeLog +++ b/gotools/ChangeLog @@ -1,3 +1,9 @@ +2015-03-24 Ian Lance Taylor + + PR go/65462 + * Makefile.am (go_cmd_go_files): Add $(libgodir)/zstdpkglist.go. + * Makefile.in: Rebuild. + 2015-03-12 Ian Lance Taylor * Makefile.am (GOLINK): Add GOCFLAGS. diff --git a/gotools/Makefile.am b/gotools/Makefile.am index 9d3ca22346c..7fb0f75c297 100644 --- a/gotools/Makefile.am +++ b/gotools/Makefile.am @@ -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 \ diff --git a/gotools/Makefile.in b/gotools/Makefile.in index c370157da47..d08a597a85c 100644 --- a/gotools/Makefile.in +++ b/gotools/Makefile.in @@ -257,7 +257,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 \ @@ -518,8 +519,8 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -@NATIVE_FALSE@install-exec-local: @NATIVE_FALSE@uninstall-local: +@NATIVE_FALSE@install-exec-local: clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \ diff --git a/libgo/Makefile.am b/libgo/Makefile.am index f6f967e22a6..e71a6fa0369 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -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 diff --git a/libgo/Makefile.in b/libgo/Makefile.in index c908869cd61..88b83adf477 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -269,23 +269,24 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive -DATA = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ - $(toolexeclibgocompress_DATA) $(toolexeclibgocontainer_DATA) \ - $(toolexeclibgocrypto_DATA) $(toolexeclibgocryptox509_DATA) \ - $(toolexeclibgodatabase_DATA) $(toolexeclibgodatabasesql_DATA) \ - $(toolexeclibgodebug_DATA) $(toolexeclibgoencoding_DATA) \ - $(toolexeclibgoexp_DATA) $(toolexeclibgogo_DATA) \ - $(toolexeclibgohash_DATA) $(toolexeclibgohtml_DATA) \ - $(toolexeclibgoimage_DATA) $(toolexeclibgoimagecolor_DATA) \ - $(toolexeclibgoindex_DATA) $(toolexeclibgoio_DATA) \ - $(toolexeclibgolog_DATA) $(toolexeclibgomath_DATA) \ - $(toolexeclibgomime_DATA) $(toolexeclibgonet_DATA) \ - $(toolexeclibgonethttp_DATA) $(toolexeclibgonetrpc_DATA) \ - $(toolexeclibgoold_DATA) $(toolexeclibgoos_DATA) \ - $(toolexeclibgopath_DATA) $(toolexeclibgoregexp_DATA) \ - $(toolexeclibgoruntime_DATA) $(toolexeclibgosync_DATA) \ - $(toolexeclibgotesting_DATA) $(toolexeclibgotext_DATA) \ - $(toolexeclibgotexttemplate_DATA) $(toolexeclibgounicode_DATA) +DATA = $(noinst_DATA) $(toolexeclibgo_DATA) \ + $(toolexeclibgoarchive_DATA) $(toolexeclibgocompress_DATA) \ + $(toolexeclibgocontainer_DATA) $(toolexeclibgocrypto_DATA) \ + $(toolexeclibgocryptox509_DATA) $(toolexeclibgodatabase_DATA) \ + $(toolexeclibgodatabasesql_DATA) $(toolexeclibgodebug_DATA) \ + $(toolexeclibgoencoding_DATA) $(toolexeclibgoexp_DATA) \ + $(toolexeclibgogo_DATA) $(toolexeclibgohash_DATA) \ + $(toolexeclibgohtml_DATA) $(toolexeclibgoimage_DATA) \ + $(toolexeclibgoimagecolor_DATA) $(toolexeclibgoindex_DATA) \ + $(toolexeclibgoio_DATA) $(toolexeclibgolog_DATA) \ + $(toolexeclibgomath_DATA) $(toolexeclibgomime_DATA) \ + $(toolexeclibgonet_DATA) $(toolexeclibgonethttp_DATA) \ + $(toolexeclibgonetrpc_DATA) $(toolexeclibgoold_DATA) \ + $(toolexeclibgoos_DATA) $(toolexeclibgopath_DATA) \ + $(toolexeclibgoregexp_DATA) $(toolexeclibgoruntime_DATA) \ + $(toolexeclibgosync_DATA) $(toolexeclibgotesting_DATA) \ + $(toolexeclibgotext_DATA) $(toolexeclibgotexttemplate_DATA) \ + $(toolexeclibgounicode_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ @@ -1154,6 +1155,7 @@ go_runtime_files = \ go/runtime/softfloat64.go \ version.go +noinst_DATA = zstdpkglist.go go_sort_files = \ go/sort/search.go \ go/sort/sort.go @@ -4394,6 +4396,18 @@ s-version: Makefile $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ +# 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) $@ + libcalls.go: s-libcalls; @true s-libcalls: libcalls-list go/syscall/mksyscall.awk $(go_base_syscall_files) rm -f libcalls.go.tmp diff --git a/libgo/go/cmd/go/build.go b/libgo/go/cmd/go/build.go index 95b9804d3de..22d37f3fa3b 100644 --- a/libgo/go/cmd/go/build.go +++ b/libgo/go/cmd/go/build.go @@ -132,7 +132,8 @@ var buildLdflags []string // -ldflags flag 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, depMode buildMode, p *Package) *action // 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) diff --git a/libgo/go/cmd/go/pkg.go b/libgo/go/cmd/go/pkg.go index 621cb4b6083..62f6b4adf57 100644 --- a/libgo/go/cmd/go/pkg.go +++ b/libgo/go/cmd/go/pkg.go @@ -112,7 +112,11 @@ func (p *Package) copyBuild(pp *build.Package) { 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, bp *build.Package, err error) *Package continue } p1 := loadImport(path, p.Dir, stk, p.build.ImportPos[path]) - if !reqPkgSrc && p1.Root == "" { + if !reqStdPkgSrc && p1.Standard { continue } if p1.local { diff --git a/libgo/go/cmd/go/test.go b/libgo/go/cmd/go/test.go index 28b46ff52bf..cc0a9acf45d 100644 --- a/libgo/go/cmd/go/test.go +++ b/libgo/go/cmd/go/test.go @@ -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) (buildAction, runAction, printAction *action, 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) (buildAction, runAction, printAction *action, 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) (buildAction, runAction, printAction *action, 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 {