Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: go tries to recompile already installed packages: missing headers #27027
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
This is likely because of
You might have better luck using this package as a binary package. I assume the other option is to not change
changed the title
Go tries to recompile already installed packages: missing headers
Aug 16, 2018
GOPATH/pkg is not something you can micromanage anymore. It's just a set of 1-entry caches. If they're up-to-date for the requested build, they'll be used; otherwise not. The go command can now tell that relevant environment variables have changed since the package was built (in particular, $CGO_LDFLAGS changed), so it does not reuse the (stale) installed package. In general, a change to CGO_LDFLAGS should trigger a rebuild, so sorry but this is working as intended.
I'm not sure what to say except that you now need to keep those environment variables set the same way from build to build.
@rsc has a blog post somewhere (which I have failed to find) which introduces the notion of content-based staleness - the closest I could find was this golang-nuts post where he introduces it. But I recall an 'aha' moment when I read that.
If I recall correctly, in the post I can't find, @rsc mentioned that initially he thought - and you might think - that 'depending on what happened to run before' was a feature which enabled you to do various things (as in this issue). He came around (and in his writing, I came around) to the idea that actually those problems can be solved through other means, giving us the very useful property that