Commit ab24432b by Ian Lance Taylor Committed by Ian Lance Taylor

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
parent a9f0423f
2015-03-24 Ian Lance Taylor <iant@google.com>
PR go/65462
* Makefile.am (go_cmd_go_files): Add $(libgodir)/zstdpkglist.go.
* Makefile.in: Rebuild.
2015-03-12 Ian Lance Taylor <iant@google.com> 2015-03-12 Ian Lance Taylor <iant@google.com>
* Makefile.am (GOLINK): Add GOCFLAGS. * Makefile.am (GOLINK): Add GOCFLAGS.
......
...@@ -67,7 +67,8 @@ go_cmd_go_files = \ ...@@ -67,7 +67,8 @@ go_cmd_go_files = \
$(cmdsrcdir)/go/tool.go \ $(cmdsrcdir)/go/tool.go \
$(cmdsrcdir)/go/vcs.go \ $(cmdsrcdir)/go/vcs.go \
$(cmdsrcdir)/go/version.go \ $(cmdsrcdir)/go/version.go \
$(cmdsrcdir)/go/vet.go $(cmdsrcdir)/go/vet.go \
$(libgodir)/zstdpkglist.go
go_cmd_gofmt_files = \ go_cmd_gofmt_files = \
$(cmdsrcdir)/gofmt/doc.go \ $(cmdsrcdir)/gofmt/doc.go \
......
...@@ -257,7 +257,8 @@ go_cmd_go_files = \ ...@@ -257,7 +257,8 @@ go_cmd_go_files = \
$(cmdsrcdir)/go/tool.go \ $(cmdsrcdir)/go/tool.go \
$(cmdsrcdir)/go/vcs.go \ $(cmdsrcdir)/go/vcs.go \
$(cmdsrcdir)/go/version.go \ $(cmdsrcdir)/go/version.go \
$(cmdsrcdir)/go/vet.go $(cmdsrcdir)/go/vet.go \
$(libgodir)/zstdpkglist.go
go_cmd_gofmt_files = \ go_cmd_gofmt_files = \
$(cmdsrcdir)/gofmt/doc.go \ $(cmdsrcdir)/gofmt/doc.go \
...@@ -518,8 +519,8 @@ distclean-generic: ...@@ -518,8 +519,8 @@ distclean-generic:
maintainer-clean-generic: maintainer-clean-generic:
@echo "This command is intended for maintainers to use" @echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild." @echo "it deletes files that may require special tools to rebuild."
@NATIVE_FALSE@install-exec-local:
@NATIVE_FALSE@uninstall-local: @NATIVE_FALSE@uninstall-local:
@NATIVE_FALSE@install-exec-local:
clean: clean-am clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \ clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
......
...@@ -978,6 +978,20 @@ s-version: Makefile ...@@ -978,6 +978,20 @@ s-version: Makefile
$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
$(STAMP) $@ $(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_files = \
go/sort/search.go \ go/sort/search.go \
go/sort/sort.go go/sort/sort.go
......
...@@ -269,23 +269,24 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ ...@@ -269,23 +269,24 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \ install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive ps-recursive uninstall-recursive
DATA = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ DATA = $(noinst_DATA) $(toolexeclibgo_DATA) \
$(toolexeclibgocompress_DATA) $(toolexeclibgocontainer_DATA) \ $(toolexeclibgoarchive_DATA) $(toolexeclibgocompress_DATA) \
$(toolexeclibgocrypto_DATA) $(toolexeclibgocryptox509_DATA) \ $(toolexeclibgocontainer_DATA) $(toolexeclibgocrypto_DATA) \
$(toolexeclibgodatabase_DATA) $(toolexeclibgodatabasesql_DATA) \ $(toolexeclibgocryptox509_DATA) $(toolexeclibgodatabase_DATA) \
$(toolexeclibgodebug_DATA) $(toolexeclibgoencoding_DATA) \ $(toolexeclibgodatabasesql_DATA) $(toolexeclibgodebug_DATA) \
$(toolexeclibgoexp_DATA) $(toolexeclibgogo_DATA) \ $(toolexeclibgoencoding_DATA) $(toolexeclibgoexp_DATA) \
$(toolexeclibgohash_DATA) $(toolexeclibgohtml_DATA) \ $(toolexeclibgogo_DATA) $(toolexeclibgohash_DATA) \
$(toolexeclibgoimage_DATA) $(toolexeclibgoimagecolor_DATA) \ $(toolexeclibgohtml_DATA) $(toolexeclibgoimage_DATA) \
$(toolexeclibgoindex_DATA) $(toolexeclibgoio_DATA) \ $(toolexeclibgoimagecolor_DATA) $(toolexeclibgoindex_DATA) \
$(toolexeclibgolog_DATA) $(toolexeclibgomath_DATA) \ $(toolexeclibgoio_DATA) $(toolexeclibgolog_DATA) \
$(toolexeclibgomime_DATA) $(toolexeclibgonet_DATA) \ $(toolexeclibgomath_DATA) $(toolexeclibgomime_DATA) \
$(toolexeclibgonethttp_DATA) $(toolexeclibgonetrpc_DATA) \ $(toolexeclibgonet_DATA) $(toolexeclibgonethttp_DATA) \
$(toolexeclibgoold_DATA) $(toolexeclibgoos_DATA) \ $(toolexeclibgonetrpc_DATA) $(toolexeclibgoold_DATA) \
$(toolexeclibgopath_DATA) $(toolexeclibgoregexp_DATA) \ $(toolexeclibgoos_DATA) $(toolexeclibgopath_DATA) \
$(toolexeclibgoruntime_DATA) $(toolexeclibgosync_DATA) \ $(toolexeclibgoregexp_DATA) $(toolexeclibgoruntime_DATA) \
$(toolexeclibgotesting_DATA) $(toolexeclibgotext_DATA) \ $(toolexeclibgosync_DATA) $(toolexeclibgotesting_DATA) \
$(toolexeclibgotexttemplate_DATA) $(toolexeclibgounicode_DATA) $(toolexeclibgotext_DATA) $(toolexeclibgotexttemplate_DATA) \
$(toolexeclibgounicode_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
...@@ -1154,6 +1155,7 @@ go_runtime_files = \ ...@@ -1154,6 +1155,7 @@ go_runtime_files = \
go/runtime/softfloat64.go \ go/runtime/softfloat64.go \
version.go version.go
noinst_DATA = zstdpkglist.go
go_sort_files = \ go_sort_files = \
go/sort/search.go \ go/sort/search.go \
go/sort/sort.go go/sort/sort.go
...@@ -4394,6 +4396,18 @@ s-version: Makefile ...@@ -4394,6 +4396,18 @@ s-version: Makefile
$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
$(STAMP) $@ $(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 libcalls.go: s-libcalls; @true
s-libcalls: libcalls-list go/syscall/mksyscall.awk $(go_base_syscall_files) s-libcalls: libcalls-list go/syscall/mksyscall.awk $(go_base_syscall_files)
rm -f libcalls.go.tmp rm -f libcalls.go.tmp
......
...@@ -132,7 +132,8 @@ var buildLdflags []string // -ldflags flag ...@@ -132,7 +132,8 @@ var buildLdflags []string // -ldflags flag
var buildGccgoflags []string // -gccgoflags flag var buildGccgoflags []string // -gccgoflags flag
var buildRace bool // -race 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 buildContext = build.Default
var buildToolchain toolchain = noToolchain{} var buildToolchain toolchain = noToolchain{}
...@@ -187,9 +188,9 @@ func addBuildFlags(cmd *Command) { ...@@ -187,9 +188,9 @@ func addBuildFlags(cmd *Command) {
cmd.Flag.BoolVar(&buildRace, "race", false, "") cmd.Flag.BoolVar(&buildRace, "race", false, "")
switch build.Default.Compiler { switch build.Default.Compiler {
case "gc": case "gc":
reqPkgSrc = true reqStdPkgSrc = true
case "gccgo": case "gccgo":
reqPkgSrc = false reqStdPkgSrc = false
} }
} }
...@@ -579,7 +580,7 @@ func (b *builder) action(mode buildMode, depMode buildMode, p *Package) *action ...@@ -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. // are writing is not the cgo we need to use.
if goos == runtime.GOOS && goarch == runtime.GOARCH && !buildRace { if goos == runtime.GOOS && goarch == runtime.GOARCH && !buildRace {
if reqPkgSrc { if reqStdPkgSrc {
if len(p.CgoFiles) > 0 || p.Standard && p.ImportPath == "runtime/cgo" { if len(p.CgoFiles) > 0 || p.Standard && p.ImportPath == "runtime/cgo" {
var stk importStack var stk importStack
p1 := loadPackage("cmd/cgo", &stk) p1 := loadPackage("cmd/cgo", &stk)
......
...@@ -112,7 +112,11 @@ func (p *Package) copyBuild(pp *build.Package) { ...@@ -112,7 +112,11 @@ func (p *Package) copyBuild(pp *build.Package) {
p.ConflictDir = pp.ConflictDir p.ConflictDir = pp.ConflictDir
// TODO? Target // TODO? Target
p.Goroot = pp.Goroot 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.GoFiles = pp.GoFiles
p.CgoFiles = pp.CgoFiles p.CgoFiles = pp.CgoFiles
p.IgnoredGoFiles = pp.IgnoredGoFiles p.IgnoredGoFiles = pp.IgnoredGoFiles
...@@ -582,7 +586,7 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package ...@@ -582,7 +586,7 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
continue continue
} }
p1 := loadImport(path, p.Dir, stk, p.build.ImportPos[path]) p1 := loadImport(path, p.Dir, stk, p.build.ImportPos[path])
if !reqPkgSrc && p1.Root == "" { if !reqStdPkgSrc && p1.Standard {
continue continue
} }
if p1.local { if p1.local {
......
...@@ -384,17 +384,18 @@ func runTest(cmd *Command, args []string) { ...@@ -384,17 +384,18 @@ func runTest(cmd *Command, args []string) {
delete(deps, "unsafe") delete(deps, "unsafe")
all := []string{} all := []string{}
if reqPkgSrc { for path := range deps {
for path := range deps { if !build.IsLocalImport(path) {
if !build.IsLocalImport(path) { all = append(all, path)
all = append(all, path)
}
} }
} }
sort.Strings(all) sort.Strings(all)
a := &action{} a := &action{}
for _, p := range packagesForBuild(all) { for _, p := range packagesForBuild(all) {
if !reqStdPkgSrc && p.Standard {
continue
}
a.deps = append(a.deps, b.action(modeInstall, modeInstall, p)) a.deps = append(a.deps, b.action(modeInstall, modeInstall, p))
} }
b.do(a) b.do(a)
...@@ -563,7 +564,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, ...@@ -563,7 +564,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
stk.push(p.ImportPath + " (test)") stk.push(p.ImportPath + " (test)")
for _, path := range p.TestImports { for _, path := range p.TestImports {
p1 := loadImport(path, p.Dir, &stk, p.build.TestImportPos[path]) p1 := loadImport(path, p.Dir, &stk, p.build.TestImportPos[path])
if !reqPkgSrc && p1.Root == "" { if !reqStdPkgSrc && p1.Standard {
continue continue
} }
if p1.Error != nil { if p1.Error != nil {
...@@ -591,7 +592,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, ...@@ -591,7 +592,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
continue continue
} }
p1 := loadImport(path, p.Dir, &stk, p.build.XTestImportPos[path]) p1 := loadImport(path, p.Dir, &stk, p.build.XTestImportPos[path])
if !reqPkgSrc && p1.Root == "" { if !reqStdPkgSrc && p1.Standard {
continue continue
} }
if p1.Error != nil { if p1.Error != nil {
...@@ -722,7 +723,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, ...@@ -722,7 +723,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
pmain.imports = append(pmain.imports, ptest) pmain.imports = append(pmain.imports, ptest)
} else { } else {
p1 := loadImport(dep, "", &stk, nil) p1 := loadImport(dep, "", &stk, nil)
if !reqPkgSrc && p1.Root == "" { if !reqStdPkgSrc && p1.Standard {
continue continue
} }
if p1.Error != nil { if p1.Error != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment