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/link: linking with -linkshared fails if a package depends on a method in another pkg indirectly #22998
Comments
CC @mwhudson |
Ping @mwhudson |
Oops, sorry for missing this. I can reproduce the problem with the supplied script. I guess the linker needs to be fixed to load any go shared libraries that are dependencies of ones it loads. This suuuper simple patch seems to fix it:
but that almost too easy... |
I found a similar but different bug in Thanks, |
@mwhudson Do you want to try sending in your patch? |
I can't recreate this problem, though I don't know what would have fixed it. Is still an issue on tip? |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
Yes. go1.9.2 is the latest release as of 2017-12-04.
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/yunabe/local/gocode"
GORACE=""
GOROOT="/usr/lib/go-1.9"
GOTOOLDIR="/usr/lib/go-1.9/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build706131046=/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?
lib0
) that defines a type and a method and uses a standard library (e.g. "fmt")lib1
) that defines an instance of the type abovelib2
) that calls a method from the instance defined in (2).-buildmode=shared -linkshared
with the same-pkgdir
.I created a git repository to reproduce this bug (yunabe/gobug22998). You can reproduce this bug by running
go get -d github.com/yunabe/gobug22998 $GOPATH/src/github.com/yunabe/gobug22998/run.sh
What did you expect to see?
libgithub.com-yunabe-gobug22998-lib2.so
is created corretly and it depends on lib0.so and lib1.soWhat did you see instead?
Got errors from the linker
Notes
There is a workaround for this bug. If I add an dependency to lib0 explicitly by importing _ "github.com/yunabe/linkbug/lib0" in lib2/src.go, everything works fine. Thus, I guess link with -linkshared fails to resolve indirect dependencies to methods.
Also, if you remove
import "fmt"
from lib0/src.go, you can build lib2.so without hitting this bug.The text was updated successfully, but these errors were encountered: