]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix addition of "math" dependency for arm binaries
authorRuss Cox <rsc@golang.org>
Tue, 11 Aug 2015 14:33:25 +0000 (10:33 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 11 Aug 2015 19:13:12 +0000 (19:13 +0000)
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>
src/cmd/go/go_test.go
src/cmd/go/pkg.go

index 5b0f2783f358a5b45d9a6f88e5e3d5da79805011..0718869aa66daa46a03182ed77ac7f443b3d9969 100644 (file)
@@ -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")
+}
index 6b78a479394cd5f0715bb21facfb6108fb963632..0317536bce6aec8c0e6ea145e027a588275fef74 100644 (file)
@@ -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")
                }
        }