Skip to content

Commit d103be7

Browse files
authored
Mark downloaded repository as reproducible (#531)
#515 only makes the config repository reproducible. The downloaded toolchains are store in a separate repository. Since this separate repository is not marked as reproducible, the extracted files are currently not cached. This change fixes that by marking the repositority that contains the downloaded toolchain also reproducible. Similar to the git repo rule here: https://github.com/bazelbuild/bazel/blob/648f991bd8653408ba6b4c24c6ff8fa4fce51eba/tools/build_defs/repo/git.bzl#L219
1 parent 6a2ba86 commit d103be7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/scripts/run_tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ if [[ -z ${toolchain_name} && -z ${disable_wasm_tests} ]]; then
8484
"//wasm:all"
8585
)
8686
"${bazel}" clean --expunge
87+
# Remove the repo contents cache in addition to cleaning the work trees since
88+
# this is where the llvm toolchains are stored.
89+
user="$(id -un)"
90+
if [[ ${OSTYPE} == 'darwin'* ]]; then
91+
rm -rf "/private/var/tmp/_bazel_${user}/cache/repos/v1/contents"
92+
else
93+
rm -rf "${HOME}/.cache/bazel/_bazel_${user}/cache/repos/v1/contents"
94+
fi
8795
"${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \
8896
"${common_test_args[@]}" "${test_args[@]}" "${wasm_targets[@]}"
8997
fi

toolchain/internal/repo.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
load(
1515
"//toolchain/internal:common.bzl",
16+
_attr_dict = "attr_dict",
1617
_os = "os",
1718
_supported_os_arch_keys = "supported_os_arch_keys",
1819
)
@@ -334,4 +335,10 @@ def llvm_repo_impl(rctx):
334335
# do want to make changes, then we should do it through a patch file, and
335336
# document it for users of toolchain_roots attribute.
336337

337-
return updated_attrs
338+
if hasattr(rctx, "repo_metadata"):
339+
if updated_attrs == _attr_dict(rctx.attr):
340+
return rctx.repo_metadata(reproducible = True)
341+
else:
342+
return rctx.repo_metadata(attrs_for_reproducibility = updated_attrs)
343+
else:
344+
return updated_attrs

0 commit comments

Comments
 (0)