Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: Go build (Go 1.9) does not use pack but fails if pkg/tool/$GOOS_$GOARCH/pack does not exist and you build with -x -a #22819

Closed
rminnich opened this issue Nov 20, 2017 · 4 comments
Labels
FrozenDueToAge GoCommand cmd/go WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@rminnich
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go release branch 1.9

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

This was discovered when using u-root (u-root.tk). In u-root we build a minimal standalone environment which lets us build Go programs. There are only 5 binaries:
/init, go, compile, asm, link

We found that go build was failing with the error
go tool: no such tool "pack"

Although in this case pack is not used; e.g.
/go/pkg/tool/linux_amd64/pack r $WORK/math.a $WORK/math/_obj/asin_amd64.o (lots of .o's elided) # internal

To see for yourself:

Create this file as hello.go:
package main
import "fmt"
func main() {
fmt.Println("hi")
}

go build -x -a hello.go
it works.

Then
cp /path/to/go/pkg/tool/$GOOS_$GOARCH/pack /some/where/safe

/path/to/go/pkg/tool/$GOOS_$GOARCH/pack
i.e. just zero out the pack command

go build -x -a hello.go
still works

Then
rm /path/to/go/pkg/tool/$GOOS_$GOARCH/pack

Note: it only fails with -x -a, not with -x or -a.

It may be just something about rebuilding it all, and showing it all?

The special circumstances of u-root may explain why nobody has seen this to date.

@rminnich rminnich added the GoCommand cmd/go label Nov 20, 2017
@bradfitz
Copy link
Contributor

The cmd/go caching was entirely rewritten for Go 1.10, fixing dozens of these sorts of bugs in the process.

Please try with Go 1.10 and report back. This won't be backported to Go 1.9.

@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 20, 2017
@bradfitz bradfitz changed the title Go build does not use pack but fails if pkg/tool/$GOOS_$GOARCH/pack does not exist and you build with -x -a cmd/go: Go build (Go 1.9) does not use pack but fails if pkg/tool/$GOOS_$GOARCH/pack does not exist and you build with -x -a Nov 20, 2017
@rminnich
Copy link
Contributor Author

go tip doesn't even come close to building for me but I'll try later this week when I get a chance.

@bradfitz
Copy link
Contributor

go tip doesn't even come close to building for me

@rminnich, uh, why?

Our build dashboard is happy and not red.

@ianlancetaylor
Copy link
Contributor

One of the goals of go build -x is to produce a set of commands that, if executed again, will produce the same result. The "pack" step of a build is performed internally by the go tool for efficiency, but the -x output lists an invocation of the go tool pack command that does the same thing. In order to generate that output, the go tool looks up and prints the location of the "pack" tool. If the "pack" tool does not exist, then you get this error.

We could add extra code to do the right thing if the "pack" tool does not exist, but this is such a special and unusual case that I don't think it's worth it. For your purposes, I recommend simply creating a tiny executable shell script named "pack" in your tool directory, that just does exit 1. Then go build -x should start working again.

Closing this issue because we aren't going to make any changes.

@golang golang locked and limited conversation to collaborators Mar 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants