Skip to content
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

Closed
EricSites opened this issue Jan 25, 2018 · 6 comments
Closed

cmd/cgo: multiple definition of `_cgo_05dc84caff82_Cfunc_sysconf' #23555

EricSites opened this issue Jan 25, 2018 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@EricSites
Copy link

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

@ianlancetaylor
Copy link
Contributor

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.

@EricSites
Copy link
Author

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.

@ianlancetaylor ianlancetaylor changed the title multiple definition of `_cgo_05dc84caff82_Cfunc_sysconf' cmd/cgo: multiple definition of `_cgo_05dc84caff82_Cfunc_sysconf' Jan 25, 2018
@ianlancetaylor
Copy link
Contributor

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.

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 25, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Jan 25, 2018
@EricSites
Copy link
Author

EricSites commented Jan 25, 2018

I was not having this problem a year ago. Is there a workaround that I can use before the release of go 1.11?

@ianlancetaylor
Copy link
Contributor

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.

@gopherbot
Copy link

Change https://golang.org/cl/118739 mentions this issue: cmd/cgo: add import path to hash

dna2github pushed a commit to dna2fork/go that referenced this issue Jun 14, 2018
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>
@golang golang locked and limited conversation to collaborators Jun 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants