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: go install -buildmode=shared -linkshared std doesn't work as expected #28722

Open
rezaalavi opened this Issue Nov 11, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@rezaalavi

rezaalavi commented Nov 11, 2018

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

The problem appears in all versions after 1.9.1 including 1.9.1. All versions before 1.9.1 work as expected.

Does this issue reproduce with the latest release?

Yes.

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

go env Output
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go-src"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build001874867=/tmp/go-build"
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?

I run "go install -buildmode=shared -linkshared std" to generated a shared library for the std.

I have run the above on all recent go version from 1.6 to 1.11.
Since 1.9.1 the above doesn't work anymore and producses a warning.
As a result we cannot dynamically link our code to std library in any version more than 1.8.7.

What did you expect to see?

success without any warning.

What did you see instead?

/usr/bin/ld: warning: .init_array section has zero size

@ianlancetaylor ianlancetaylor changed the title from go install -buildmode=shared -linkshared std doesn't work as expected to cmd/link: go install -buildmode=shared -linkshared std doesn't work as expected Nov 12, 2018

@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Nov 12, 2018

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Nov 12, 2018

Running go install -buildmode=shared -linkshared std works for me. I just tried it on amd64 GNU/Linux.

What C linker are you using? For me /usr/bin/ld --version prints

GNU ld (GNU Binutils for Debian) 2.30
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
@rezaalavi

This comment has been minimized.

rezaalavi commented Nov 12, 2018

It is the one that comes with Centos 6.

GNU ld version 2.20.51.0.2-5.48.el6 20100205
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Nov 13, 2018

Hmmm, that's an 8 year old linker. This is just a warning, right? The program still completes and works?

@gopherbot

This comment has been minimized.

gopherbot commented Dec 7, 2018

Change https://golang.org/cl/153257 mentions this issue: cmd/link: only create .init_array section if not empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment