+Ian Lance Taylor I spent some time this morning trying to figure out why everyone includes "-installsuffix cgo" in their static Go builds. It seems likely they cargo-culted it from you here:

https://github.com/golang/go/issues/9344#issuecomment-69944514

I think the reason for the install suffix in that thread was that in that version of Go, std packages would not normally be rebuilt, even if they were originally compiled with cgo and you asked for CGO_ENABLED=0. So you suggested adding a suffix (and picked "cgo" as an arbitrary name) which would cause everything to actually be rebuilt.

But today the build system, or the meaning of "go build", or something else has changed so that "go build" with CGO_ENABLED=0 will actually rebuild std packages whose compiled object files depend on C libraries. So CGO_ENABLED=0 is now sufficient for a static binary, and you only need the other build tags or linker options if you are trying to build a static binary with cgo, and you don't need an install suffix at all.

Is this correct?
Shared publiclyView activity