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

misc/cgo/testcshared failure, linking to wrong libgo.so #17986

Closed
hartzell opened this issue Nov 19, 2016 · 3 comments
Closed

misc/cgo/testcshared failure, linking to wrong libgo.so #17986

hartzell opened this issue Nov 19, 2016 · 3 comments

Comments

@hartzell
Copy link

TL;DR: I needed to change libgo.so to ./libgo.so on one line in test.bash to make misc/cgo/testcshared pass and am looking for feedback.

Please answer these questions before submitting your issue. Thanks!

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

Building 1.7.3 with a go built from release-branch.go1.4

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

go env output from the successful build mentioned below:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/rss/spack-20161101/opt/spack/linux-centos7-x86_64/gcc-5.4.0/go-1.7.3-wzhabet756id3kyoqr6v6hnrwopfkpic"
GOTOOLDIR="/rss/spack-20161101/opt/spack/linux-centos7-x86_64/gcc-5.4.0/go-1.7.3-wzhabet756id3kyoqr6v6hnrwopfkpic/pkg/tool/linux_amd64"
CC="/rss/spack-20161101/lib/spack/env/gcc/gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="/rss/spack-20161101/lib/spack/env/gcc/g++"
CGO_ENABLED="1"

I'm working in a DigitalOcean droplet based on their CentOS7 image with a minimal set of packages added. I've worked through the problem described in #16283 by adding the kernel boot flag. I also had to add glibc-static to my "minimal" set of packages so that the cgo static linking tests pass.

What did you do?

I'm updating go packaging in the spack package manager.

I've updated their go-bootstrap package to use release-branch.go1.4 instead of 1.4.2 to pick up Brad's timezone fix. I have not yet submitted a pull request to the spack project for this change (but will).

I'm using that go-bootstrap package to build 1.7.3.

I've updated their go package to include an entry for the 1.7.3 tag.

The testing step has been failing in misc/cgo/testcshared with this message:

./testp: symbol lookup error: ./testp: undefined symbol: DidInitRun

After drilling down into the tests to the point where I was able to build the test itself and replicate the failure, I noticed that testp was linking against the "wrong" libgo.so. When I added a "./" to the shared library name, it linked against the "right" libgo.so the test passed.

[hartzelg@spack-0 testcshared]$ $(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
[hartzelg@spack-0 testcshared]$ ./testp
./testp: symbol lookup error: ./testp: undefined symbol: DidInitRun
[hartzelg@spack-0 testcshared]$ ldd testp
	linux-vdso.so.1 =>  (0x00007ffcd83c1000)
	libgo.so => /rss/spack-20161101/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gcc-5.4.0-5ugmutg4tsvybv3zsrhfa5h67ltzrc5i/lib64/libgo.so (0x00007fdffe6aa000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdffe487000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fdffe0c5000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fdffddc3000)
	libgcc_s.so.1 => /rss/spack-20161101/opt/spack/linux-centos7-x86_64/gcc-4.8.5/gcc-5.4.0-5ugmutg4tsvybv3zsrhfa5h67ltzrc5i/lib64/libgcc_s.so.1 (0x00007fdffdbab000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fdfff8ea000)
[hartzelg@spack-0 testcshared]$ pwd
/rss/spack-20161101/var/spack/stage/go-1.7.3-wzhabet756id3kyoqr6v6hnrwopfkpic/go/misc/cgo/testcshared
[hartzelg@spack-0 testcshared]$ $(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c ./libgo.$libext
[hartzelg@spack-0 testcshared]$ ldd testp
	linux-vdso.so.1 =>  (0x00007fffa87d8000)
	./libgo.so (0x00007f520d4d3000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f520d2b0000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f520ceee000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f520d7da000)
[hartzelg@spack-0 testcshared]$ ./testp
PASS

If I patch the test.bash script like so:

--- misc/cgo/testcshared/test.bash.orig	2016-11-19 00:00:11.917000000 +0000
+++ misc/cgo/testcshared/test.bash	2016-11-19 00:00:22.081000000 +0000
@@ -107,7 +107,7 @@

 # test0: exported symbols in shared lib are accessible.
 # TODO(iant): using _shared here shouldn't really be necessary.
-$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c libgo.$libext
+$(go env CC) ${GOGCCFLAGS} -I ${installdir} -o testp main0.c ./libgo.$libext
 binpush testp

 output=$(run LD_LIBRARY_PATH=. ./testp)

then I can build 1.7.3 successfully.

Since the 1.7.3 release has been in the wild for a while and I don't see any other issues about this I suspect it's related to the gymanstics that Spack does to support multiple installations of compilers and libraries and etc....

I'm inclined to add a patch to test.bash to Spack's install step (as above) but I'd like to get feedback from more experienced gophers first.

Comments?

@minux
Copy link
Member

minux commented Nov 19, 2016 via email

@ianlancetaylor
Copy link
Contributor

It's normal to install a file named libgo.so, since the linker will look for an extension of ".so" when resolving a -lgo option. It will be a symlink to the real file with the version number.

I'll add the ./, it's the right thing to do anyhow.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/33413 mentions this issue.

hartzell added a commit to hartzell/spack that referenced this issue Nov 19, 2016
Switched from pulling from the git repository to using the source
tarballs and added digest values.

Added support for 1.7.3, continued supporting 1.6.2, including patches
for a couple of problems (details in
[17545](golang/go#17545) and
[17986](golang/go#17986).

Dropped support for 1.5.4 and 1.4.2 because they no longer pass their
tests and the patches above to not apply.
tgamblin pushed a commit to spack/spack that referenced this issue Nov 24, 2016
* Update go-bootstrap package

The last C based Go src tree was the 1.4 series.  For a while they
were cutting new releases so that people could bootstrap from a C only
system.  Now they're recommending that you either use the release-1.4
branch or that you use a date-stamped tarball that they'll produce on
an as-needed basis.

There are several issues that keep 1.4.2 from building on a CentOS 7
system.

I've switched to the date based tarball.

The cgo bits were also mis-behaving, but they're not needed for the
bootstrapping task so I've set an environment variable that disables
them.

Details [on the install-from-source
page](https://golang.org/doc/install/source#go14) and these issues:

- golang/go#17545
- golang/go#16352.

* Update go package

Switched from pulling from the git repository to using the source
tarballs and added digest values.

Added support for 1.7.3, continued supporting 1.6.2, including patches
for a couple of problems (details in
[17545](golang/go#17545) and
[17986](golang/go#17986).

Dropped support for 1.5.4 and 1.4.2 because they no longer pass their
tests and the patches above to not apply.
citibeth pushed a commit to citibeth/spack that referenced this issue Dec 4, 2016
* Update go-bootstrap package

The last C based Go src tree was the 1.4 series.  For a while they
were cutting new releases so that people could bootstrap from a C only
system.  Now they're recommending that you either use the release-1.4
branch or that you use a date-stamped tarball that they'll produce on
an as-needed basis.

There are several issues that keep 1.4.2 from building on a CentOS 7
system.

I've switched to the date based tarball.

The cgo bits were also mis-behaving, but they're not needed for the
bootstrapping task so I've set an environment variable that disables
them.

Details [on the install-from-source
page](https://golang.org/doc/install/source#go14) and these issues:

- golang/go#17545
- golang/go#16352.

* Update go package

Switched from pulling from the git repository to using the source
tarballs and added digest values.

Added support for 1.7.3, continued supporting 1.6.2, including patches
for a couple of problems (details in
[17545](golang/go#17545) and
[17986](golang/go#17986).

Dropped support for 1.5.4 and 1.4.2 because they no longer pass their
tests and the patches above to not apply.
hartzell added a commit to spack/spack that referenced this issue Feb 7, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
tgamblin pushed a commit to spack/spack that referenced this issue Feb 8, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
healther pushed a commit to electronicvisions/spack that referenced this issue Feb 9, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
diaena pushed a commit to diaena/spack that referenced this issue May 26, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
xavierandrade pushed a commit to xavierandrade/spack that referenced this issue Jun 16, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
amklinv pushed a commit to spack/spack that referenced this issue Jul 17, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
healther pushed a commit to electronicvisions/spack that referenced this issue Jul 26, 2017
[The fix](golang/go#17986) for the small buglet addressed by `misc-cgo-testcshared.patch` has been merged into the tree a while back.  I was surprised to see that it wasn't in 1.7.5 and did a bit of digging.  It is *has not* been merged into the 1.7 branch but it *has* been merged into 1.8 (and therefor the patch will no longer be necessary).

Figured I'd document my digging for the next person to come along.
@golang golang locked and limited conversation to collaborators Nov 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants