From 594d370819c8d247f6e73120bdf5e6255f298983 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 21 Dec 2023 12:59:52 -0800 Subject: [PATCH] [Build] Prepared for Bazel 7 (#35374) This is a prerequisite change to start supporting Bazel 7. Changes are - Disabled bzlmod which Bazel 7 begins to enable by default. This eventually needs to be done to support bzlmod but not now. - Upgraded some bazel rule dependencies which are required to support Bazel 7. - Using Python 3 explcitly as Bazel 7 begins to reject Python 2. Note that this isn't enough to enable Bazel 7 by default and another PR will follow for that. Closes #35374 PiperOrigin-RevId: 592931675 --- .gitignore | 3 ++ WORKSPACE | 7 ++++ bazel/grpc_deps.bzl | 38 ++++++++++++------- test/cpp/naming/BUILD | 1 + third_party/benchmark | 2 +- tools/bazel.rc | 4 ++ .../run_tests/sanity/check_bazel_workspace.py | 2 + tools/run_tests/sanity/check_submodules.sh | 2 +- 8 files changed, 43 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index b08fa159e69..cce15572a73 100644 --- a/.gitignore +++ b/.gitignore @@ -181,3 +181,6 @@ iwyu_build/ # fuzzer logs fuzz-*.log +# bazel module files (MODULE.bazel will need to be removed here) +MODULE.bazel +MODULE.bazel.lock diff --git a/WORKSPACE b/WORKSPACE index 39ec89b02c5..472d904c525 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -89,6 +89,13 @@ http_archive( url = "https://github.com/bazelbuild/rules_swift/releases/download/1.7.1/rules_swift.1.7.1.tar.gz", ) +load( + "@build_bazel_apple_support//lib:repositories.bzl", + "apple_support_dependencies", +) + +apple_support_dependencies() + load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 6765a8b6805..dc2500fe63c 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -230,6 +230,16 @@ def grpc_deps(): actual = "@com_google_googleapis//google/logging/v2:logging_cc_proto", ) + if "platforms" not in native.existing_rules(): + http_archive( + name = "platforms", + sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", + ], + ) + if "boringssl" not in native.existing_rules(): http_archive( name = "boringssl", @@ -298,22 +308,22 @@ def grpc_deps(): if "rules_cc" not in native.existing_rules(): http_archive( name = "rules_cc", - sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40", - strip_prefix = "rules_cc-0.0.6", + sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", + strip_prefix = "rules_cc-0.0.9", urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz", - "https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz", + "https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz", ], ) if "com_github_google_benchmark" not in native.existing_rules(): http_archive( name = "com_github_google_benchmark", - sha256 = "4e47ca279d5ae967c506c136bd8afb42eedcaf010aebb48a0e87790cae4b488a", - strip_prefix = "benchmark-015d1a091af6937488242b70121858bce8fd40e9", + sha256 = "8e7b955f04bc6984e4f14074d0d191474f76a6c8e849e04a9dced49bc975f2d4", + strip_prefix = "benchmark-344117638c8ff7e239044fd0fa7085839fc03021", urls = [ - # v1.8.2 - "https://github.com/google/benchmark/archive/015d1a091af6937488242b70121858bce8fd40e9.tar.gz", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/benchmark/archive/344117638c8ff7e239044fd0fa7085839fc03021.tar.gz", + "https://github.com/google/benchmark/archive/344117638c8ff7e239044fd0fa7085839fc03021.tar.gz", ], ) @@ -419,20 +429,20 @@ def grpc_deps(): if "build_bazel_rules_apple" not in native.existing_rules(): http_archive( name = "build_bazel_rules_apple", - sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911", + sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7", urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz", - "https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz", + "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz", ], ) if "build_bazel_apple_support" not in native.existing_rules(): http_archive( name = "build_bazel_apple_support", - sha256 = "f4fdf5c9b42b92ea12f229b265d74bb8cedb8208ca7a445b383c9f866cf53392", + sha256 = "cf4d63f39c7ba9059f70e995bf5fe1019267d3f77379c2028561a5d7645ef67c", urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/1.3.1/apple_support.1.3.1.tar.gz", - "https://github.com/bazelbuild/apple_support/releases/download/1.3.1/apple_support.1.3.1.tar.gz", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/1.11.1/apple_support.1.11.1.tar.gz", + "https://github.com/bazelbuild/apple_support/releases/download/1.11.1/apple_support.1.11.1.tar.gz", ], ) diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD index 24d193c7edd..258b0cedcec 100644 --- a/test/cpp/naming/BUILD +++ b/test/cpp/naming/BUILD @@ -32,6 +32,7 @@ grpc_py_binary( srcs = [ "resolver_component_tests_runner.py", ], + python_version = "PY3", ) grpc_cc_test( diff --git a/third_party/benchmark b/third_party/benchmark index 015d1a091af..344117638c8 160000 --- a/third_party/benchmark +++ b/third_party/benchmark @@ -1 +1 @@ -Subproject commit 015d1a091af6937488242b70121858bce8fd40e9 +Subproject commit 344117638c8ff7e239044fd0fa7085839fc03021 diff --git a/tools/bazel.rc b/tools/bazel.rc index e2795a08791..83fc0aa1767 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -1,5 +1,9 @@ # bazelrc file +# Bazel 7 begins to enable module by default which breaks gRPC build. +# Therefore, this option is disabled until gRPC works with bzlmod. +common --enable_bzlmod=false + # for platform-appropriate cxxopts common --enable_platform_specific_config diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 9e6e436f112..24e1f4f694a 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -47,6 +47,7 @@ _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME = ( _TWISTED_CONSTANTLY_DEP_NAME = "com_github_twisted_constantly" _GRPC_DEP_NAMES = [ + "platforms", "boringssl", "zlib", "com_google_protobuf", @@ -83,6 +84,7 @@ _GRPC_DEP_NAMES = [ ] _GRPC_BAZEL_ONLY_DEPS = [ + "platforms", "rules_cc", "com_google_absl", "com_google_fuzztest", diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index ff2b3b85fbe..1462440d240 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -26,7 +26,7 @@ want_submodules=$(mktemp /tmp/submXXXXXX) git submodule | sed 's/+//g' | awk '{ print $2 " " $1 }' | sort >"$submodules" cat <"$want_submodules" third_party/abseil-cpp 29bf8085f3bf17b84d30e34b3d7ff8248fda404e -third_party/benchmark 015d1a091af6937488242b70121858bce8fd40e9 +third_party/benchmark 344117638c8ff7e239044fd0fa7085839fc03021 third_party/bloaty 60209eb1ccc34d5deefb002d1b7f37545204f7f2 third_party/boringssl-with-bazel 2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b third_party/cares/cares 6360e96b5cf8e5980c887ce58ef727e53d77243a