From 28fb0d802380391044650e36f186c27302d6f578 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 11 Aug 2015 10:33:25 -0400 Subject: [PATCH] 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 --- src/cmd/go/go_test.go | 20 ++++++++++++++++++++ src/cmd/go/pkg.go | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) 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") } } -- 2.48.1