From 058e436392bcaaebe05a22299594b3d97257cc12 Mon Sep 17 00:00:00 2001 From: Felix Hanau Date: Sat, 26 Oct 2024 04:09:59 +0000 Subject: [PATCH] [EXP] Bazel 8 support --- .bazelrc | 2 + .bazelversion | 3 +- MODULE.bazel | 1 + WORKSPACE | 51 +++++++++++++++++++ build/deps/gen/dep_rules_python.bzl | 8 +-- ...-missing-imports-needed-with-Bazel-8.patch | 19 +++++++ src/workerd/util/BUILD.bazel | 9 +--- 7 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 MODULE.bazel create mode 100644 patches/v8/0021-bazel-Add-missing-imports-needed-with-Bazel-8.patch diff --git a/.bazelrc b/.bazelrc index 3eb4b1c3646..ba4c43a3c31 100644 --- a/.bazelrc +++ b/.bazelrc @@ -371,3 +371,5 @@ build:windows --cxxopt='/Zc:__cplusplus' --host_cxxopt='/Zc:__cplusplus' # enable clang coverage: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html build:clang-coverage --copt="-fprofile-instr-generate" --linkopt="-fprofile-instr-generate" build:clang-coverage --copt="-fcoverage-mapping" --linkopt="-fcoverage-mapping" + +build --enable_workspace --incompatible_autoload_externally="+@rules_python,+@protobuf,@rules_shell" diff --git a/.bazelversion b/.bazelversion index 643916c03f1..d05fd0f1d98 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1,2 @@ -7.3.1 +ed9bbd0e510afce7981f8af5916c034a2476715f +# last available bazel 8 commit as of 10/25 diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000000..af095bf0a1b --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1 @@ +# We don't use bzlmod at this time, but bazel 8 still expects us to have a MODULE.bazel file. diff --git a/WORKSPACE b/WORKSPACE index 6c0666e4569..9d51fc29339 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -14,6 +14,54 @@ deps_gen() load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") +http_archive( + name = "rules_cc", + sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80", + strip_prefix = "rules_cc-0.0.13", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"], +) + +PTAG_NAME = "v28.2" + +PURL = "https://github.com/protocolbuffers/protobuf/releases/download/v28.2/protobuf-28.2.tar.gz" + +PSTRIP_PREFIX = "protobuf-28.2" + +PSHA256 = "b2340aa47faf7ef10a0328190319d3f3bee1b24f426d4ce8f4253b6f27ce16db" + +PTYPE = "tgz" + +http_archive( + name = "protobuf", + sha256 = PSHA256, + strip_prefix = PSTRIP_PREFIX, + type = PTYPE, + url = PURL, +) + +http_archive( + name = "rules_shell", + sha256 = "0d0c56d01c3c40420bf7bf14d73113f8a92fbd9f5cd13205a3b89f72078f0321", + strip_prefix = "rules_shell-0.1.1", + url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.1.1/rules_shell-v0.1.1.tar.gz", +) + +load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") + +rules_shell_dependencies() + +rules_shell_toolchains() + +http_archive( + name = "rules_proto", + sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1", + strip_prefix = "rules_proto-4.0.0", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz", + ], +) + NODE_VERSION = "20.14.0" load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") @@ -53,6 +101,8 @@ load("@rules_python//python:repositories.bzl", "py_repositories", "python_regist py_repositories() +load("@rules_python//python:py_test.bzl", "py_test") + http_archive( name = "com_google_benchmark", integrity = "sha256-a8GApX0j1NlRVRn5KwyD1hsFtbqxiJYfNqx7BrDZ6c4=", @@ -302,6 +352,7 @@ http_archive( "//:patches/v8/0018-Update-illegal-invocation-error-message-in-v8.patch", "//:patches/v8/0019-Implement-cross-request-context-promise-resolve-hand.patch", "//:patches/v8/0020-Modify-where-to-look-for-fast_float-dependency.patch", + "//:patches/v8/0021-bazel-Add-missing-imports-needed-with-Bazel-8.patch", ], strip_prefix = "v8-13.0.245.16", url = "https://github.com/v8/v8/archive/refs/tags/13.0.245.16.tar.gz", diff --git a/build/deps/gen/dep_rules_python.bzl b/build/deps/gen/dep_rules_python.bzl index 05e5799b7c7..a01d1575c2d 100644 --- a/build/deps/gen/dep_rules_python.bzl +++ b/build/deps/gen/dep_rules_python.bzl @@ -2,10 +2,10 @@ load("@//:build/http.bzl", "http_archive") -TAG_NAME = "0.37.0" -URL = "https://api.github.com/repos/bazelbuild/rules_python/tarball/0.37.0" -STRIP_PREFIX = "bazelbuild-rules_python-0c0492d" -SHA256 = "442740dfce802db482633d11302ef0894c2d8641c988aa1aa8f129acccdee2be" +TAG_NAME = "0.37.1" +URL = "https://api.github.com/repos/bazelbuild/rules_python/tarball/0.37.1" +STRIP_PREFIX = "bazelbuild-rules_python-8c3acea" +SHA256 = "3a71f2ab193743465bbaa3b426028577a35e032f052f67018d284a16a3ce328f" TYPE = "tgz" def dep_rules_python(): diff --git a/patches/v8/0021-bazel-Add-missing-imports-needed-with-Bazel-8.patch b/patches/v8/0021-bazel-Add-missing-imports-needed-with-Bazel-8.patch new file mode 100644 index 00000000000..cfff9b08657 --- /dev/null +++ b/patches/v8/0021-bazel-Add-missing-imports-needed-with-Bazel-8.patch @@ -0,0 +1,19 @@ +From c9688d31cd8e1e8cbb5624f9cee367029d5a728a Mon Sep 17 00:00:00 2001 +From: Felix Hanau +Date: Sun, 27 Oct 2024 16:49:31 +0000 +Subject: [bazel] Add missing imports needed with Bazel 8 + + +diff --git a/BUILD.bazel b/BUILD.bazel +index 3fa74551420b48f226553ddaa00eb9926a3b009f..5860920e592b2b22d44bbd6a62783fc472e4dcf7 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -3,7 +3,7 @@ + # found in the LICENSE file. + + load("@bazel_skylib//lib:selects.bzl", "selects") +-load("@rules_python//python:defs.bzl", "py_binary") ++load("@rules_python//python:defs.bzl", "py_binary", "py_test") + load("@v8_python_deps//:requirements.bzl", "requirement") + load( + "@v8//:bazel/defs.bzl", diff --git a/src/workerd/util/BUILD.bazel b/src/workerd/util/BUILD.bazel index f697bfbc119..c6f93fbada4 100644 --- a/src/workerd/util/BUILD.bazel +++ b/src/workerd/util/BUILD.bazel @@ -9,17 +9,10 @@ wd_cc_library( "perfetto-tracing.h", "use-perfetto-categories.h", ], - defines = select({ - "@platforms//os:windows": [], - "//conditions:default": ["WORKERD_USE_PERFETTO"], - }), visibility = ["//visibility:public"], deps = [ "@capnp-cpp//src/kj", - ] + select({ - "@platforms//os:windows": [], - "//conditions:default": ["@perfetto//:libperfetto_client_experimental"], - }), + ], ) # TODO(later): Currently perfetto support is not enabled on Windows simply because the # perfetto bazel build fails on windows for some reason and it's currently not worth