Skip to content

Commit

Permalink
cmd/go: fix addition of "math" dependency for arm binaries
Browse files Browse the repository at this point in the history
p.ImportPath is the directory-derived path (like cmd/go).
p.Name is the actual package name.

Fixes golang#12089.

Change-Id: Ief76d42a85f811b0dfe2218affb48551527a7d44
Reviewed-on: https://go-review.googlesource.com/13530
Reviewed-by: David Crawshaw <[email protected]>
  • Loading branch information
rsc committed Aug 11, 2015
1 parent 8ce80ce commit 28fb0d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion src/cmd/go/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down

0 comments on commit 28fb0d8

Please sign in to comment.