-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go, cmd/cgo: repeatable builds on Solaris #13247
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
Comments
Change (*builder).ccompile to execute gcc from within $WORKDIR: Works, but something is still inserting $WORKDIR into the object file. I haven't yet figured out what.
Change (*builder).ccompilerCmd to include -fdebug-prefix-map: Works, but the compiler command line appears to be included in the object file somewhere:
Also -fdebug-prefix-map doesn't appear to be supported by clang, so that's probably not a useful approach to continue pursuing. |
We could post-process the compiled .o file's DWARF debug strings to replace all occurrences of /tmp/go-build12345 with /tmp/go-buildXXXXX. |
Hm, post-processing the DWARF debug strings doesn't seem to reliably work either, as the debug string's ordering is also influenced by the actual build directory name:
|
BTW, the temporary directory generated by cmd/link for external linking is also being embedded into the output files (as a FILE symbol in the ELF .symtab):
|
I looked briefly into this but it's like gcc is actively working against us. I love the fact that the -fdebug-prefix-map command-line argument gets embedded into the binary when the whole point of that flag is to specify something to keep out. https://go-review.googlesource.com/17943 has my work in progress. Until gcc or clang wants to cooperate I don't see much point in heroics. I do see that clang seems to have added support for -fdebug-prefix-map very recently, not that we can rely on it being available. |
The magic additional incantation appears to be -gno-record-gcc-switches to keep the flags out of the binary. |
Yay!
|
CL https://golang.org/cl/19363 mentions this issue. |
Fixed with a caveat: The system compiler needs to support -fdebug-prefix-map for builds to be reproducible. That's gcc 4.3 and clang 3.8 (not released yet). |
Reopening, because Solaris builds remain inconsistent. |
See #13247. Change-Id: I06636157028d98430eb29277c822270592907856 Reviewed-on: https://go-review.googlesource.com/19910 Reviewed-by: Brad Fitzpatrick <[email protected]>
Is this still a problem after my fix for #14957? I can't reproduce the issue locally with my fix applied: Historically, I would note that the Solaris linker would insert the working directory if no STT_FILE was found, but that's no longer true in current Solaris releases. So I think what was causing the changes made for this bug to not work on Solaris was the problem fixed in #14957. |
Sounds like this is fixed then. |
I believe #9206 too can be closed. |
CL https://golang.org/cl/23741 mentions this issue. |
Updates #13247. Change-Id: If5e4c9f4db05f58608b0eeed1a2312a04015b207 Reviewed-on: https://go-review.googlesource.com/23741 Run-TryBot: Mikio Hara <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
No, this issue is not fixed on Solaris. See https://build.golang.org/log/efb56d2bc3049a131016966cff929c44137968d8 |
I also confirm #9206 cannot be closed, I can still reproduce the issue. |
Postponing until 1.8. |
CL https://golang.org/cl/24460 mentions this issue. |
Handling a symbol with address 0 and size 0, such as an ELF STT_FILE symbols, was causing us to disassemble the entire program. We started adding STT_FILE symbols to help fix issue #13247. Fixes #16154. Change-Id: I174b9614e66ddc3d65801f7c1af7650f291ac2af Reviewed-on: https://go-review.googlesource.com/24460 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Joe Tsai <[email protected]>
Confirmed this is still a problem on Solaris:
The first and third diff are the work tempdir leaking into the binary. I'm not sure what the second diff is. I have no solution. If someone knows how to tell gcc on Solaris not to record the absolute object paths used during a link, please let us know. |
Binaries built with "go build" that use cgo or include packages that use cgo contain references to a temporary directory. Multiple builds for the same binary will produce inconsistent results.
Simple reproduction:
Some build systems require reproducible results: The same inputs should produce precisely the same outputs. The above behavior violates that requirement.
The problem appears to be that the gcc command invoked by "go build" includes the absolute path of the source file in $WORKDIR, which gcc then bakes into the resulting object file.
One fix might be to execute gcc from within $WORKDIR. There is, however, a comment in cmd/go/build.go indicating that the current behavior is intentional: "We always pass absolute paths of source files so that the error messages will include the full path to a file in need of attention."
Another possibility might be to use -fdebug-prefix-map to elide $WORKDIR from the debugging information written by gcc. I don't know if this can be generalized to other compilers.
The text was updated successfully, but these errors were encountered: