Skip to content

[pull] main from bazel-contrib:main#483

Merged
pull[bot] merged 1 commit into
garymm:mainfrom
bazel-contrib:main
Dec 29, 2025
Merged

[pull] main from bazel-contrib:main#483
pull[bot] merged 1 commit into
garymm:mainfrom
bazel-contrib:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Dec 29, 2025

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 : )

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.
@pull pull Bot locked and limited conversation to collaborators Dec 29, 2025
@pull pull Bot added the ⤵️ pull label Dec 29, 2025
@pull pull Bot merged commit 352f405 into garymm:main Dec 29, 2025
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant