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

go/build: Context.BuildTags are ignored when checking file name #25461

Closed
linzhp opened this issue May 19, 2018 · 3 comments
Closed

go/build: Context.BuildTags are ignored when checking file name #25461

linzhp opened this issue May 19, 2018 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@linzhp
Copy link
Contributor

linzhp commented May 19, 2018

When Context.BuildTags has "freebsd" in it, go/build should include Go files for FreeBSD. However, it fails to include Go files with freebsd in the name when GOOS is not freebsd. It works as expected when "freebsd" is in // +build line but not in file name.

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

go version go1.10.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GORACE=""
GOTMPDIR=""
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/m6/vs051rl54k3_sgxr94ylcz5h0000gn/T/go-build595956365=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

git clone git@github.com:linzhp/go_examples.git
cd go_examples/buildConstraints
go run main.go

What did you expect to see?

[print_freebsd.go print.go]

What did you see instead?

[print.go]

@gopherbot
Copy link

Change https://golang.org/cl/113818 mentions this issue: go/build: call ctxt.match for checking file name constraints

@bcmills
Copy link
Contributor

bcmills commented May 21, 2018

CC: @griesemer @ianlancetaylor

It seems strange to put freebsd in the BuildTags field, since you'll likely end up with a mismatch between that and 'GOOS' anyway. What happens if you set GOOS="freebsd" in your example instead?

@bcmills bcmills added this to the Go1.11 milestone May 21, 2018
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 21, 2018
@linzhp
Copy link
Contributor Author

linzhp commented May 21, 2018

This is intentional. When freebsd is present in BuildTags, go should include files for both GOOS and freebsd. This test specifically tests that scenario.

@golang golang locked and limited conversation to collaborators May 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants