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 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@perillo
Copy link
Contributor

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

CC @rsc via https://dev.golang.org/owners.

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 12, 2021
@qdm12
Copy link
Contributor

qdm12 commented Aug 20, 2021

I obtain a very similar error but on Windows.

$ go version
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\user\AppData\Local\go-build
set GOENV=C:\Users\user\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\user\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\user\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\somerepo\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\user\AppData\Local\Temp\go-build2520574871=/tmp/go-build -gno-record-gcc-switches

Steps to reproduce:

  1. Clone some repository using syscall, in my case:

    git clone https://github.com/qdm12/gluetun.git .
  2. Run tests with go test -tags=linux ./...

Errors shown as:

C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:8:7: GOOS redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:8:14: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:10:7: GoosAix redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:10:17: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:11:7: GoosAndroid redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:11:21: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:12:7: GoosDarwin redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:12:20: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:13:7: GoosDragonfly redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:13:23: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:14:7: GoosFreebsd redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:14:21: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:15:7: GoosHurd redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:15:18: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:16:7: GoosIllumos redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:16:21: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:17:7: GoosIos redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:17:17: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:18:7: GoosJs redeclared in this block
        C:\Program Files\Go\src\runtime\internal\sys\zgoos_linux.go:18:16: previous declaration
C:\Program Files\Go\src\runtime\internal\sys\zgoos_windows.go:18:7: too many errors

Followed by a few [build failed] for each sub-package of the repository

@ross-spencer
Copy link

Golang 1.20.2 here, tried the same lib as above after seeing it on another repo.

go test -tags=windows ./...

go: downloading golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224
# internal/goos
/usr/local/go/src/internal/goos/zgoos_windows.go:7:7: GOOS redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:7:7: other declaration of GOOS
/usr/local/go/src/internal/goos/zgoos_windows.go:9:7: IsAix redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:9:7: other declaration of IsAix
/usr/local/go/src/internal/goos/zgoos_windows.go:10:7: IsAndroid redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:10:7: other declaration of IsAndroid
/usr/local/go/src/internal/goos/zgoos_windows.go:11:7: IsDarwin redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:11:7: other declaration of IsDarwin
/usr/local/go/src/internal/goos/zgoos_windows.go:12:7: IsDragonfly redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:12:7: other declaration of IsDragonfly
/usr/local/go/src/internal/goos/zgoos_windows.go:13:7: IsFreebsd redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:13:7: other declaration of IsFreebsd
/usr/local/go/src/internal/goos/zgoos_windows.go:14:7: IsHurd redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:14:7: other declaration of IsHurd
/usr/local/go/src/internal/goos/zgoos_windows.go:15:7: IsIllumos redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:15:7: other declaration of IsIllumos
/usr/local/go/src/internal/goos/zgoos_windows.go:16:7: IsIos redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:16:7: other declaration of IsIos
/usr/local/go/src/internal/goos/zgoos_windows.go:17:7: IsJs redeclared in this block
	/usr/local/go/src/internal/goos/zgoos_linux.go:17:7: other declaration of IsJs
/usr/local/go/src/internal/goos/zgoos_windows.go:17:7: too many errors
FAIL	github.com/qdm12/gluetun/internal/configuration/settings [build failed]
?   	github.com/qdm12/gluetun/internal/constants/openvpn	[no test files]
FAIL	github.com/qdm12/gluetun/internal/configuration/sources/env [build failed]
?   	github.com/qdm12/gluetun/internal/constants/vpn	[no test files]
FAIL	github.com/qdm12/gluetun/internal/constants/providers [build failed]
FAIL	github.com/qdm12/gluetun/internal/dns [build failed]
FAIL	github.com/qdm12/gluetun/internal/firewall [build failed]
FAIL	github.com/qdm12/gluetun/internal/healthcheck [build failed]
FAIL	github.com/qdm12/gluetun/internal/httpserver [build failed]
FAIL	github.com/qdm12/gluetun/internal/models [build failed]
FAIL	github.com/qdm12/gluetun/internal/netlink [build failed]
FAIL	github.com/qdm12/gluetun/internal/openvpn [build failed]
FAIL	github.com/qdm12/gluetun/internal/openvpn/extract [build failed]
FAIL	github.com/qdm12/gluetun/internal/pprof [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/common [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/custom [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/expressvpn [build failed]
?   	github.com/qdm12/gluetun/internal/provider/privateinternetaccess/presets	[no test files]
FAIL	github.com/qdm12/gluetun/internal/provider/ipvanish/updater [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/ivpn [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/ivpn/updater [build failed]
?   	github.com/qdm12/gluetun/internal/provider/surfshark/servers	[no test files]
FAIL	github.com/qdm12/gluetun/internal/provider/mullvad [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/mullvad/updater [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/privateinternetaccess [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/slickvpn/updater [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/surfshark/updater [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/utils [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/vpnsecure/updater [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/wevpn [build failed]
FAIL	github.com/qdm12/gluetun/internal/provider/windscribe [build failed]
FAIL	github.com/qdm12/gluetun/internal/routing [build failed]
FAIL	github.com/qdm12/gluetun/internal/storage [build failed]
FAIL	github.com/qdm12/gluetun/internal/tun [build failed]
FAIL	github.com/qdm12/gluetun/internal/updater/html [build failed]
FAIL	github.com/qdm12/gluetun/internal/updater/resolver [build failed]
FAIL	github.com/qdm12/gluetun/internal/wireguard [build failed]
FAIL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

4 participants