Skip to content

Commit 54977cd

Browse files
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 <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent 0cb68ac commit 54977cd

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/cmd/go/go_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,3 +2454,12 @@ func TestGoBuildARM(t *testing.T) {
24542454
tg.run("build", "hello.go")
24552455
tg.grepStderrNot("unable to find math.a", "did not build math.a correctly")
24562456
}
2457+
2458+
func TestIssue13655(t *testing.T) {
2459+
tg := testgo(t)
2460+
defer tg.cleanup()
2461+
for _, pkg := range []string{"runtime", "runtime/internal/atomic"} {
2462+
tg.run("list", "-f", "{{.Deps}}", pkg)
2463+
tg.grepStdout("runtime/internal/sys", "did not find required dependency of "+pkg+" on runtime/internal/sys")
2464+
}
2465+
}

src/cmd/go/pkg.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,14 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
835835
}
836836
}
837837

838+
// Runtime and its internal packages depend on runtime/internal/sys,
839+
// so that they pick up the generated zversion.go file.
840+
// This can be an issue particularly for runtime/internal/atomic;
841+
// see issue 13655.
842+
if p.Standard && (p.ImportPath == "runtime" || strings.HasPrefix(p.ImportPath, "runtime/internal/")) && p.ImportPath != "runtime/internal/sys" {
843+
importPaths = append(importPaths, "runtime/internal/sys")
844+
}
845+
838846
// Build list of full paths to all Go files in the package,
839847
// for use by commands like go fmt.
840848
p.gofiles = stringList(p.GoFiles, p.CgoFiles, p.TestGoFiles, p.XTestGoFiles)

0 commit comments

Comments
 (0)