From 0d278878421147f004cc533121e6e835b6e148d9 Mon Sep 17 00:00:00 2001 From: Aaron Siddhartha Mondal Date: Sat, 14 Dec 2024 05:10:56 +0100 Subject: [PATCH] Achieve perfect reproducibility for Linux Bazel builds Close the final nonhermeticity by reconfiguring rules_python to use a statically linked musl toolchain. This makes nativelink fully buildable and testable with lre-rs in remote execution with perfect parity to local execution. --- .bazelrc | 8 ++++++++ MODULE.bazel | 2 +- nativelink-proto/BUILD.bazel | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index a1b212f59..91f4857fa 100644 --- a/.bazelrc +++ b/.bazelrc @@ -20,6 +20,14 @@ common --enable_platform_specific_config common --incompatible_enable_cc_toolchain_resolution common --incompatible_enable_proto_toolchain_resolution +# Simulate rules_python's initialization with a script and use a statically +# linked musl Python toolchain. +# TODO(aaronmondal): This is a hack. It works for us because have just a few +# simple python scripts in the repository and don't have +# complex Python dependencies. Implement LRE for Python. +common --@rules_python//python/config_settings:bootstrap_impl=script +common --@rules_python//python/config_settings:py_linux_libc=musl + # Don't leak PATH and LD_LIBRARY_PATH into the build. build --incompatible_strict_action_env diff --git a/MODULE.bazel b/MODULE.bazel index ecc336b15..bcb74f7f9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,7 +6,7 @@ module( bazel_dep(name = "rules_cc", version = "0.0.17") bazel_dep(name = "platforms", version = "0.0.10") -bazel_dep(name = "rules_python", version = "0.40.0") +bazel_dep(name = "rules_python", version = "1.0.0") python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( diff --git a/nativelink-proto/BUILD.bazel b/nativelink-proto/BUILD.bazel index 40e110da0..d8ab175d0 100644 --- a/nativelink-proto/BUILD.bazel +++ b/nativelink-proto/BUILD.bazel @@ -1,4 +1,5 @@ load("@bazel_skylib//lib:selects.bzl", "selects") +load("@rules_python//python:defs.bzl", "py_binary", "py_test") load( "@rules_rust//rust:defs.bzl", "rust_binary",