go: cmd/go: go test -coverpkg=./... -race does not rebuild sync/atomic

Please answer these questions before submitting your issue. Thanks!

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

go version devel +e776975 Sat Dec 31 18:54:27 2016 +0000 linux/amd64

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

GOARCH=“amd64” GOBIN=“” GOEXE=“” GOHOSTARCH=“amd64” GOHOSTOS=“linux” GOOS=“linux” GOPATH=“/home/travis/gopath” GORACE=“” GOROOT=“/home/travis/.gimme/versions/go” GOTOOLDIR=“/home/travis/.gimme/versions/go/pkg/tool/linux_amd64” GCCGO=“gccgo” CC=“gcc” GOGCCFLAGS=“-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build901867199=/tmp/go-build” CXX=“g++” CGO_ENABLED=“1” PKG_CONFIG=“pkg-config” CGO_CFLAGS=“-g -O2” CGO_CPPFLAGS=“” CGO_CXXFLAGS=“-g -O2” CGO_FFLAGS=“-g -O2” CGO_LDFLAGS=“-g -O2”

What did you do?

If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.

  1. create an empty package https://github.com/hirochachacha/empty
  2. add .travis.yml
language: go
go:
    - 1.5
    - 1.6
    - 1.7
    - tip
script:
- go test -coverpkg=./... -race -v
  1. then, I see a build error. https://travis-ci.org/hirochachacha/empty
$ go test -coverpkg=./... -race -v
# github.com/hirochachacha/empty
/tmp/go-build559712700/github.com/hirochachacha/empty/_obj/empty.go:3: can't find import: "sync/atomic"

What did you expect to see?

no errors.

What did you see instead?

an error.

I could not reproduce it on my mac and linux. However, I can reproduce it on a docker container.

docker run -it quay.io/travisci/travis-go /bin/bash

and,

su - travis
GIMME_OUTPUT=$(gimme tip) && eval "$GIMME_OUTPUT"
export GOPATH=$HOME/gopath
export PATH=$HOME/gopath/bin:$PATH
go get github.com/hirochachacha/empty
cd $HOME/gopath/src/github.com/hirochachacha/empty
go test -coverpkg=./... -race -v

I have no clue. It may be travis’s issue? or something I am missing.

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (13 by maintainers)

Most upvoted comments

-coverpkg=./... and -race will work alone, but both of the flags together fail.

$ go test -coverpkg=./... -v
?   	github.com/hirochachacha/empty	[no test files]

$ go test -race -v
?   	github.com/hirochachacha/empty	[no test files]

$ go test -coverpkg=./... -race -v
# github.com/hirochachacha/empty
/tmp/go-build463635544/github.com/hirochachacha/empty/_obj/empty.go:3: can't find import: "sync/atomic"

$ cat /tmp/go-build595576066/github.com/hirochachacha/empty/_obj/empty.go -n
     1	package empty
     2	
     3	import _cover_atomic_ "sync/atomic"
     4	
     5	var _ = _cover_atomic_.AddUint32
     6	
     7	var GoCover_0 = struct {
     8		Count     [0]uint32
     9		Pos       [3 * 0]uint32
    10		NumStmt   [0]uint16
    11	} {
    12		Pos: [3 * 0]uint32{
    13		},
    14		NumStmt: [0]uint16{
    15		},
    16	}

I’ve isolated the issue to, cmd/compile not being able to compile a program importing std-lib with -race. It can compile it without -race though.

Smaller repro case,

$ cat /tmp/p.go 
package p

import _ "sync/atomic"

$ go tool compile -o /dev/null /tmp/p.go 
# ... succeeds ...

$ go tool compile -o /dev/null -race /tmp/p.go 
/tmp/p.go:3: can't find import: "sync/atomic"

Looking into why cmd/compile fails to compile it with -race.