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: BuildTags should reject tags with the same name as a known os or arch #45488

Open
perillo opened this issue Apr 10, 2021 · 1 comment
Open

Comments

@perillo
Copy link
Contributor

@perillo perillo commented Apr 10, 2021

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

$ go version
go version go1.16.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOENV="/home/manlio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE="*.local"
GOMODCACHE="/home/manlio/.local/lib/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="*.local"
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2654897084=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.16.3 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.16.3
uname -sr: Linux 5.11.11-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.33.
gdb --version: GNU gdb (GDB) 10.1

What did you do?

go vet -tags=windows on a Linux host.

What did you expect to see?

An error, explaining that "windows" should not be used as a build tag.

What did you see instead?

# runtime/internal/sys
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:7:7: GOOS redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:8:14
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:9:7: GoosAix redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:10:17
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:10:7: GoosAndroid redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:11:21
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:11:7: GoosDarwin redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:12:20
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:12:7: GoosDragonfly redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:13:23
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:13:7: GoosFreebsd redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:14:21
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:14:7: GoosHurd redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:15:18
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:15:7: GoosIllumos redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:16:21
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:16:7: GoosIos redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:17:17
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:17:7: GoosJs redeclared in this block
	previous declaration at /usr/lib/go/src/runtime/internal/sys/zgoos_linux.go:18:16
/usr/lib/go/src/runtime/internal/sys/zgoos_windows.go:17:7: too many errors

A similar error is reported when a different arch is specified as a build tag.

Is there a reason why a build tag with the same name of an os or arch is not rejected?

Thanks.

@perillo perillo changed the title go/build: BuildTags should reject tags with the same name as a know os or arch go/build: BuildTags should reject tags with the same name as a known os or arch Apr 10, 2021
@mknyszek mknyszek added this to the Backlog milestone Apr 12, 2021
@mknyszek
Copy link
Contributor

@mknyszek mknyszek commented Apr 12, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants