-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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, cmd/cgo: repeatable builds on OS X with external linker #9206
Comments
Sounds like this has been fixed. See #13247. |
FWIW, I just checked on tip on a medium size project on darwin, and there are still two small differences:
The first one I guess it's a timestamp, the second seems the path to a temporary directory created by/for go-link. |
Reopening. As far as I know the problem is Darwin-specific. |
CC @neild |
Sigh. |
I guess it will keep regressing until some tests are added to trybots. It looks like the typical feature that is impossible not to break without tests. |
There is a test, actually: TestCgoConsistentResults in src/cmd/go. Works On My Machine(tm). Try running that test:
Do you see -fdebug-prefix-map in the compiler invocation, or is the test skipped because the compiler does not support that flag? If the test passes for you, can you give me steps to reproduce the inconsistency? Thanks. |
The test passes, and To reproduce what I see, it should be sufficient something like this:
|
@neild let me know if you reproduce and/or you need more info; i'd like to make sure that the bug is properly filed (though I don't personally need a quick resolution). |
It looks like the problem here is that the external linker adds a symbol to the symbol table, containing the full path of the I think we might need something similar to this fix: go/src/cmd/link/internal/ld/symtab.go Line 203 in 53fd522
but for macho instead of elf. |
@ianlancetaylor @bradfitz Hi, by "varying the build path" I mean we are doing the first build in Example diff and a list of things we vary. I originally thought to open a new bug, because this bug seems to be about cgo and $WORK. We have also experienced this cgo issue elsewhere which we document here, but the issue I described with |
I could retitle the other bug to something a bit more specific, if you prefer. Such as "golang embeds build path into .gopclntab, causing loss of reproducibility". |
Oh, I see. They are slightly different bugs. Okay, we can track them separately. I'll reopen #16860 and we can give it a better title. |
@ianlancetaylor or @neild, didn't you figure out the magic flag |
Confirmed this is still a problem:
I have no solution. I tried hacking cmd/link to pass a relative path (just "go.o") to the external linker and then running the linker in the temp directory (to make the relative path valid), hoping that the linker would then record the relative path instead of the absolute path seen in the diff. But that didn't help. (Also, in general I'm not sure of the implications of changing the directory where the linker runs, but it didn't help anyway.) If someone knows how to tell clang on macOS not to record the absolute object paths used during a link, please let us know. |
@rsc Here are a list of known issues with reproducible builds: https://tests.reproducible-builds.org/debian/index_issues.html perhaps this one has been studied and solved before for other packages. Golang-1.7 is listed here: https://tests.reproducible-builds.org/debian/issues/unstable/captures_build_path_issue.html and discusses some of the issues. HTH |
@purpleidea Note that there are no known problems with reproducible builds with Go when using GCC, only when using clang. |
On Thu, Jun 22, 2017 at 8:45 PM, Ian Lance Taylor ***@***.***> wrote:
@purpleidea Note that there are no known problems with reproducible builds with Go when using GCC, only when using clang.
running `go build` is still un-reproducible IIRC.
https://github.com/purpleidea/mgmt/blob/master/test/test-reproducible.sh#L2
(lots more variations need to be added, but this test is disabled due
to path issues in `go build` iirc)
|
@purpleidea Thanks. Assuming that is not on MacOS, please file a different issue with a reproduction case. |
…tor. I had to apply two tricks to get a reproducible snowflake-client. The first is to use faketime to eliminate some timestamps. There were 11 variable timestamps in the file. Through experimentation, I found that 10 of them were dependent on the Go runtime (recompiling Go caused them to change) and 1 was dependent on snowflake-client itself (recompiling snowflake-client with the same runtime changed only that 1 timestamp). The underlying issue has to do with clang 3.8.0 on Darwin embedding timestamps, unsolved in the Go issue tracker as of 13 days ago. golang/go#9206 (comment) The second is a sed command to clobber embedded paths of the form /tmp/go-buildXXXXXXXXX and /tmp/go-link-XXXXXXXXX. Their presence is caused by some combination of Clang and Darwin, and there is as yet no known workaround upstream.
tor-browser-bundle.git author: David Fifield <david@bamsoftware.com> tor-browser-bundle.git commit: 26e0cd44f2886bfad1c3d30844ff7a21eb9d0478 Commit message from the tor-browser-bundle.git commit: Build go-webrtc and snowflake in the mac pluggable-transports descriptor. I had to apply two tricks to get a reproducible snowflake-client. The first is to use faketime to eliminate some timestamps. There were 11 variable timestamps in the file. Through experimentation, I found that 10 of them were dependent on the Go runtime (recompiling Go caused them to change) and 1 was dependent on snowflake-client itself (recompiling snowflake-client with the same runtime changed only that 1 timestamp). The underlying issue has to do with clang 3.8.0 on Darwin embedding timestamps, unsolved in the Go issue tracker as of 13 days ago. golang/go#9206 (comment) The second is a sed command to clobber embedded paths of the form /tmp/go-buildXXXXXXXXX and /tmp/go-link-XXXXXXXXX. Their presence is caused by some combination of Clang and Darwin, and there is as yet no known workaround upstream.
This is fixed as of now. There were a few different steps and steps backward. |
@rsc Great, thanks! What does it mean: "There were a few different steps and steps backward." ? Cheers! |
It means there were multiple things to fix (steps forward) and maybe also a few new bugs introduced (steps backward) that also needed fixing. |
The text was updated successfully, but these errors were encountered: