-
-
Notifications
You must be signed in to change notification settings - Fork 723
Drop non-hermetic deps in _go_tool_binary_impl #4365
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
Conversation
f5ccf9d to
ed64111
Compare
ed64111 to
86f25cd
Compare
|
Tested manually on NixOS running unstable from a week or so go. This resolved the mktemp not found. Tested using the examples/hello/ in this repo: https://github.com/calmette54/rules_go/tree/master/examples/hello and Also retested this on Ubuntu server LTS, and with the patch applied the build continues to work |
ecaaf6a to
5fcc83f
Compare
bfddafd to
728403e
Compare
|
@fmeum ok, so I think we have the following options:
With all of these solutions, the key thing to remember is that due to Based on all of the above, I am tempted to do (3). It feels like the best way to ensure the output is insulated and matches what we do on Windows, opening the path to combining the codepaths. WDYT? |
|
I'm pretty strongly in favor of 3 - I want to avoid adding precompiled binaries to the mix that aren't part of a Go SDK, but also don't like dependencies on hardcoded directory paths. @jayconrod @linzhp Any concerns? |
728403e to
8f1f4ad
Compare
3358174 to
c2d4e08
Compare
|
I don't feel like any of these are great options. Depending on the shell for this one bootstrapping step seems reasonable to me. If we write to
If we really had to avoid a shell dependency, I think shipping a precompiled binary would be better. |
@dzbarsky Do you know whether the cache directory contents are deterministic (assuming exclusive access by one action) and how many files the cache typically contains? |
|
@jayconrod that's fair, I'm not thrilled about any of these options :) Note that on Windows we are already doing the output directory trick because there's no @fmeum I don't think it's deterministic, that's why I had to exclude it in reproducibility tests. Perhaps it could be made deterministic with the right flags and we never had to try before, but it's also possible that the Go compiler doesn't care about the contents matching precisely as long as they can be used to emit reproducible artifacts (i.e. I assume they store extra metadata about when an entry was created/read so it can be LRU'ed but it doesn't affect build results). I think for the action here the cache was a few hundred files, I can check more precisely later if you're curious |
|
Non-determinism in outputs is bad even if these outputs don't end up being used - this will show up as an anomaly when diffing exec logs. If we keep the dep on a shell, is there a way to make this work for nix by modifying how we look for |
Is it enough to put the outputs under TMPDIR or do you think we also need a |
I know. Someone should do something :P
I think we need mktemp under |
|
Bazel inherits Yes, I agree that we need |
|
How do we feel about picking up a dependency on Aspect's coreutils toolchain? That would give us another path to solving this hermetically. And perhaps we can file a bug in upstream Go to allow compilation without GOCACHE though it may take some convincing and would be a while before we could rely on that here .. |
|
Wow guys. Really interesting following along in the thread. Feels like
there's a lot of useful understanding coming out, which it would be amazing
and helpful to capture in a doc somehow. Essentially, you are digging into
the details about the sandbox comes up, which is currently "lightly"
documented.
The challenge seems to be we are talking about the bootstrap. For example,
it would be potentially be elegant to allow rules_go to create its own
dependencies, via
https://github.com/u-root/u-root/blob/main/cmds/core/mktemp/mktemp.go, for
instance, however, the challenge is we are talking about sandbox setup. At
the point mktemp is being called, we don't have to go, so we couldn't
supply a go only mktemp even if we wanted to.
Maybe the undeclared depency is within bazel, rather than rules_go?
Rules_go arguably starts *after* this sandbox setup?
…On Thu, May 29, 2025 at 8:35 PM David Zbarsky ***@***.***> wrote:
*dzbarsky* left a comment (bazel-contrib/rules_go#4365)
<#4365 (comment)>
How do we feel about picking up a dependency on Aspect's coreutils
toolchain
<https://github.com/bazel-contrib/bazel-lib/blob/f81fc59b2a2e71a4df6616d5253705fa1d021a76/lib/private/coreutils_toolchain.bzl#L99>?
That would give us another path to solving this hermetically.
And perhaps we can file a bug in upstream Go to allow compilation without
GOCACHE though it may take some convincing and would be a while before we
could rely on that here ..
—
Reply to this email directly, view it on GitHub
<#4365 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APMCHTVUW57LLXJKWPXDZU33A7GZJAVCNFSM6AAAAAB56TVMBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMRRGEZTMMBZGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Regards,
Dave Seddon
+1 415 857 5102
|
I'd prefer not to add a dependency for this.
That's unlikely to happen: it would mean reversing a large effort that's been in a positive direction.
I'm not sure what this means? The problem is whether we can depend on Thinking more about precompiled binaries: I don't think this would work. I'd actually love to ship a precompiled binary for the builder tool (replacing this whole rule), but we'd need one for every execution platform, and it'd need to work at every commit, not just release. So we'd still need to fall back to the current Other thoughts:
The problem with this approach is that if we fail to compile the builder tool for some reason, we have no way to clean up the |
c2d4e08 to
ed75a7e
Compare
|
@jayconrod in an earlier iteration of this PR I had tried to point HOME (and thus GOCACHE) at the execroot and it caused constant cache invalidation. I just looked at it again and realized that it was due to it being a relative path which is late-expanded within I've updated the PR, how do we feel about the approach now? |
f1eb3bc to
ea6433d
Compare
ea6433d to
9765701
Compare
|
@jayconrod @fmeum I've updated with all the feedback, PTAL? |
jayconrod
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. No other comments from me. Thanks for improving this.
What type of PR is this?
Bug fix for Nix
What does this PR do? Why is it needed?
The current implementation depends on
mktempandrmbeing in the PATH, which they're not on Nix. This alternative construction executesgo builddirectly without run_shell or the coreutils deps.While here, I set a few extra env vars to disable new Go features we don't want (GOTELEMETRY, GOENV).
If this works, we may be able to remove the Windows codepath.
Which issues(s) does this PR fix?
Fixes #
Other notes for review