// Cgo translation adds imports of "runtime/cgo" and "syscall",
// except for certain packages, to avoid circular dependencies.
- if p.UsesCgo() && (!p.Standard || !cgoExclude[p.ImportPath]) {
+ if p.UsesCgo() && (!p.Standard || !cgoExclude[p.ImportPath]) && cfg.BuildContext.Compiler != "gccgo" {
addImport("runtime/cgo")
}
if p.UsesCgo() && (!p.Standard || !cgoSyscallExclude[p.ImportPath]) {
// SWIG adds imports of some standard packages.
if p.UsesSwig() {
- addImport("runtime/cgo")
+ if cfg.BuildContext.Compiler != "gccgo" {
+ addImport("runtime/cgo")
+ }
addImport("syscall")
addImport("sync")
deps := []string{"runtime"}
// External linking mode forces an import of runtime/cgo.
- if externalLinkingForced(p) {
+ if externalLinkingForced(p) && cfg.BuildContext.Compiler != "gccgo" {
deps = append(deps, "runtime/cgo")
}
// On ARM with GOARM=5, it forces an import of math, for soft floating point.
GoFiles []string
ImportMap map[string]string
PackageFile map[string]string
+ Standard map[string]bool
ImportPath string
SucceedOnTypecheckFailure bool
ImportPath: a.Package.ImportPath,
ImportMap: make(map[string]string),
PackageFile: make(map[string]string),
+ Standard: make(map[string]bool),
}
a.vetCfg = vcfg
for i, raw := range a.Package.Internal.RawImports {
for _, a1 := range a.Deps {
p1 := a1.Package
- if p1 == nil || p1.ImportPath == "" || a1.built == "" {
+ if p1 == nil || p1.ImportPath == "" {
continue
}
// Add import mapping if needed
if !vcfgMapped[p1.ImportPath] {
vcfg.ImportMap[p1.ImportPath] = p1.ImportPath
}
- vcfg.PackageFile[p1.ImportPath] = a1.built
+ if a1.built != "" {
+ vcfg.PackageFile[p1.ImportPath] = a1.built
+ }
+ if p1.Standard {
+ vcfg.Standard[p1.ImportPath] = true
+ }
}
}
if vcfg.ImportMap["fmt"] == "" {
a1 := a.Deps[1]
vcfg.ImportMap["fmt"] = "fmt"
- vcfg.PackageFile["fmt"] = a1.built
+ if a1.built != "" {
+ vcfg.PackageFile["fmt"] = a1.built
+ }
+ vcfg.Standard["fmt"] = true
}
// During go test, ignore type-checking failures during vet.
GoFiles []string
ImportMap map[string]string
PackageFile map[string]string
+ Standard map[string]bool
SucceedOnTypecheckFailure bool
return nil, fmt.Errorf("unknown import path %q", path)
}
if v.PackageFile[p] == "" {
+ if v.Compiler == "gccgo" && v.Standard[path] {
+ // gccgo doesn't have sources for standard library packages,
+ // but the importer will do the right thing.
+ return v.imp.Import(path)
+ }
return nil, fmt.Errorf("unknown package file for import %q", path)
}
return v.imp.Import(p)
func (v *vetConfig) openPackageFile(path string) (io.ReadCloser, error) {
file := v.PackageFile[path]
if file == "" {
+ if v.Compiler == "gccgo" && v.Standard[path] {
+ // The importer knows how to handle this.
+ return nil, nil
+ }
// Note that path here has been translated via v.ImportMap,
// unlike in the error in Import above. We prefer the error in
// Import, but it's worth diagnosing this one too, just in case.
var reader io.ReadSeeker
var fpath string
+ var rc io.ReadCloser
if lookup != nil {
if p := imports[pkgpath]; p != nil && p.Complete() {
return p, nil
}
- rc, err := lookup(pkgpath)
+ rc, err = lookup(pkgpath)
if err != nil {
return nil, err
}
+ }
+ if rc != nil {
defer rc.Close()
rs, ok := rc.(io.ReadSeeker)
if !ok {