-
Notifications
You must be signed in to change notification settings - Fork 651
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
Builds not reproducible with cgo (?) #1547
Comments
I think this is probably a duplicate of #1518, but needs analysis to be sure. |
So this is weird... I have a fix, but it's "magic". I think what's happening is that setting the (I reached this via justinsb@2e10d87 which has more debug information, but the flag is a red herring I believe, because it works with any flag) Going to try this on a few more projects, but thought this might give someone a clue... (I think this is a dup of #1518, agreed, though maybe this one has a few more details now!) |
Ah - so here's why (I think): https://github.com/golang/go/blob/5756895877492e3427c92e9ec8784eb1f4b01474/src/cmd/go/internal/work/exec.go#L2253-L2258 My read of that is that setting CGO_CFLAGS completely replaces the defaults, so if we do override those flags, we probably should pass "-g -O2" as well, other the cgo code won't be optimized. But dropping the |
So based on all this I did a PoC of a "real" patch: justinsb@96be613 With that the debug symbol path (from (I'm using the shm experiment, but the same applies without it) That seems to be good enough for a reproducible build, though still a little ugly admittedly. But feedback welcome on the approach (I can send a PR), or feel free to take the learnings and fix it "right" - I know that can be faster on some of these fixes that have several ways to tackle them :-) |
I don't know about adding Thanks for looking into this. This is important, but there's a lot of stuff in flight right now, and I haven't had time to take it on. |
Another thing here is that cgo.go uses a temp dir as its source dir and those temp dir paths are also embedded. |
One final note on this. stdlib is still not fully reproducible when using clang with debug symbols ( There is a bug in clang that does not respect I will file a bug with LLVM for this. Illustration of the bug: $ cat > dummy.c
int main() { return 0; }
$ clang -S -c dummy.c -o dummy.S
$ clang -fdebug-prefix-map=$PWD= -g dummy.S -o dummy
$ strings dummy | grep $PWD The tests may pass on Travis macOS even with |
Thanks @siddharthab - I ran with 3725f0a (which is going to be 0.13.0 it looks like - thanks @jayconrod ) and this is indeed fixed for me - thank you! (I wasn't able to see the path you mentioned in my use-case, but I'm not using much cgo. Thank you for looking into it though!) |
You are welcome @justinsb. You will be fine if you are not using clang with -g. That's the only case when it's not fully fixed. |
https://reviews.llvm.org/D48989 for LLVM patch. Any followups will happen there. |
Possibly related to #1531 , and might be the issue being fixed in #1536
Builds (that involve cgo?) produce different binaries from run to run. For example https://github.com/kopeio/etcd-manager
I believe this is because the sandbox path is included in the binary:
(And 380 changes in between invocations)
In bazel-bin:
So it's coming from those .a files, which I think are the ones that aren't cached in #1531.
The text was updated successfully, but these errors were encountered: