Go: cmd/go, x/vgo: compilation errors upon building

Created on 23 Jul 2018  Â·  17Comments  Â·  Source: golang/go

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

go version go1.11beta2 darwin/amd64

Does this issue reproduce with the latest release?

This is happening with the latest release.

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/myusername/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/myusername/OneDrive/gocode"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/9x/xp9y18vx58q815_7fp24cf5c0000gn/T/go-build936526924=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I just now upgraded from version go1.11beta1 to go1.11beta2.

I'm trying to build a program using the vgo build command, and I'm getting a bunch of errors and failures after the "go.mod" file is built. It doesn't look like it's something particularly due to the packages being included, since this issue occurs with a couple other packages I tried to build.

What did you expect to see?

A successful build.

What did you see instead?

It looks like a few internal packages are not being compiled correctly. There are a lot of "redeclared in this block" errors.

Here's a copy of the complete output by the vgo build command:

$ vgo build
vgo: creating new go.mod: module github.com/dchenk/go-graph-fb
# runtime/internal/sys
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:8:2: ArchFamily redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:8:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:9:2: BigEndian redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:9:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:10:2: CacheLineSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:10:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:11:2: DefaultPhysPageSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:11:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:12:2: PCQuantum redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:12:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:13:2: Int64Align redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:13:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:14:2: HugePageSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:14:29
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:15:2: MinFrameSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:15:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:18:6: Uintreg redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:18:6
# internal/cpu
/usr/local/go/src/internal/cpu/cpu_x86.go:9:7: CacheLineSize redeclared in this block
    previous declaration at /usr/local/go/src/internal/cpu/cpu_wasm.go:7:23
# runtime/internal/atomic
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:14:6: Load redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:13:24
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:20:6: Loadp redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:19:32
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:26:6: Load64 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:25:26
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:32:6: Xadd redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:30:37
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:40:6: Xadd64 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:33:39
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:48:6: Xadduintptr redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:36:47
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:56:6: Xchg redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:39:36
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:64:6: Xchg64 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:42:38
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:72:6: Xchguintptr redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:45:45
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:80:6: And8 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:48:27
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:80:6: too many errors
FrozenDueToAge NeedsInvestigation WaitingForInfo modules

Most helpful comment

Also, as of 1.11beta2 you don't need to type vgo, that functionality has been moved into the go command.

I recommend, unless you want to use the old vgo fork, to delete, vgo from your $PATH.

All 17 comments

the same to you, i use docker golang:1.11beta2-stretch

I just now upgraded from version go1.11beta2 to go1.11beta2.

How did you upgrade from one version to another? It is common to see the class of error you describe if one version of Go is unpacked atop another.

Also, as of 1.11beta2 you don't need to type vgo, that functionality has been moved into the go command.

I recommend, unless you want to use the old vgo fork, to delete, vgo from your $PATH.

@davecheney I used the standard installer for MacOS from golang.org/dl

Is there thorough, official documentation of the new "go build"?

Try tip.golang.org for the pre release docs.

On 23 Jul 2018, at 14:33, Dmitriy notifications@github.com wrote:

@davecheney I used the standard installer for MacOS from golang.org/dl

Is there thorough, official documentation of the new "go build"?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

I have solved it because the different versions of go runtime are covered by each other

I just now upgraded from version go1.11beta2 to go1.11beta2.

That looks like a typo. What version did you upgrade from?

I used the standard installer for MacOS from golang.org/dl

Did you rebuild the vgo binary after upgrading the Go toolchain? The _wasm.go suffix is an implicit build constraint in Go 1.11 but not in Go 1.10, so a vgo built from 1.10 will not work with standard library sources from 1.11beta2.

Did you install the Go toolchain from source, or using the binary installer? (The standalone vgo binary requires a source directory that matches the installed runtime, so if your installed runtime is go1.11beta2 and the source directory is older, that could be the problem.)

@bcmills you're right that was a typo; I fixed it to say I upgraded from go1.11beta1.

I did not rebuilt vgo after upgrading. Any suggestions on how to go about doing that safely?

(I had installed Go using the standard Installer for MacOS at https://golang.org/dl/)

I did not rebuilt vgo after upgrading. Any suggestions on how to go about doing that safely?

Honestly, at the moment vgo and go1.11beta2 are pretty much equivalent. I second @davecheney's advice to use the go tool instead.

(The reason you'd want to use vgo at this point is to use module support with an older Go toolchain. If you're already on 1.11beta2 that shouldn't be an issue. After 1.11 is released, it may once again become worthwhile to use vgo to pick up changes in between 1.11 and 1.12, but hopefully those changes won't be particularly urgent to upgrade past.)

That answers my questions. Thank you all!

I installed go1.11beta2 linux/amd64 on a freshly installed system and faced a similar error. I do have an old GOPATH but the GOROOT (Go's own installation) is fresh. I did not upgrade from an older version of Go.

$ vgo build                                                                         
go: creating new go.mod: module github.com/some/repo
go: copying requirements from Gopkg.lock
# runtime/internal/atomic
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:14:6: Load redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:13:24
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:20:6: Loadp redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:19:32
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:26:6: Load64 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:25:26
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:32:6: Xadd redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:30:37
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:40:6: Xadd64 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:33:39
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:48:6: Xadduintptr redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:36:47
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:56:6: Xchg redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:39:36
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:64:6: Xchg64 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:42:38
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:72:6: Xchguintptr redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:45:45
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:80:6: And8 redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64x.go:48:27
/usr/local/go/src/runtime/internal/atomic/atomic_wasm.go:80:6: too many errors
# runtime/internal/sys
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:8:2: ArchFamily redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:8:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:9:2: BigEndian redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:9:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:10:2: CacheLineSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:10:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:11:2: DefaultPhysPageSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:11:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:12:2: PCQuantum redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:12:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:13:2: Int64Align redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:13:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:14:2: HugePageSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:14:29
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:15:2: MinFrameSize redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:15:24
/usr/local/go/src/runtime/internal/sys/arch_wasm.go:18:6: Uintreg redeclared in this block
    previous declaration at /usr/local/go/src/runtime/internal/sys/arch_amd64.go:18:6
# internal/cpu
/usr/local/go/src/internal/cpu/cpu_x86.go:9:7: CacheLineSize redeclared in this block
    previous declaration at /usr/local/go/src/internal/cpu/cpu_wasm.go:7:23

Also, I don't think go and vgo are the same even in beta2. I tried go build and it simply complains that a dependency is missing while as vgo installs the dependencies and then resuts in the above error.

 go build                                                                         
# github.com/some/repo
./main.go:8:14: undefined: sqs

I think I misunderstood the comment about vgo. vgo is of course referring to an old install and lives inside GOPATH.

I think you’ve messed up your go installation.

I’d delete it, download GO1.11beta2 and the use go, not vgo.

I think that will resolve your problem.

On 26 Jul 2018, at 12:11, Owais Lone notifications@github.com wrote:

I think I misunderstood the comment about vgo. vgo is of course referring to an old install and lives inside GOPATH.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Yup. I had old 1.10 binaries left in GOPATH which were not working. Thanks

I had this error appear in GoLand after I upgraded Go from 1.10 to 1.11. The problem was resolved when I reinstalled vgo go get -u golang.org/x/vgo using 1.11.

The vgo codebase is a fork of Go 1.11 for use only with go 1.10. If you are using go 1.11, then do not combine it with vgo, it will not lead to success.

On 9 Sep 2018, at 02:37, nicerobot notifications@github.com wrote:

I had this error appear in GoLand when I upgraded Go from 1.10 to 1.11. The problem was resolved when I reinstalled vgo go get -u golang.org/x/vgo using 1.11.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

GoLand seems to do the right thing when vgo is select with the go1.11 SDK also selected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bradfitz picture bradfitz  Â·  3Comments

longzhizhi picture longzhizhi  Â·  3Comments

stub42 picture stub42  Â·  3Comments

enoodle picture enoodle  Â·  3Comments

myitcv picture myitcv  Â·  3Comments