golang/go

cmd/vet: +build comment error is confusingly worded

Open

#31,410 opened on Apr 11, 2019

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
AnalysisNeedsFixhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Please answer these questions before submitting your issue. Thanks!

What did you do?

Hello up there. I was updating my tracing/xruntime package for Go1.12 and hit test error:

.../src/lab.nexedi.com/kirr/go123/tracing/internal/xruntime$ go test
# lab.nexedi.com/kirr/go123/tracing/internal/xruntime
./runtime_g_amd64.s:3:1: +build comment must appear before package clause and be followed by a blank line
FAIL    lab.nexedi.com/kirr/go123/tracing/internal/xruntime [build failed]

The error here complains about +build directive in assembly file:

---- 8< ---- (runtime_g_amd64.s)

#include "textflag.h"

// +build amd64 amd64p

// func getg() *g
TEXT ·getg(SB),NOSPLIT,$0-8
	MOVQ (TLS), R14
	MOVQ R14, ret+0(FP)
	RET

(https://lab.nexedi.com/kirr/go123/blob/7ee2de42/tracing/internal/xruntime/runtime_g_amd64.s)

It was working with Go1.11 and previous releases.

What did you expect to see?

Build and test succeed; test pass, as with e.g. Go1.11:

.../src/lab.nexedi.com/kirr/go123/tracing/internal/xruntime$ go1.11 test -v
=== RUN   TestStartStopTheWorld
--- PASS: TestStartStopTheWorld (1.00s)
PASS
ok      lab.nexedi.com/kirr/go123/tracing/internal/xruntime     1.003s

What did you see instead?

.../src/lab.nexedi.com/kirr/go123/tracing/internal/xruntime$ go1.12 test -v
# lab.nexedi.com/kirr/go123/tracing/internal/xruntime
./runtime_g_amd64.s:3:1: +build comment must appear before package clause and be followed by a blank line
FAIL    lab.nexedi.com/kirr/go123/tracing/internal/xruntime [build failed]

System details

go version go1.12.3 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/kirr/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kirr/go"
GOPROXY=""
GORACE=""
GOROOT="/home/kirr/src/tools/go/go"
GOTMPDIR=""
GOTOOLDIR="/home/kirr/src/tools/go/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.12.3 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.3
uname -sr: Linux 4.19.0-4-amd64
Distributor ID:	Debian
Description:	Debian GNU/Linux buster/sid
Release:	testing
Codename:	buster
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.28-8) stable release version 2.28.
gdb --version: GNU gdb (Debian 8.2.1-2) 8.2.1

Contributor guide