[pull] main from bazel-contrib:main#483
Merged
Merged
Conversation
This makes build data accessible to binaries. By default, some basic information is always available: target name and if stamping was enabled. When `--stamp` is enabled, the full `workspace_status_command` output is included in the build information. Build information is made available through a special `bazel_binary_info` module. This module is created by the bootstrap and injected into sys.modules. It provides an API for gettting the raw build information that was written. Exposing a module, instead of a file, is done insulate from the Bazel-ism of runfiles. When stamping is enabled, the way stamped data works is a bit round about to get the desired semantics: that the build data reflects the most recent build of a binary, not the last cached value of the build information (e.g., if I build a binary, then modify a file in the binary, then build again, the build data should reflect the timestamp of the second build). Normal Bazel caching, however, makes that somewhat difficult (the build data file has to take the full transitive set of files as inputs to properly detect changes, otherwise it'll get cached on first build of the binary; plus actions can't take runfiles objects as inputs). To work around this, we use some special APIs to get `ctx.version_file` information into the output without entirely destroying caching. * Because `ctx.version_file` doesn't trigger cache invalidation, a special helper, `py_internal.copy_without_caching()`, is used to make it _always_ invalidate caching. Now we can ensure we have a copy of the most recent invocation data. * To prevent the above from _always_ rebuilding a binary, another special api, `py_internal.declare_constant_metadata_file()` is used to restore the behavior of a file never invalidating caching (even if it changes). This dance is necessary because actions can't take runfiles as direct inputs. It also avoids having to pass the entire program's transitive set of files as an input just to do input change tracking. Note the above only applies when stamping is enabled. Unstamped binaries don't do any of this. Along the way... * The `stamp` attribute now transitions the `--stamp` flag. This was necessary so that the dependency on version_info was conditional on stamping. * Remove a defunct helper from the stage2 bootstrap code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )