1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:40:23 -07:00

cmd/cgo: don't depend on runtime/cgo if !CgoEnabled

Fixes the build when CGO_ENABLED=0.

Change-Id: I7f3c67d61e156e69536558fda0a0a4b429b82bbd
Reviewed-on: https://go-review.googlesource.com/33104
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2016-11-10 15:19:11 -08:00
parent 35ea53dcc8
commit 7bdb77af5f

View File

@ -913,6 +913,7 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
importPaths = append(importPaths, "syscall")
}
if buildContext.CgoEnabled && p.Name == "main" && !p.Goroot {
// Currently build modes c-shared, pie (on systems that do not
// support PIE with internal linking mode), plugin, and
// -linkshared force external linking mode, as of course does
@ -928,9 +929,10 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
linkmodeExternal = true
}
}
if p.Name == "main" && !p.Goroot && (buildBuildmode == "c-shared" || buildBuildmode == "plugin" || pieCgo || buildLinkshared || linkmodeExternal) {
if buildBuildmode == "c-shared" || buildBuildmode == "plugin" || pieCgo || buildLinkshared || linkmodeExternal {
importPaths = append(importPaths, "runtime/cgo")
}
}
// Everything depends on runtime, except runtime, its internal
// subpackages, and unsafe.