Update to Bazel 8.0.0
Updates to Bazel 8.0.0 and tidies up the MODULE.bazel and .bazelrc
files.
Bug: b/372510795, b/315871648
Change-Id: I309f13888e5ba9c75de8d8a338513f84c1f7d696
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/examples/+/259292
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Dave Roth <davidroth@google.com>
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/.bazelrc b/.bazelrc
index 726e028..4e0dff0 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -12,26 +12,62 @@
# License for the specific language governing permissions and limitations under
# the License.
-# TODO: https://pwbug.dev/319665090: Disable hermetic sandbox tmp due to issues
-# with arm toolchain.
-build --noincompatible_sandbox_hermetic_tmp
+# Standard Pigweed flags
+# ======================
+# All Pigweed projects are expected to set these flags. They mostly pre-adopt
+# future Bazel settings, and most are critical to working around known issues.
+#
+# The source of truth for these flags is @pigweed//pw_build:pigweed.bazelrc in
+# the main Pigweed repo.
+
+# Don't automatically create __init__.py files.
+#
+# This prevents spurious package name collisions at import time, and should be
+# the default (https://github.com/bazelbuild/bazel/issues/7386). It's
+# particularly helpful for Pigweed, because we have many potential package name
+# collisions due to a profusion of stuttering paths like
+# pw_transfer/py/pw_transfer.
+common --incompatible_default_to_explicit_init_py
# Do not attempt to configure an autodetected (local) toolchain. We vendor all
# our toolchains, and CI VMs may not have any local toolchain to detect.
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
+# Don't propagate flags or defines to the exec config. This will become the
+# default one day (https://github.com/bazelbuild/bazel/issues/22457) and will
+# improve cache hit rates between builds targeting different platforms. This is
+# especially impactful for large host tools like protoc, which will have its
+# cache invalidated when your host C++ config changes, causing many rebuilds
+# of protoc (https://pwbug.dev/315871648).
+common --experimental_exclude_defines_from_exec_config
+common --experimental_exclude_starlark_flags_from_exec_config
+
+# Enforces consistent action environment variables. This is important to
+# address Protobuf's rebuild sensitivity on changes to the environment
+# variables. It also improves cache hit rates. Should be true by default one
+# day (https://github.com/bazelbuild/bazel/issues/7026).
+build --incompatible_strict_action_env
+
+# Expose exec toolchains for Python. We use these toolchains in some rule
+# implementations (git grep for
+# "@rules_python//python:exec_tools_toolchain_type").
+build --@rules_python//python/config_settings:exec_tools_toolchain=enabled
+
+# TODO: https://github.com/bazelbuild/rules_python/issues/2515 - This flag was
+# enabled with Bazel 8.0.0, but it breaks py_proto_library imports when using
+# the latest release of rules_python (1.0.0). Flipping this flag is a temporary
+# workaround.
+common --legacy_external_runfiles=True
+
+# C++ configuration
+# =================
+
common --custom_malloc=//targets:malloc
# Ignore all warnings in third-party code.
common --per_file_copt=external/.*@-w
common --host_per_file_copt=external/.*@-w
-# Required for new toolchain resolution API.
-build --incompatible_enable_cc_toolchain_resolution
-
-# Expose exec toolchains for Python.
-build --@rules_python//python/config_settings:exec_tools_toolchain=enabled
-
# Default targets to build when running:
# bazel build --config=presubmit
build:presubmit -- \
@@ -52,16 +88,6 @@
//tools:console \
//tools:device_sim
-
-# Don't automatically create __init__.py files.
-#
-# This prevents spurious package name collisions at import time, and should be
-# the default (https://github.com/bazelbuild/bazel/issues/7386). It's
-# particularly helpful for Pigweed, because we have many potential package name
-# collisions due to a profusion of stuttering paths like
-# pw_transfer/py/pw_transfer.
-common --incompatible_default_to_explicit_init_py
-
# Error output settings.
common --verbose_failures
test --test_output=errors
@@ -71,6 +97,10 @@
common:remote_cache --google_default_credentials=true
common:remote_cache --remote_instance_name=projects/pigweed-rbe-open/instances/default-instance
common:remote_cache --remote_upload_local_results=false
+# TODO: https://github.com/bazelbuild/bazel/issues/24867 - This flag breaks
+# runfiles handling with remote caching, and causes a bunch of
+# java.io.FileNotFoundException when creating runfiles trees.
+common:remote_cache --experimental_inprocess_symlink_creation=false
# User bazelrc file; see
# https://bazel.build/configure/best-practices#bazelrc-file
diff --git a/.bazelversion b/.bazelversion
index 41b382c..ae9a76b 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-1ff5af18d045e8f30a2a0367470db4e8225a785c
+8.0.0
diff --git a/MODULE.bazel b/MODULE.bazel
index c84d294..a714e9b 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -20,22 +20,16 @@
bazel_dep(name = "pico-sdk", version = "2.0.0")
bazel_dep(name = "pigweed")
bazel_dep(name = "platforms", version = "0.0.10")
-bazel_dep(name = "pw_toolchain")
-bazel_dep(name = "rules_cc", version = "0.0.10")
+bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
bazel_dep(name = "rules_platform", version = "0.1.0")
-bazel_dep(name = "rules_python", version = "0.36.0")
+bazel_dep(name = "rules_python", version = "0.40.0")
local_path_override(
module_name = "pigweed",
path = "third_party/pigweed",
)
-local_path_override(
- module_name = "pw_toolchain",
- path = "third_party/pigweed/pw_toolchain_bazel",
-)
-
http_archive = use_repo_rule(
"@bazel_tools//tools/build_defs/repo:http.bzl",
"http_archive",