You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When compiling standard library as shared library and use buildmode pie to compile position indedependent executable from our code it fails, but if we do not compile standard library as shared library but use our own libraries as shared library it compiles successfully
What version of Go are you using (go version)?
tested with both Master and 1.7.1
go version go1.7.1 linux/amd64
&
go version devel +d817c4e Fri Sep 9 20:07:43 2016 +0000 linux/amd64
What operating system and processor architecture are you using (go env)?
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' std
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack1
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack2
the above all built successfully
the following should succeed now:
go install -v -buildmode=pie -linkshared -pkgdir '/mnt/lib' piet
What did you see instead?
but it fails with:
go install -v -buildmode=pie -linkshared -pkgdir '/mnt/lib' piet
piet
# piet
/src/dev/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/mnt/lib//libstd.so: undefined reference to `main.init'
/mnt/lib//libstd.so: undefined reference to `main.main'
collect2: error: ld returned 1 exit status
What ELSE?
If you do not build the std library and skip that part
rm -rf /mnt/lib
mkdir -p /mnt/lib
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack1
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack2
go install -v -buildmode=pie -linkshared -pkgdir '/mnt/lib' piet
It successfully builds pie binary and uses pack1 and pack2 shared libraries , you can check that with ldd
The text was updated successfully, but these errors were encountered:
quentinmit
changed the title
builmode pie with linkshared when std library is also shared fails
cmd/compile: builmode pie with linkshared when std library is also shared fails
Sep 12, 2016
When compiling standard library as shared library and use buildmode pie to compile position indedependent executable from our code it fails, but if we do not compile standard library as shared library but use our own libraries as shared library it compiles successfully
What version of Go are you using (
go version
)?tested with both Master and 1.7.1
go version go1.7.1 linux/amd64
&
go version devel +d817c4e Fri Sep 9 20:07:43 2016 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/src/dev"
GORACE=""
GOROOT="/src/dev"
GOTOOLDIR="/src/dev/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build475536354=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
and for Go 1.7.1:
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build856345781=/tmp/go-build -gno-record-gcc-switches"
What did you do?
piet.go
pack1 package:
pack1.go
pack2 package:
pack2.go
What did you expect to see?
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' std
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack1
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack2
the above all built successfully
the following should succeed now:
go install -v -buildmode=pie -linkshared -pkgdir '/mnt/lib' piet
What did you see instead?
but it fails with:
go install -v -buildmode=pie -linkshared -pkgdir '/mnt/lib' piet
What ELSE?
If you do not build the std library and skip that part
rm -rf /mnt/lib
mkdir -p /mnt/lib
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack1
go install -v -buildmode=shared -linkshared -pkgdir '/mnt/lib/' pack2
go install -v -buildmode=pie -linkshared -pkgdir '/mnt/lib' piet
It successfully builds pie binary and uses pack1 and pack2 shared libraries , you can check that with ldd
The text was updated successfully, but these errors were encountered: