cmd/go: runtime and runtime/internal packages depend on runtime/internal/sys

Fixes #13655.

Change-Id: I764019aecdd59743baa436b7339499e6c2126268
Reviewed-on: https://go-review.googlesource.com/17916
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Ian Lance Taylor 2015-12-17 10:29:12 -08:00
parent 0cb68acea2
commit 54977cd3de
2 changed files with 17 additions and 0 deletions

View file

@ -2454,3 +2454,12 @@ func TestGoBuildARM(t *testing.T) {
tg.run("build", "hello.go")
tg.grepStderrNot("unable to find math.a", "did not build math.a correctly")
}
func TestIssue13655(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
for _, pkg := range []string{"runtime", "runtime/internal/atomic"} {
tg.run("list", "-f", "{{.Deps}}", pkg)
tg.grepStdout("runtime/internal/sys", "did not find required dependency of "+pkg+" on runtime/internal/sys")
}
}

View file

@ -835,6 +835,14 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
}
}
// Runtime and its internal packages depend on runtime/internal/sys,
// so that they pick up the generated zversion.go file.
// This can be an issue particularly for runtime/internal/atomic;
// see issue 13655.
if p.Standard && (p.ImportPath == "runtime" || strings.HasPrefix(p.ImportPath, "runtime/internal/")) && p.ImportPath != "runtime/internal/sys" {
importPaths = append(importPaths, "runtime/internal/sys")
}
// Build list of full paths to all Go files in the package,
// for use by commands like go fmt.
p.gofiles = stringList(p.GoFiles, p.CgoFiles, p.TestGoFiles, p.XTestGoFiles)