-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cgo: multiple definition of `_cgo_05dc84caff82_Cfunc_sysconf' #23555
Comments
Can you give us a way to recreate the problem? I don't see any vendor directory in github.com/google/cadvisor. I can't clone github.com/dockarray1/agent: it says I need a username. |
I will see if I can create an example: But cadvisor vendor dir is here: https://github.com/google/cadvisor/tree/master/vendor dockarray1/agent is an internal project that I can't share the source. |
Thanks. I think I see the problem. The cgo command uses a hash of the source files to pick a unique name for the globally visible C function. This strategy fails when the exact same package is vendored into a program in two different locations. |
I was not having this problem a year ago. Is there a workaround that I can use before the release of go 1.11? |
The workaround would be to change one of the copies. Change a file that does import "C" in any way, for example by adding a comment. |
Change https://golang.org/cl/118739 mentions this issue: |
This avoids name conflicts when two identical packages use cgo. This can happen in practice when the same package is vendored multiple times in a single build. Fixes golang#23555 Change-Id: I9f0ec6db9165dcf9cdf3d314c668fee8ada18f9c Reviewed-on: https://go-review.googlesource.com/118739 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
What version of Go are you using (
go version
)?go version go1.9.3 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eric/dev/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build111158852=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
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"
What did you do?
go build
What did you expect to see?
Nothing
What did you see instead?
go build
github.com/dockarray1/agent
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-071896903/000008.o: In function
_cgo_05dc84caff82_Cfunc_sysconf': /tmp/go-build/github.com/google/cadvisor/vendor/github.com/opencontainers/runc/libcontainer/system/_obj/cgo-gcc-prolog:32: multiple definition of
_cgo_05dc84caff82_Cfunc_sysconf'/tmp/go-link-071896903/000007.o:/tmp/go-build/github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/system/_obj/cgo-gcc-prolog:32: first defined here
collect2: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered: