Skip to content

x/sys: cacheLineSize redeclared in this block #30668

Closed

Description

@triztian

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

$ go version
go version go1.10.7 darwin/amd64

Does this issue reproduce with the latest release?

No, haven't tested (development is done with 1.10.7)

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

go env Output
 λ ~/go/src/golang.org/x/sys (master): go env
GOARCH="amd64"
GOBIN="/Users/tristian/go/bin"
GOCACHE="/Users/tristian/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tristian/go"
GORACE=""
GOROOT="/usr/local/Cellar/go@1.10/1.10.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go@1.10/1.10.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/g1/v3hz1sm92nv7wbzpg3dx_h_h0000gp/T/go-build319213198=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I just ran go get golang.org/x/sys and ran go build ./...

The commit I checked out was:

commit 572b51eaf7221935bdec454796989ba8318fa6f3 (HEAD -> master, origin/master, origin/HEAD)
Author: Tobias Klauser <tklauser@distanz.ch>
Date:   Thu Mar 7 14:06:33 2019 +0100

    unix: add SetsockoptPacketMreq on Linux

    Add SetsockoptPacketMreq to set packet socket options used to
    configure physical-layer multi‐casting and promiscuous mode
    (PACKET_ADD_MEMBERSHIP, PACKET_DROP_MEMBERSHIP).

    Change-Id: I0f292315ad1c57e6a3d1dd12f5f29be70d8bfd54
    Reviewed-on: https://go-review.googlesource.com/c/sys/+/165977
    Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

And it seems like the wasm constant that is redeclared was instruduced in commit b354f8bf

 λ ~/go/src/golang.org/x/sys (master): git blame cpu/cpu_wasm.go
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  1) // Copyright 2019 The Go Authors. All rights reserved.
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  2) // Use of this source code is governed by a BSD-style
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  3) // license that can be found in the LICENSE file.
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  4)
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  5) package cpu
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  6)
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  7) // We're compiling the cpu package for an unknown (software-abstracted) CPU.
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  8) // Make CacheLinePad an empty struct and hope that the usual struct alignment
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500  9) // rules are good enough.
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500 10)
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500 11) const cacheLineSize = 0
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500 12)
b354f8bf (Bryan C. Mills 2019-03-06 16:31:30 -0500 13) func doinit() {}

What did you expect to see?

No output; a succesful build

What did you see instead?

Build failed with the following output:

$ ~/go/src/golang.org/x/sys (master): go build ./...
# golang.org/x/sys/cpu
cpu/cpu_x86.go:9:23: cacheLineSize redeclared in this block
	previous declaration at cpu/cpu_wasm.go:11:23

Activity

  1. added this to the Unreleased milestone on Mar 8, 2019
  2. ianlancetaylor commented on Mar 8, 2019

    @ianlancetaylor
    Contributor

    This is happening because Go 1.10 doesn't know about wasm. Will send a CL.

  3. triztian commented on Mar 8, 2019

    @triztian
    Author

    Awesome, thank you for the quick reply!!, seems like adding the

    // +build wasm
    

    Build tag to the cpu/cpu_wasm.go fixes the issue. Is that the correct way to fix it?

  4. ianlancetaylor commented on Mar 8, 2019

    @ianlancetaylor
    Contributor
  5. gopherbot commented on Mar 8, 2019

    @gopherbot
    Contributor

    Change https://golang.org/cl/166137 mentions this issue: cpu: add build tag to cpu_wasm.go

  6. locked and limited conversation to collaborators on Mar 7, 2020
  7. added a commit that references this issue on Jun 7, 2024
    584f3b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions