Update to bazel 8.0.0 (#4729)

This updates to bazel 8.0.0, also updating bazel mod deps and tools to
make that function. The release is a couple weeks old, and we haven't
updated in a while, and it's a major release. Note it includes some
incompatible flag flips that this is trying to update with respect to.
I'll try generally enabling incompatible support separately.

The most visible bazel behavior change here will be the change from `~`
to `+` in repo path names. (If you're curious,
https://github.com/bazelbuild/bazel/issues/23127 indicates this fixes a
Windows performance issue)

Note that this is building on top of both the action env update in #4728
(which got me started down this path) and the proto removal in #4731
(which would add significant work to this update). Only the commit
starting at "Work towards bazel 8.0.0" is specifically part of this PR.
This commit is contained in:
Jon Ross-Perkins
2025-01-06 23:50:12 +00:00
committed by GitHub
parent bc637bdd7a
commit ccf51cef23
10 changed files with 2875 additions and 3405 deletions
+3
View File
@@ -7,3 +7,6 @@ bazel-carbon-lang
# See github_tools/MODULE.bazel.
github_tools
# Used as part of repo patching.
third_party/boost_unordered
+12 -1
View File
@@ -128,7 +128,18 @@ build --allow_unresolved_symlinks=false
# RC file here if present.
try-import %workspace%/user.bazelrc
# TODO: WORKSPACE will be removed in bazel 9, should finish moving off.
common --enable_workspace
# The version of treesitter rules we're using depends on empty globs.
# TODO: Look at the different rules in the registry.
common --incompatible_disallow_empty_glob=false
# TODO: Enable as many incompatible flags as we can, per
# https://bazel.build/release/backward-compatibility. To get the latest list,
# using `bazelisk --migrate build //...` will help.
build --incompatible_strict_action_env
common --incompatible_strict_action_env
# This excludes things like rules_android to reduce warnings.
# TODO: Disable this completely.
common --incompatible_autoload_externally=+@rules_java,+@rules_python,+@rules_shell
+1 -1
View File
@@ -1 +1 @@
7.3.0
8.0.0
+2 -2
View File
@@ -2,6 +2,6 @@
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
source external/_main~llvm_project~llvm-project/llvm/utils/gdb-scripts/prettyprinters.py
source external/_main~llvm_project~llvm-project/libcxx/utils/gdb/libcxx/printers.py
source external/+llvm_project+llvm-project/llvm/utils/gdb-scripts/prettyprinters.py
source external/+llvm_project+llvm-project/libcxx/utils/gdb/libcxx/printers.py
python register_libcxx_printer_loader()
+2 -2
View File
@@ -9,7 +9,7 @@
"args": ["--file_tests=${relativeFile}"],
"debuggerRoot": "${workspaceFolder}",
"initCommands": [
"command script import external/_main~llvm_project~llvm-project/llvm/utils/lldbDataFormatters.py",
"command script import external/+llvm_project+llvm-project/llvm/utils/lldbDataFormatters.py",
"settings set target.source-map \".\" \"${workspaceFolder}\""
],
"env": { "TEST_TMPDIR": "/tmp" }
@@ -28,7 +28,7 @@
],
"debuggerRoot": "${workspaceFolder}",
"initCommands": [
"command script import external/_main~llvm_project~llvm-project/llvm/utils/lldbDataFormatters.py",
"command script import external/+llvm_project+llvm-project/llvm/utils/lldbDataFormatters.py",
"settings set target.source-map \".\" \"${workspaceFolder}\""
]
}
+13 -13
View File
@@ -29,11 +29,11 @@ http_archive = use_repo_rule(
)
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "abseil-cpp", version = "20240116.2")
bazel_dep(name = "re2", version = "2024-06-01")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "google_benchmark", version = "1.8.4")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "abseil-cpp", version = "20240722.0.bcr.2")
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
bazel_dep(name = "googletest", version = "1.15.2")
bazel_dep(name = "google_benchmark", version = "1.8.5")
# The registry only has an old version. We use that here to avoid a miss but
# override it with a newer version.
@@ -60,15 +60,15 @@ archive_override(
bazel_dep(name = "tcmalloc", version = "0.0.0-20240411-5ed309d", dev_dependency = True)
git_override(
module_name = "tcmalloc",
# HEAD as of 2024-07-14.
commit = "923df94c922e0cd2d0512c1662d374f63c2c0c96",
# HEAD as of 2024-12-20.
commit = "91765c11461a01579fcbdddf430a556b818818c4",
remote = "https://github.com/google/tcmalloc.git",
)
bazel_dep(name = "rules_bison", version = "0.2.2")
bazel_dep(name = "rules_flex", version = "0.2.1")
bazel_dep(name = "rules_m4", version = "0.2.3")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_bison", version = "0.3")
bazel_dep(name = "rules_flex", version = "0.3")
bazel_dep(name = "rules_m4", version = "0.2.4")
bazel_dep(name = "rules_cc", version = "0.1.0")
bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
git_override(
@@ -106,7 +106,7 @@ http_archive(
# Required for llvm-project.
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "zlib", version = "1.3.1.bcr.3", repo_name = "llvm_zlib")
bazel_dep(name = "zlib", version = "1.3.1.bcr.4", repo_name = "llvm_zlib")
bazel_dep(name = "zstd", version = "1.5.6", repo_name = "llvm_zstd")
###############################################################################
@@ -143,7 +143,7 @@ use_repo(llvm_project, "llvm-project")
# Python
###############################################################################
bazel_dep(name = "rules_python", version = "0.33.1")
bazel_dep(name = "rules_python", version = "1.0.0")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
+2807 -3346
View File
File diff suppressed because it is too large Load Diff
+11 -16
View File
@@ -29,15 +29,13 @@ try:
except FileNotFoundError:
sys.exit("ERROR: unable to find deps file: %s" % deps_path)
# bazel_dep repos can have a `name~version` format, whereas use_repo and
# use_repo_rule have a `@@_main~rule_name~repo_name` format. We process the
# latter case first because we only have a couple; once done, we can assume
# anything after the ~ is a version.
# This errors out on dependencies that aren't recognized, and continues on
# allowed dependencies.
for dep in deps:
print("Checking dependency: " + dep)
repo, _, rule = dep.partition("//")
if repo == "@@_main~llvm_project~llvm-project":
if repo == "@@+llvm_project+llvm-project":
package, _, rule = rule.partition(":")
# Other packages in the LLVM project shouldn't be accidentally used
@@ -63,34 +61,31 @@ for dep in deps:
# The rest of LLVM, LLD, and Clang themselves are safe to depend on.
continue
# Ignore the version, just use the repo name.
repo_base = repo.split("~")[0]
# Carbon code is always allowed.
if repo_base == "" and not rule.startswith("third_party"):
if repo == "" and not rule.startswith("third_party"):
continue
# An empty stub library added by rules_cc:
# https://github.com/bazelbuild/rules_cc/blob/main/BUILD
if repo_base == "@@rules_cc" and rule == ":link_extra_lib":
if repo == "@@rules_cc+" and rule == ":link_extra_lib":
continue
# An utility library provided by Bazel that is under a compatible license.
if repo_base == "@@bazel_tools" and rule == "tools/cpp/runfiles:runfiles":
if repo == "@@bazel_tools" and rule == "tools/cpp/runfiles:runfiles":
continue
# These are stubs wrapping system libraries for LLVM. They aren't
# distributed and so should be fine.
if repo_base in (
"@@zlib",
"@@zstd",
if repo in (
"@@zlib+",
"@@zstd+",
):
continue
# This should never be reached from non-test code, but these targets do
# exist. Specially diagnose them to try to provide a more helpful
# message.
if repo_base in (
if repo in (
"@google_benchmark",
"@abseil-cpp",
"@googletest",
@@ -98,4 +93,4 @@ for dep in deps:
sys.exit("ERROR: dependency only allowed in test code: %s" % dep)
# Conservatively fail if a dependency isn't explicitly allowed above.
sys.exit("ERROR: unknown dependency: %s" % dep)
sys.exit(f"ERROR: unknown dependency on {repo}: {dep}")
+1 -1
View File
@@ -324,7 +324,7 @@ echo $CC
which clang
which clang-16
clang --version
grep llvm_bindir $(bazel info workspace)/bazel-execroot/external/_main\~clang_toolchain_extension\~bazel_cc_toolchain/clang_detected_variables.bzl
grep llvm_bindir $(bazel info workspace)/bazel-execroot/external/+clang_toolchain_extension+bazel_cc_toolchain/clang_detected_variables.bzl
# If on macOS:
brew --prefix llvm
+23 -23
View File
@@ -35,18 +35,18 @@ class ReleaseInfo(NamedTuple):
_BAZEL_TOOLS_URL = (
"https://github.com/bazelbuild/buildtools/releases/download/v7.1.2/"
"https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/"
)
# Structured information per release tool.
_RELEASES = {
Release.BAZELISK: ReleaseInfo(
"https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/", "-"
"https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/", "-"
),
Release.BUILDIFIER: ReleaseInfo(_BAZEL_TOOLS_URL, "-"),
Release.BUILDOZER: ReleaseInfo(_BAZEL_TOOLS_URL, "-"),
Release.TARGET_DETERMINATOR: ReleaseInfo(
"https://github.com/bazel-contrib/target-determinator/releases/download/v0.27.0/", # noqa: E501
"https://github.com/bazel-contrib/target-determinator/releases/download/v0.30.0/", # noqa: E501
".",
),
}
@@ -59,32 +59,32 @@ _RELEASES = {
# to make copy-paste updates simpler.
_RELEASE_SHAS = {
Release.BAZELISK: {
"darwin-amd64": "51a6228d51704c656df9fceacad18d64f265b973905b3efdcf8a504b687545bf", # noqa: E501
"darwin-arm64": "29753341c0ddc35931fb240e247fbba0b83ef81bccc2433dd075363ec02a67a6", # noqa: E501
"linux-amd64": "d9af1fa808c0529753c3befda75123236a711d971d3485a390507122148773a3", # noqa: E501
"linux-arm64": "467ec3821aca5e278c8570b7c25e0dfc1a061d2873be89e4a266aaf488148426", # noqa: E501
"windows-amd64.exe": "4175ce7ef4b552fb17e93ce49a245679dc26a35cf2fbc7c3146daca6ffc7a81e", # noqa: E501
"darwin-amd64": "0af019eeb642fa70744419d02aa32df55e6e7a084105d49fb26801a660aa56d3", # noqa: E501
"darwin-arm64": "b13dd89c6ecd90944ca3539f5a2c715a18f69b7458878c471a902a8e482ceb4b", # noqa: E501
"linux-amd64": "fd8fdff418a1758887520fa42da7e6ae39aefc788cf5e7f7bb8db6934d279fc4", # noqa: E501
"linux-arm64": "4c8d966e40ac2c4efcc7f1a5a5cceef2c0a2f16b957e791fa7a867cce31e8fcb", # noqa: E501
"windows-amd64.exe": "641a3dfebd717703675f912917735c44b45cf6300bfdfb924537f3cfbffcdd92", # noqa: E501
},
Release.BUILDIFIER: {
"darwin-amd64": "687c49c318fb655970cf716eed3c7bfc9caeea4f2931a2fd36593c458de0c537", # noqa: E501
"darwin-arm64": "d0909b645496608fd6dfc67f95d9d3b01d90736d7b8c8ec41e802cb0b7ceae7c", # noqa: E501
"linux-amd64": "28285fe7e39ed23dc1a3a525dfcdccbc96c0034ff1d4277905d2672a71b38f13", # noqa: E501
"linux-arm64": "c22a44eee37b8927167ee6ee67573303f4e31171e7ec3a8ea021a6a660040437", # noqa: E501
"windows-amd64.exe": "a8331515019d8d3e01baa1c76fda19e8e6e3e05532d4b0bce759bd759d0cafb7", # noqa: E501
"darwin-amd64": "375f823103d01620aaec20a0c29c6cbca99f4fd0725ae30b93655c6704f44d71", # noqa: E501
"darwin-arm64": "5a6afc6ac7a09f5455ba0b89bd99d5ae23b4174dc5dc9d6c0ed5ce8caac3f813", # noqa: E501
"linux-amd64": "5474cc5128a74e806783d54081f581662c4be8ae65022f557e9281ed5dc88009", # noqa: E501
"linux-arm64": "0bf86c4bfffaf4f08eed77bde5b2082e4ae5039a11e2e8b03984c173c34a561c", # noqa: E501
"windows-amd64.exe": "370cd576075ad29930a82f5de132f1a1de4084c784a82514bd4da80c85acf4a8", # noqa: E501
},
Release.BUILDOZER: {
"darwin-amd64": "90da5cf4f7db73007977a8c6bec23fa7022265978187e1da8df5edc91daf6ee1", # noqa: E501
"darwin-arm64": "bedff301bc51f04da46d2c8900c1753032ea88485af375a9f1b7bed0915558e0", # noqa: E501
"linux-amd64": "8d5c459ab21b411b8be059a8bdf59f0d3eabf9dff943d5eccb80e36e525cc09d", # noqa: E501
"linux-arm64": "a00d1790e8c92c5022d83e345d6629506836d73c23c5338d5f777589bfaed02d", # noqa: E501
"windows-amd64.exe": "3a650e10f07787760889d7e5694924d881265ae2384499fd59ada7c39c02366e", # noqa: E501
"darwin-amd64": "854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2", # noqa: E501
"darwin-arm64": "31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364", # noqa: E501
"linux-amd64": "3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4", # noqa: E501
"linux-arm64": "0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328", # noqa: E501
"windows-amd64.exe": "58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf", # noqa: E501
},
Release.TARGET_DETERMINATOR: {
"darwin.amd64": "f3ef5abce3499926534237ffa183f54139c4760e376813973b35f8cfa5eb50cf", # noqa: E501
"darwin.arm64": "17ee63f8f34c4f61907cf963ce81463b3be5b0a67b068beb02ab9a8cf7fb13d5", # noqa: E501
"linux.amd64": "65000bba3a5eb1713d93b1e08e33b6fbe5787535664bbc1ba2f4166b0d26d0a1", # noqa: E501
"linux.arm64": "99146eef911873f8dbba722214d4c382ebbeab52b0e030e89314db85b70c8558", # noqa: E501
"windows.amd64.exe": "b59a8122a5b72517c8488a638afb8fc9c78da2eaa3c6e7ecb9638052a3ebc3ee", # noqa: E501
"darwin.amd64": "faa79bed4f3b516e64532beafabf4c340aa0f67c52770d9e74782b8d32033b8c", # noqa: E501
"darwin.arm64": "0536158d45ac9d59e5fb5fd9f061a407f28e9e3d9d95ccaa4832583ed4cf13b8", # noqa: E501
"linux.amd64": "2c75ff991eb5fe46d6df3f6266cac8fb8f3abf4037be486e4c5dc871bd6c4d64", # noqa: E501
"linux.arm64": "5ec31448c87a972583e0213028e83fefe7f566ccc9d64412e333ed12390573c5", # noqa: E501
"windows.amd64.exe": "11449d0388deae5b04372be35e4b480f3beeffa8b954e707d60ebd15d3ebe428", # noqa: E501
},
}