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/go: test binary includes $WORK paths #3748

Closed
gopherbot opened this issue Jun 18, 2012 · 10 comments
Closed

cmd/go: test binary includes $WORK paths #3748

gopherbot opened this issue Jun 18, 2012 · 10 comments

Comments

@gopherbot
Copy link

by leterip:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Build a test binary
2. Print the sha sum of the binary
3. Repeat

What is the expected output?

The same hash.

What do you see instead?

Different hashes.

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g.

Which operating system are you using?

OS X 10.7.3 (Lion)

Which version are you using?  (run 'go version')

go version go1.0.2

Please provide any additional information below.

This doesn't appear to happen on non-test builds. For example, 

$ go get app
$ shasum bin/app
5c3aaef3d9a2d927d172065db38657aac11f4afb  bin/app
$ rm bin/app
$ go get app
$ shasum bin/app
5c3aaef3d9a2d927d172065db38657aac11f4afb  bin/app

But,

$ go test -c app
$ shasum app.test
faa5f17ee8461d1c2241cf6e79ac2c8a1e91a7d3  app.test
$ go test -c app
$ shasum app.test
b1bc4693c9c28f857d0a2f20192e00c8cb79d927  app.test

Perhaps a compiler flag would be appropriate?
@alberts
Copy link
Contributor

alberts commented Jun 18, 2012

Comment 1:

I think filenames for stuff in TMPPATH, like _testmain.go, could be causing this. I
think you'll have the same problem with cgo apps. Not ideal.

@alberts
Copy link
Contributor

alberts commented Jun 18, 2012

Comment 2:

TMPDIR, not TMPPPATH.

@rsc
Copy link
Contributor

rsc commented Jun 19, 2012

Comment 3:

We can mangle the archives using go pack P to strip those paths.

Status changed to Accepted.

@minux
Copy link
Member

minux commented Jul 3, 2012

Comment 4:

http://golang.org/cl/6357064/
fixing the problem for cgo binaries is not as easy and I'm looking into it.

@minux
Copy link
Member

minux commented Aug 7, 2012

Comment 5:

This issue was closed by revision df623d0.

Status changed to Fixed.

@alberts
Copy link
Contributor

alberts commented Aug 7, 2012

Comment 6:

Does this fix it for cgo binaries? If not, maybe we should open another issue?

@minux
Copy link
Member

minux commented Aug 7, 2012

Comment 7:

it won't fix cgo binaries, and in fact, i doubt we can fix it completely.
for one thing, we pass -g to gcc, and gcc will surely embed the full path
to source file in the object files.
free free to open an issue for it though.

@ianlancetaylor
Copy link
Contributor

Comment 8:

GCC supports changing the path names used in the debug info, for situations like this. 
See the -fdebug-prefix-map option.
(I don't know if there are other problems here.)

@minux
Copy link
Member

minux commented Aug 7, 2012

Comment 9:

thanks iant, i will try to see if we can build identical cgo binaries for the same
source code.

@alberts
Copy link
Contributor

alberts commented Aug 7, 2012

Comment 10:

It might also be interesting to look at how Fedora works with debuginfos. You can build
an RPM almost anywhere, but when you install the debuginfo RPM, the source always goes
into /usr/src/whatever and you can set breakpoints accordingly.
It would be nice it Go worked with this scheme. I think it mostly will, but cgo has the
interesting property that some of the source that gets compiled into the binary only
exists in the work directory and gets deleted. I haven't debugged a cgo binary recently,
so I'm not sure what will happen with stack frames associated with this non-existent
code?

minux added a commit that referenced this issue May 11, 2015
««« backport c1ce95068533
cmd/go: remove $WORK paths in generated binaries
        Fixes #3748.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6357064

»»»
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

5 participants