Skip to content

Commit c6437e8

Browse files
chore(defaults): Update for 9 > Bazel >= 8 (#689)
Just as it says on the tin. ### Changes are visible to end-users: no ### Test plan This is the test plan. --------- Co-authored-by: aspect-marvin[bot] <marvin@aspect.build>
1 parent b2abc99 commit c6437e8

File tree

8 files changed

+90
-42
lines changed

8 files changed

+90
-42
lines changed

.bcr/patches/remove_dev_deps.patch

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
--- a/MODULE.bazel 2025-10-25 10:38:24
2-
+++ b/MODULE.bazel 2025-10-25 10:38:24
3-
@@ -24,554 +24,3 @@
1+
--- a/MODULE.bazel 2025-10-28 11:19:35
2+
+++ b/MODULE.bazel 2025-10-28 11:19:35
3+
@@ -22,557 +22,5 @@
4+
"@aspect_rules_py//py/private/toolchain/venv/...",
5+
"@aspect_rules_py//py/private/toolchain/unpack/...",
46
"@aspect_rules_py//py/private/toolchain/shim/...",
5-
)
6-
7+
-)
8+
-
79
-################################################################################
810
-# Dev deps
911
-#
@@ -291,8 +293,8 @@
291293
- ],
292294
- target_triple = "x86_64-unknown-linux-musl",
293295
- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above)
294-
-)
295-
-
296+
)
297+
296298
-# -> linux arm (musl)
297299
-rust.repository_set(
298300
- name = "rust_darwin_x86_64",
@@ -431,6 +433,7 @@
431433
-# TODO: Replace with bazel_features?
432434
-# cf. https://github.com/bazel-contrib/bazelrc-preset.bzl/blob/main/MODULE.bazel#L8C1-L10C70
433435
-bazel_dep(name = "bazel_features", version = "1.0.0")
436+
-bazel_dep(name = "rules_shell", version = "0.6.1")
434437
-
435438
-version = use_extension("@bazel_features//private:extensions.bzl", "version_extension")
436439
-use_repo(version, "bazel_features_globals", "bazel_features_version")

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ use_repo(crate, "crates")
451451
# TODO: Replace with bazel_features?
452452
# cf. https://github.com/bazel-contrib/bazelrc-preset.bzl/blob/main/MODULE.bazel#L8C1-L10C70
453453
bazel_dep(name = "bazel_features", version = "1.0.0")
454+
bazel_dep(name = "rules_shell", version = "0.6.1")
454455

455456
version = use_extension("@bazel_features//private:extensions.bzl", "version_extension")
456457
use_repo(version, "bazel_features_globals", "bazel_features_version")

bazel/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ bazelrc_preset(
1010
# USE_BAZEL_VERSION for testing.
1111
doc_link_template = "https://registry.build/flag/bazel?filter={flag}",
1212
strict = True,
13-
target_compatible_with = incompatible_with("8.0.0"),
13+
target_compatible_with = incompatible_with("9.0.0"),
1414
)

bazel/defaults.bazelrc

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ common:ci --announce_rc
1515
common --nobuild_runfile_links
1616
# Docs: https://registry.build/flag/bazel?filter=build_runfile_links
1717

18-
# See https://github.com/bazelbuild/bazel/issues/20577
19-
coverage --build_runfile_links
20-
# Docs: https://registry.build/flag/bazel?filter=build_runfile_links
21-
2218
# Always run tests even if they have cached results.
2319
# This ensures tests are executed fresh each time, useful for debugging and ensuring test reliability.
2420
common:debug --nocache_test_results
@@ -59,22 +55,6 @@ common --noexperimental_check_external_repository_files
5955
common --experimental_fetch_all_coverage_outputs
6056
# Docs: https://registry.build/flag/bazel?filter=experimental_fetch_all_coverage_outputs
6157

62-
# This flag was added in Bazel 6.2.0 with a default of zero:
63-
# https://github.com/bazelbuild/bazel/commit/24b45890c431de98d586fdfe5777031612049135
64-
# For Bazel 8.0.0rc1 the default was changed to 5:
65-
# https://github.com/bazelbuild/bazel/commit/739e37de66f4913bec1a55b2f2a162e7db6f2d0f
66-
# Back-port the updated flag default value to older Bazel versions.
67-
common --experimental_remote_cache_eviction_retries=5
68-
# Docs: https://registry.build/flag/bazel?filter=experimental_remote_cache_eviction_retries
69-
70-
# This flag was added in Bazel 5.0.0 with a default of zero:
71-
# https://github.com/bazelbuild/bazel/commit/a1137ec1338d9549fd34a9a74502ffa58c286a8e
72-
# For Bazel 8.0.0 the default was changed to 5:
73-
# https://github.com/bazelbuild/bazel/commit/9335cf989ee6a678ca10bc4da72214634cef0a57
74-
# Back-port the updated flag default value to older Bazel versions.
75-
common --experimental_repository_downloader_retries=5
76-
# Docs: https://registry.build/flag/bazel?filter=experimental_repository_downloader_retries
77-
7858
# Set this flag to enable re-tries of failed tests on CI.
7959
# When any test target fails, try one or more times. This applies regardless of whether the "flaky"
8060
# tag appears on the target definition.
@@ -116,25 +96,13 @@ startup --host_jvm_args="-DBAZEL_TRACK_SOURCE_DIRECTORIES=1"
11696
common --incompatible_default_to_explicit_init_py
11797
# Docs: https://registry.build/flag/bazel?filter=incompatible_default_to_explicit_init_py
11898

119-
# Disallow empty glob patterns.
120-
# The glob() function tends to be error-prone, because any typo in a path will silently return an empty list.
121-
# This flag was added in Bazel 0.27 and flipped in Bazel 8: https://github.com/bazelbuild/bazel/issues/8195
122-
common --incompatible_disallow_empty_glob
123-
# Docs: https://registry.build/flag/bazel?filter=incompatible_disallow_empty_glob
124-
12599
# Make builds more reproducible by using a static value for PATH and not inheriting LD_LIBRARY_PATH.
126100
# Use `--action_env=ENV_VARIABLE` if you want to inherit specific variables from the environment where Bazel runs.
127101
# Note that doing so can prevent cross-user caching if a shared cache is used.
128102
# See https://github.com/bazelbuild/bazel/issues/2574 for more details.
129103
common --incompatible_strict_action_env
130104
# Docs: https://registry.build/flag/bazel?filter=incompatible_strict_action_env
131105

132-
# Performance improvement: avoid laying out a second copy of the runfiles tree.
133-
# See https://github.com/bazelbuild/bazel/issues/23574.
134-
# This flag was flipped for Bazel 8.
135-
common --nolegacy_external_runfiles
136-
# Docs: https://registry.build/flag/bazel?filter=legacy_external_runfiles
137-
138106
# On CI, don't download remote outputs to the local machine.
139107
# Most CI pipelines don't need to access the files and they can remain at rest on the remote cache.
140108
# Significant time can be spent on needless downloads, which is especially noticeable on fully-cached builds.
@@ -235,3 +203,60 @@ test:ci --test_summary="terse"
235203
# Set to a high value to allow tests to complete even if they take longer than expected.
236204
common:debug --test_timeout=9999
237205
# Docs: https://registry.build/flag/bazel?filter=test_timeout
206+
207+
# Automatic execution groups select an execution platform for each toolchain type.
208+
# In other words, one target can have multiple execution platforms without defining execution groups.
209+
# Migration requires setting a toolchain parameter inside ctx.actions.{run, run_shell} for actions which use tool or executable from a toolchain.
210+
#
211+
# See https://github.com/bazelbuild/bazel/issues/17134
212+
common --incompatible_auto_exec_groups
213+
# Docs: https://registry.build/flag/bazel?filter=incompatible_auto_exec_groups
214+
215+
# Language specific rules (Protos, Java, C++, Android) are being rewritten to Starlark and moved from Bazel into their rules repositories
216+
# (protobuf, rules_java, rules_cc, rules_android, apple_support).
217+
# Because of the move the rules need to be loaded from their repositories.
218+
# This requires adding load statements to all bzl and BUILD files that are using those rules.
219+
#
220+
# See https://github.com/bazelbuild/bazel/issues/23043
221+
common --incompatible_autoload_externally=""
222+
# Docs: https://registry.build/flag/bazel?filter=incompatible_autoload_externally
223+
224+
# Visibility on config_setting isn't historically enforced. This is purely for legacy reasons.
225+
# There's no philosophical reason to distinguish them.
226+
# Treat all config_settings as if they follow standard visibility logic at https://docs.bazel.build/versions/master/visibility.html:
227+
# have them set visibility explicitly if they'll be used anywhere outside their own package.
228+
#
229+
# See https://github.com/bazelbuild/bazel/issues/12933
230+
common --incompatible_config_setting_private_default_visibility
231+
# Docs: https://registry.build/flag/bazel?filter=incompatible_config_setting_private_default_visibility
232+
233+
# When set to `true`, native repo rules cannot be used in WORKSPACE; their Starlark counterparts must be used. Native repo rules already can't be used in Bzlmod.
234+
#
235+
# See https://github.com/bazelbuild/bazel/issues/22080
236+
common --incompatible_disable_native_repo_rules
237+
# Docs: https://registry.build/flag/bazel?filter=incompatible_disable_native_repo_rules
238+
239+
# Removes create_executable attribute from java_binary.
240+
# Migration to java_single_jar is needed.
241+
#
242+
# See https://github.com/bazelbuild/bazel/issues/19687
243+
common --incompatible_disable_non_executable_java_binary
244+
# Docs: https://registry.build/flag/bazel?filter=incompatible_disable_non_executable_java_binary
245+
246+
# Changes this syntax to be illegal: cfg = "host"
247+
# Instead use: cfg = "exec"
248+
#
249+
# See https://github.com/bazelbuild/bazel/issues/17032
250+
common --incompatible_disable_starlark_host_transitions
251+
# Docs: https://registry.build/flag/bazel?filter=incompatible_disable_starlark_host_transitions
252+
253+
# Address a counterintuitive interaction with --action_env and it's affect on repository environments.
254+
#
255+
# Note that this will implicitly affect other features which inherit the repository environment such as:
256+
# - Credential managers
257+
# - Download manager
258+
# - And possibly more.
259+
#
260+
# See https://github.com/bazelbuild/bazel/issues/26222
261+
common --incompatible_repo_env_ignores_action_env
262+
# Docs: https://registry.build/flag/bazel?filter=incompatible_repo_env_ignores_action_env

bazel/include/test.MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# TODO: Replace with bazel_features?
22
# cf. https://github.com/bazel-contrib/bazelrc-preset.bzl/blob/main/MODULE.bazel#L8C1-L10C70
33
bazel_dep(name = "bazel_features", version = "1.0.0")
4+
bazel_dep(name = "rules_shell", version = "0.6.1")
45

56
version = use_extension("@bazel_features//private:extensions.bzl", "version_extension")
67
use_repo(version, "bazel_features_globals", "bazel_features_version")

py/private/py_venv/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ config_setting(
1919
flag_values = {
2020
":debug_venv": "True",
2121
},
22+
# This needs to be set public for global use since we select() on it from
23+
# macros which analyze visibility wrt the expanding package.
24+
#
25+
# TODO: Eliminate this in favor of a proper bool flag or something.
26+
visibility = [
27+
"//visibility:public",
28+
],
2229
)
2330

2431
bzl_library(

py/private/py_venv/py_venv.bzl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ def _py_venv_base_impl(ctx):
145145
outputs = [
146146
venv_dir,
147147
],
148+
# TODO: Is this right? The venv toolchain isn't quite in the right
149+
# configuration (target not exec) so we have to use a different source
150+
# of the target, but it is (logically) the venv toolchain.
151+
toolchain = VENV_TOOLCHAIN,
148152
)
149153

150154
return venv_dir, rfs.merge_all([
@@ -411,7 +415,10 @@ _py_venv = rule(
411415

412416
def _wrap_with_debug(rule):
413417
def helper(**kwargs):
414-
kwargs["debug"] = select({Label(":debug_venv_setting"): True, "//conditions:default": False})
418+
kwargs["debug"] = select({
419+
Label(":debug_venv_setting"): True,
420+
"//conditions:default": False,
421+
})
415422
return rule(**kwargs)
416423

417424
return helper
@@ -443,7 +450,10 @@ def py_venv_link(venv_name = None, srcs = [], **kwargs):
443450

444451
# Note that the binary is already wrapped with debug
445452
link_script = str(Label("//py/private/py_venv:link.py"))
446-
kwargs["debug"] = select({Label(":debug_venv_setting"): True, "//conditions:default": False})
453+
kwargs["debug"] = select({
454+
Label(":debug_venv_setting"): True,
455+
"//conditions:default": False,
456+
})
447457
py_venv_binary(
448458
args = [] + (["--name=" + venv_name] if venv_name else []),
449459
main = link_script,

py/tests/py-venv-standalone-interpreter/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
12
load("//py/private/py_venv:defs.bzl", "py_venv_binary")
23

34
py_venv_binary(

0 commit comments

Comments
 (0)