Compare commits

..

1 Commits

Author SHA1 Message Date
Tyler French
1d8a22e9dd Fix non-determinism in rules_rs/crate_git_repository.bzl (#16590)
Running multiple builds with no changes causes some differences, we see
that
https://app.buildbuddy.io/compare/a9719629-1660-4735-a477-d66357f234fb...df85310b-eb5c-4c10-8b79-4d0449ba6cdd#file
shows the file-differences between two Bazel builds.

These differences are caused by a non-deterministic `.git` entry in the
rules_rs crates that are created with `crate_git_repository`.

As a way to make these deterministic, we can remove this entry after we
download the git source, so that the input to the compile action is
deterministic.

### CLA

I have read the CLA Document and I hereby sign the CLA
2026-04-02 11:21:11 -07:00
2 changed files with 4 additions and 8 deletions

View File

@@ -10,7 +10,6 @@ exports_files([
"rules_rust_repository_set_exec_constraints.patch",
"rules_rust_windows_msvc_direct_link_args.patch",
"rules_rust_windows_gnullvm_build_script.patch",
"rules_rs_delete_git_worktree_pointer.patch",
"rules_rs_windows_gnullvm_exec.patch",
"rusty_v8_prebuilt_out_dir.patch",
"v8_bazel_rules.patch",

View File

@@ -1,13 +1,7 @@
# What: delete .git worktree pointer from crate git checkouts.
# Why: the .git file contains an absolute path to the bazel output base,
# which differs across machines. This pollutes compile_data and causes
# action cache misses when builds run on different CI runners.
diff --git a/rs/private/crate_git_repository.bzl b/rs/private/crate_git_repository.bzl
index 1234567..abcdefg 100644
--- a/rs/private/crate_git_repository.bzl
+++ b/rs/private/crate_git_repository.bzl
@@ -35,6 +35,11 @@ def _crate_git_repository_implementation(rctx):
@@ -35,6 +35,14 @@
"HEAD"
])
if result.return_code != 0:
@@ -16,6 +10,9 @@ index 1234567..abcdefg 100644
+ # Remove .git worktree pointer file. It contains an absolute path to
+ # the bazel output base which is machine-specific and non-deterministic.
+ # Leaving it in pollutes compile_data globs and causes AC misses.
+ #
+ # Note that bazelbuild/rules_rust ignores .git (among other paths) during splicing:
+ # https://github.com/bazelbuild/rules_rust/blob/ca4915c0210bcd240152a5333ecb24d266bda144/crate_universe/src/splicing/splicer.rs#L42
+ rctx.delete(root.get_child(".git"))
+
if strip_prefix: