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 install -ldflags should always rebuild #22471

Closed
natefinch opened this issue Oct 27, 2017 · 3 comments
Closed

cmd/go: go install -ldflags should always rebuild #22471

natefinch opened this issue Oct 27, 2017 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.

Comments

@natefinch
Copy link
Contributor

natefinch commented Oct 27, 2017

Please answer these questions before submitting your issue. Thanks!

What did you do?

go get github.com/foo/bar
go install -ldflags=-X = github.com/<some valid variable path>
// check that variables were set in the binary

What did you expect to see?

binary created in $GOPATH/bin with appropriate values set

What did you see instead?

go install short circuited and didn't rebuild because the packages hadn't changed.

Does this issue reproduce with the latest release (go1.9.2)?

yes

System details

go version go1.9 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/finchnat"
GORACE=""
GOROOT="/Users/finchnat/src/github.com/golang/go"
GOTOOLDIR="/Users/finchnat/src/github.com/golang/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ch/4d1vgsv17jq0b3yfmnkl9thdk0jm7d/T/go-build252358238=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version go1.9 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.9
uname -v: Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29
lldb --version: lldb-900.0.50.1
  Swift-4.0

Thoughts

This is related to #22469

I have a command build with go that has a build script that uses ldflags to set the version, commit hash, etc. Standard stuff.

However, if someone uses go get to get my command, and then runs the build script (which just calls go install -ldflags with the right flags.... then nothing happens.

go install should not short circuit the build if you pass in ldflags, because by definition, the new binary will be different than the old one (ok, possibly it'll be the same as the old one, but go install can't know that).

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Oct 27, 2017
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 27, 2017
@ianlancetaylor
Copy link
Contributor

I believe @rsc already intends to fix this for 1.10, but I couldn't find a different bug for it.

@mvdan
Copy link
Member

mvdan commented Oct 28, 2017

Isn't this #18369?

@ianlancetaylor
Copy link
Contributor

Yes, thanks @mvdan, closing as dup.

@mvdan mvdan unassigned rsc Oct 28, 2017
@mvdan mvdan removed this from the Go1.10 milestone Oct 28, 2017
@golang golang locked and limited conversation to collaborators Oct 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants