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/cgo: cgo binaries change each time you build them #5170

Closed
alberts opened this issue Mar 31, 2013 · 10 comments
Closed

cmd/cgo: cgo binaries change each time you build them #5170

alberts opened this issue Mar 31, 2013 · 10 comments

Comments

@alberts
Copy link
Contributor

alberts commented Mar 31, 2013

What steps will reproduce the problem?

cd misc/cgo/stdio
go build hello.go
md5sum hello.go
go build hello.go
md5sum hello.go

What is the expected output?

same hash

What do you see instead?

different hashes

looking at a few changes in the hexdump:

--- hello.hex   2013-03-31 10:33:19.114543157 +0200
+++ hello.1.hex 2013-03-31 10:33:23.269525520 +0200
@@ -41,4 +41,4 @@
-00000280  47 4e 55 00 24 a0 0b 56  b5 4c 4b 86 c0 50 72 55  |GNU.$..V.LK..PrU|
-00000290  44 eb 46 4c f4 d2 c6 af  04 00 00 00 14 00 00 00  |D.FL............|
-000002a0  03 00 00 00 47 4e 55 00  69 a3 c5 7d 98 dc ed 5c  |....GNU.i..}...\|
-000002b0  86 b9 24 f4 92 a5 44 67  a7 6f e5 5a 04 00 00 00  |..$...Dg.o.Z....|
+00000280  47 4e 55 00 13 17 8b 27  51 48 39 83 a0 f6 80 98  |GNU....'QH9.....|
+00000290  09 1f e1 fe 36 ed ab 04  04 00 00 00 14 00 00 00  |....6...........|
+000002a0  03 00 00 00 47 4e 55 00  45 8c 05 ba bf 14 5d 9e  |....GNU.E.....].|
+000002b0  4f c8 d3 f6 d1 6b 52 7f  f6 e1 c9 80 04 00 00 00  |O....kR.........|
@@ -20976,2 +20976,2 @@
-00051f80  04 00 24 00 00 00 08 01  50 00 00 00 01 95 02 00  |..$.....P.......|
-00051f90  00 e2 02 00 00 d0 0f 40  00 00 00 00 00 18 10 40  |.......@.......@|
+00051f80  04 00 24 00 00 00 08 01  50 00 00 00 01 b5 02 00  |..$.....P.......|
+00051f90  00 95 02 00 00 d0 0f 40  00 00 00 00 00 18 10 40  |.......@.......@|
@@ -21049 +21049 @@
-00052410  00 01 c3 03 00 00 e2 02  00 00 20 10 40 00 00 00  |.......... .@...|
+00052410  00 01 a1 03 00 00 95 02  00 00 20 10 40 00 00 00  |.......... .@...|
@@ -21092 +21092 @@
-000526c0  00 00 00 0e b9 03 00 00  01 11 bc 02 00 00 30 10  |..............0.|
+000526c0  00 00 00 0e 07 04 00 00  01 11 bc 02 00 00 30 10  |..............0.|
@@ -21094 +21094 @@
-000526e0  0f a1 03 00 00 01 29 40  10 40 00 00 00 00 00 4e  |......)@[email protected]|
+000526e0  0f ef 03 00 00 01 29 40  10 40 00 00 00 00 00 4e  |......)@[email protected]|
@@ -21628 +21628 @@
-00054840  2d 62 75 69 6c 64 34 35  34 30 36 34 34 36 33 2f  |-build454064463/|
+00054840  2d 62 75 69 6c 64 31 31  35 32 37 37 35 32 37 2f  |-build115277527/|
@@ -21657,7 +21657,7 @@
-00054a10  00 2f 64 65 76 2f 73 68  6d 2f 67 6f 2d 62 75 69  |./dev/shm/go-bui|
-00054a20  6c 64 34 35 34 30 36 34  34 36 33 2f 5f 2f 68 6f  |ld454064463/_/ho|
-00054a30  6d 65 2f 61 6c 62 65 72  74 73 2f 67 6f 2f 6d 69  |me/alberts/go/mi|
-00054a40  73 63 2f 63 67 6f 2f 73  74 64 69 6f 2f 5f 6f 62  |sc/cgo/stdio/_ob|
-00054a50  6a 2f 66 69 6c 65 2e 63  67 6f 32 2e 63 00 2f 68  |j/file.cgo2.c./h|
-00054a60  6f 6d 65 2f 61 6c 62 65  72 74 73 2f 67 6f 2f 6d  |ome/alberts/go/m|
-00054a70  69 73 63 2f 63 67 6f 2f  73 74 64 69 6f 00 5f 6e  |isc/cgo/stdio._n|
+00054a10  00 2f 68 6f 6d 65 2f 61  6c 62 65 72 74 73 2f 67  |./home/alberts/g|
+00054a20  6f 2f 6d 69 73 63 2f 63  67 6f 2f 73 74 64 69 6f  |o/misc/cgo/stdio|
+00054a30  00 2f 64 65 76 2f 73 68  6d 2f 67 6f 2d 62 75 69  |./dev/shm/go-bui|
+00054a40  6c 64 31 31 35 32 37 37  35 32 37 2f 5f 2f 68 6f  |ld115277527/_/ho|
+00054a50  6d 65 2f 61 6c 62 65 72  74 73 2f 67 6f 2f 6d 69  |me/alberts/go/mi|
+00054a60  73 63 2f 63 67 6f 2f 73  74 64 69 6f 2f 5f 6f 62  |sc/cgo/stdio/_ob|
+00054a70  6a 2f 66 69 6c 65 2e 63  67 6f 32 2e 63 00 5f 6e  |j/file.cgo2.c._n|
@@ -21673,8 +21673,8 @@
-00054b10  74 64 6f 75 74 00 73 74  64 65 72 72 00 5f 63 67  |tdout.stderr._cg|
-00054b20  6f 5f 37 36 61 37 61 37  64 61 63 38 66 35 5f 43  |o_76a7a7dac8f5_C|
-00054b30  66 75 6e 63 5f 67 65 74  53 74 64 65 72 72 00 2f  |func_getStderr./|
-00054b40  64 65 76 2f 73 68 6d 2f  67 6f 2d 62 75 69 6c 64  |dev/shm/go-build|
-00054b50  34 35 34 30 36 34 34 36  33 2f 5f 2f 68 6f 6d 65  |454064463/_/home|
-00054b60  2f 61 6c 62 65 72 74 73  2f 67 6f 2f 6d 69 73 63  |/alberts/go/misc|
-00054b70  2f 63 67 6f 2f 73 74 64  69 6f 2f 5f 6f 62 6a 2f  |/cgo/stdio/_obj/|
-00054b80  73 74 64 69 6f 2e 63 67  6f 32 2e 63 00 2f 64 65  |stdio.cgo2.c./de|
+00054b10  74 64 6f 75 74 00 73 74  64 65 72 72 00 2f 64 65  |tdout.stderr./de|
+00054b20  76 2f 73 68 6d 2f 67 6f  2d 62 75 69 6c 64 31 31  |v/shm/go-build11|
+00054b30  35 32 37 37 35 32 37 2f  5f 2f 68 6f 6d 65 2f 61  |5277527/_/home/a|
+00054b40  6c 62 65 72 74 73 2f 67  6f 2f 6d 69 73 63 2f 63  |lberts/go/misc/c|
+00054b50  67 6f 2f 73 74 64 69 6f  2f 5f 6f 62 6a 2f 73 74  |go/stdio/_obj/st|
+00054b60  64 69 6f 2e 63 67 6f 32  2e 63 00 5f 63 67 6f 5f  |dio.cgo2.c._cgo_|
+00054b70  37 36 61 37 61 37 64 61  63 38 66 35 5f 43 66 75  |76a7a7dac8f5_Cfu|
+00054b80  6e 63 5f 67 65 74 53 74  64 65 72 72 00 2f 64 65  |nc_getStderr./de|

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

6g
gcc-4.7.2-2.fc17.x86_64

Which operating system are you using?

linux
F16 x86-64

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

go version devel +35f0e92cbd6c Sat Mar 30 09:22:11 2013 -0700 linux/amd64

Please provide any additional information below.

This was fixed before:

https://code.google.com/p/go/source/detail?r=e24d688078cd
@alberts
Copy link
Contributor Author

alberts commented Mar 31, 2013

Comment 1:

part of the change might be caused by build ids:
http://fedoraproject.org/wiki/Releases/FeatureBuildId
hopefully the build id is different because of the difference in the cgo bits.

@bradfitz
Copy link
Contributor

Comment 2:

go {build,run} uses temp directories, and those directories get baked in to the binary
in various ways.

@alberts
Copy link
Contributor Author

alberts commented Mar 31, 2013

Comment 3:

Some discussion:
https://groups.google.com/d/topic/golang-nuts/bjCrKTsr3tE/discussion
As minux noted, we had this feature for a while, but recent changes probably made it go
away.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 4:

Labels changed: added priority-later, go1.2, removed priority-triage.

@robpike
Copy link
Contributor

robpike commented Aug 30, 2013

Comment 5:

Not for 1.2.

Labels changed: removed go1.2.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 6:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 7:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 8:

Labels changed: added repo-main.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 2, 2017

A lot of work has happened on this over the years.

Is this still an issue?

/cc @ianlancetaylor

@ianlancetaylor
Copy link
Contributor

This has been subsumed by #13247. It is fixed for most systems for most compilers, but there are still a few cases remaining. Closing this issue in favor of the one with more information.

@golang golang locked and limited conversation to collaborators Feb 2, 2018
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

6 participants