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

x/vgo: load does not look at -tags build flag #24053

Closed
philpennock opened this issue Feb 23, 2018 · 3 comments
Closed

x/vgo: load does not look at -tags build flag #24053

philpennock opened this issue Feb 23, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@philpennock
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pdp/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/pdp/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vs/7q9nz5955_z7b7zxfz437zrm0000gn/T/go-build533554610=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Following on from issue #24052 I tried to make sure that my app built with added dependencies enabled via a build tag. The "production" deploy of go.pennock.tech/dummyapp consists of building a scratch-based Docker image for pushing as an image to Heroku. It is built with the heroku build-tag, which adds an extra package import, of Heroku's metrics exporter library.

In the same directory and setup (same shell instance) as the previous successful build for #24052 I tried to enable this extra dependency:

% vgo build -tags heroku
build go.pennock.tech/dummyapp: cannot find module for path github.com/heroku/x/hmetrics

What does vgo think the dependencies are?

% vgo list -m
MODULE                      VERSION
go.pennock.tech/dummyapp    -
github.com/sirupsen/logrus  v1.0.4
golang.org/x/crypto         v0.0.0-20180222182404-49796115aa4b
golang.org/x/sys            v0.0.0-20180222210305-c1138c84af3a
% vgo list -tags heroku -m
MODULE                      VERSION
go.pennock.tech/dummyapp    -
github.com/sirupsen/logrus  v1.0.4
golang.org/x/crypto         v0.0.0-20180222182404-49796115aa4b
golang.org/x/sys            v0.0.0-20180222210305-c1138c84af3a

What did you expect to see?

A successful build.

What did you see instead?

What looks like vgo not using the build tags when deriving the list of dependencies to be resolved, only when later selecting the files to be compiled.

@gopherbot gopherbot added this to the vgo milestone Feb 23, 2018
@rsc
Copy link
Contributor

rsc commented Mar 30, 2018

Yes, probably cmd/go/internal/imports needs to change var Tags to func Tags() and make it look at cfg.Tags in addition to the initial list. Oops.

@rsc rsc changed the title x/vgo: does not handle build-tags implying an additional import x/vgo: load does not look at -tags build flag Mar 30, 2018
@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 30, 2018
@gopherbot
Copy link

Change https://golang.org/cl/113896 mentions this issue: x/vgo: fix ignoring tags on build, test, ...

gopherbot pushed a commit to golang/vgo that referenced this issue May 24, 2018
Before, `Tags` was initialized without -tags build flag.

Now, commands like "vgo build -tags tag1" include files
with build tags.

For golang/go#24053 (`vgo list -m` does not update dependencies like `vgo list`)

Change-Id: I1945afb928534563311c86483aea8fdd02490a0a
Reviewed-on: https://go-review.googlesource.com/113896
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
@rsc
Copy link
Contributor

rsc commented Jun 6, 2018

I believe CL 113896 fixed this problem with ignoring tags.

@rsc rsc closed this as completed Jun 6, 2018
@golang golang locked and limited conversation to collaborators Jun 6, 2019
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

3 participants