aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-08-11 10:33:25 -0400
committerRuss Cox <rsc@golang.org>2015-08-11 19:13:12 +0000
commit28fb0d802380391044650e36f186c27302d6f578 (patch)
tree52bfe280f029868674a81f6c6c2d8cd0bcf18c29
parent8ce80ce87ded2c02a3b7c2f15cbd19e8c2cc062d (diff)
downloadgo-28fb0d802380391044650e36f186c27302d6f578.tar.gz
go-28fb0d802380391044650e36f186c27302d6f578.zip
cmd/go: fix addition of "math" dependency for arm binaries
p.ImportPath is the directory-derived path (like cmd/go). p.Name is the actual package name. Fixes #12089. Change-Id: Ief76d42a85f811b0dfe2218affb48551527a7d44 Reviewed-on: https://go-review.googlesource.com/13530 Reviewed-by: David Crawshaw <crawshaw@golang.org>
-rw-r--r--src/cmd/go/go_test.go20
-rw-r--r--src/cmd/go/pkg.go2
2 files changed, 21 insertions, 1 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 5b0f2783f3..0718869aa6 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -2352,3 +2352,23 @@ func TestGoBuildOutput(t *testing.T) {
tg.runFail("build", "-o", "whatever", "cmd/gofmt", "sync/atomic")
tg.grepStderr("multiple packages", "did not reject -o with multiple packages")
}
+
+func TestGoBuildARM(t *testing.T) {
+ if testing.Short() {
+ t.Skip("skipping cross-compile in short mode")
+ }
+
+ tg := testgo(t)
+ defer tg.cleanup()
+
+ tg.makeTempdir()
+ tg.cd(tg.path("."))
+
+ tg.setenv("GOARCH", "arm")
+ tg.setenv("GOOS", "linux")
+ tg.setenv("GOARM", "5")
+ tg.tempFile("hello.go", `package main
+ func main() {}`)
+ tg.run("build", "hello.go")
+ tg.grepStderrNot("unable to find math.a", "did not build math.a correctly")
+}
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
index 6b78a47939..0317536bce 100644
--- a/src/cmd/go/pkg.go
+++ b/src/cmd/go/pkg.go
@@ -836,7 +836,7 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
importPaths = append(importPaths, "runtime/race")
}
// On ARM with GOARM=5, everything depends on math for the link.
- if p.ImportPath == "main" && goarch == "arm" {
+ if p.Name == "main" && goarch == "arm" {
importPaths = append(importPaths, "math")
}
}