Skip to content

Commit 233d6fd

Browse files
committed
refactor(bazel): move v8 and perfetto to bzlmod
1 parent 006c957 commit 233d6fd

File tree

9 files changed

+107
-102
lines changed

9 files changed

+107
-102
lines changed

MODULE.bazel

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ bazel_dep(name = "bazel_features", version = "1.35.0")
55
bazel_dep(name = "bazel_skylib", version = "1.8.1")
66
bazel_dep(name = "rules_shell", version = "0.6.0")
77

8-
# needed by perfetto, but not actually used.
9-
bazel_dep(name = "rules_android", version = "0.6.4")
10-
11-
# protobuf for use with perfetto
12-
# Updated protobuf can't be imported reliably under WORKSPACE logic in Bazel 8, so we need to use
13-
# bzlmod.
14-
bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
15-
168
# abseil is used by protobuf and tcmalloc.
179
bazel_dep(name = "abseil-cpp", version = "20250814.0")
1810

@@ -44,7 +36,6 @@ git_override(
4436
bazel_dep(name = "boringssl", version = "0.20250818.0", repo_name = "ssl")
4537

4638
include("//build/deps:deps.MODULE.bazel")
47-
4839
include("//build/deps:nodejs.MODULE.bazel")
49-
5040
include("//build/deps:python.MODULE.bazel")
41+
include("//build/deps:v8.MODULE.bazel")

WORKSPACE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ load("//:build/rust_toolchains.bzl", "rust_toolchains")
1919

2020
rust_toolchains()
2121

22-
load("@//build/deps:v8.bzl", "deps_v8")
23-
24-
deps_v8()
25-
2622
bind(
2723
name = "icu",
2824
actual = "@com_googlesource_chromium_icu//:icu",

build/deps/v8.MODULE.bazel

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""
2+
V8 and its dependencies
3+
4+
Note that googlesource does not generate tarballs deterministically, so we cannot use
5+
http_archive: https://github.com/google/gitiles/issues/84
6+
7+
It would seem that googlesource would rather we use git protocol.
8+
Fine, we can do that.
9+
10+
We previously used shallow_since for our git-based dependencies, but this may actually be
11+
harmful: https://github.com/bazelbuild/bazel/issues/12857
12+
13+
There is an official mirror for V8 itself on GitHub, but not for dependencies like zlib (Chromium
14+
fork), icu (Chromium fork), and trace_event, so we still have to use git for them.
15+
"""
16+
bazel_dep(name = "perfetto", version = "0.0.0")
17+
18+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
19+
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
20+
21+
VERSION = "14.1.146.1"
22+
23+
INTEGRITY = "sha256-2HdTM2N2J1XBI6617Icx73S2qs5+Qd/h4hQUek8CUFU="
24+
25+
PATCHES = [
26+
"0001-Allow-manually-setting-ValueDeserializer-format-vers.patch",
27+
"0002-Allow-manually-setting-ValueSerializer-format-versio.patch",
28+
"0003-Allow-Windows-builds-under-Bazel.patch",
29+
"0004-Disable-bazel-whole-archive-build.patch",
30+
"0005-Speed-up-V8-bazel-build-by-always-using-target-cfg.patch",
31+
"0006-Implement-Promise-Context-Tagging.patch",
32+
"0007-Randomize-the-initial-ExecutionContextId-used-by-the.patch",
33+
"0008-increase-visibility-of-virtual-method.patch",
34+
"0009-Add-ValueSerializer-SetTreatFunctionsAsHostObjects.patch",
35+
"0010-Modify-where-to-look-for-fp16-dependency.-This-depen.patch",
36+
"0011-Revert-heap-Add-masm-specific-unwinding-annotations-.patch",
37+
"0012-Update-illegal-invocation-error-message-in-v8.patch",
38+
"0013-Implement-cross-request-context-promise-resolve-hand.patch",
39+
"0014-Add-another-slot-in-the-isolate-for-embedder.patch",
40+
"0015-Add-ValueSerializer-SetTreatProxiesAsHostObjects.patch",
41+
"0016-Disable-memory-leak-assert-when-shutting-down-V8.patch",
42+
"0017-Enable-V8-shared-linkage.patch",
43+
"0018-Modify-where-to-look-for-fast_float-and-simdutf.patch",
44+
"0019-Remove-unneded-latomic-linker-flag.patch",
45+
"0020-Add-methods-to-get-heap-and-external-memory-sizes-di.patch",
46+
"0021-Remove-DCHECK-from-WriteOneByteV2-to-skip-v8-fatal.patch",
47+
"0022-Port-concurrent-mksnapshot-support.patch",
48+
"0023-Port-V8_USE_ZLIB-support.patch",
49+
"0024-Modify-where-to-look-for-dragonbox.patch",
50+
"0025-Disable-slow-handle-check.patch",
51+
"0026-Workaround-for-builtin-can-allocate-issue.patch",
52+
"0027-Implement-additional-Exception-construction-methods.patch",
53+
"0028-Export-icudata-file-to-facilitate-embedding-it.patch",
54+
"0029-IsGraphAsync-module-cast-check.patch",
55+
]
56+
57+
http_archive(
58+
name = "v8",
59+
integrity = INTEGRITY,
60+
patch_args = ["-p1"],
61+
patches = ["//:patches/v8/" + p for p in PATCHES],
62+
strip_prefix = "v8-" + VERSION,
63+
url = "https://github.com/v8/v8/archive/refs/tags/" + VERSION + ".tar.gz",
64+
)
65+
66+
git_repository(
67+
name = "com_googlesource_chromium_icu",
68+
build_file = "@v8//:bazel/BUILD.icu",
69+
commit = "1b2e3e8a421efae36141a7b932b41e315b089af8",
70+
patch_cmds = ["find source -name BUILD.bazel | xargs rm"],
71+
patch_cmds_win = ["Get-ChildItem -Path source -File -Include BUILD.bazel -Recurse | Remove-Item"],
72+
remote = "https://chromium.googlesource.com/chromium/deps/icu.git",
73+
)
74+
75+
archive_override(
76+
module_name = "perfetto",
77+
patches = ["//:patches/perfetto/MODULE.bazel.patch"],
78+
integrity = "sha256-T5F4h9xXdYfTGMa+AXmewHIkS1cgxu5ierfyJMOwqJA=",
79+
strip_prefix = "perfetto-51.2",
80+
url = "https://github.com/google/perfetto/archive/refs/tags/v51.2.tar.gz",
81+
)
82+
83+
# For use with perfetto, see https://github.com/google/perfetto/blob/main/bazel/standalone/README.md
84+
local_path_override(
85+
module_name = "perfetto_cfg",
86+
path = "build/perfetto",
87+
)

build/deps/v8.bzl

Lines changed: 0 additions & 84 deletions
This file was deleted.

build/perfetto/BUILD

Whitespace-only changes.

build/perfetto/MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
module(name = "perfetto_cfg")

build/perfetto/perfetto_cfg.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ PERFETTO_CONFIG = struct(
6060
protobuf_py = [],
6161
pandas_py = [],
6262
tp_vendor_py = [],
63+
tp_resolvers_py = [],
6364

6465
# There are multiple configurations for the function name demangling
6566
# logic in trace processor:

docs/v8-updates.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To update the version of V8 used by workerd, the steps are:
1818

1919
4. Sync the local copy of V8 to the version used by workerd.
2020

21-
First, find workerd's current version of V8 in `v8.bzl`. We will call this `<old_version>`.
21+
First, find workerd's current version of V8 in `v8.MODULE.bazel`. We will call this `<old_version>`.
2222

2323
Then sync your fetched version v8 based on the tag.
2424

@@ -56,7 +56,7 @@ To update the version of V8 used by workerd, the steps are:
5656
8. Remove the existing patches from `<path_to_workerd>/patches/v8` and copy over the latest generated patches
5757
from the V8 directory.
5858

59-
9. Update the `VERSION` for V8 in `v8.bzl`.
59+
9. Update the `VERSION` for V8 in `v8.MODULE.bazel`.
6060

6161
The list of patches should be refreshed if new patches are being added or existing
6262
patches are being removed.
@@ -66,13 +66,13 @@ from the V8 directory.
6666
workerd using the newer V8 version or by running
6767
`openssl dgst -sha256 -binary <tarball_filename> | openssl base64 -A`
6868

69-
10. Update V8's dependencies in `v8.bzl` and `WORKSPACE`.
69+
10. Update V8's dependencies in `v8.MODULE.bazel` and `WORKSPACE`.
7070

7171
You can find the commit versions for V8's dependencies under `<path_to_v8>/DEPS`.
7272

7373
These currently include `zlib` and `com_googlesource_chromium_icu`.
7474
Typically you'll get a build failure if the projects are out of sync. Copy the
75-
commit versions from `v8/DEPS` to the `v8.bzl` or `WORKSPACE` file.
75+
commit versions from `v8/DEPS` to the `v8.MODULE.bazel` or `WORKSPACE` file.
7676

7777
11. Check workerd's tests pass with the updated V8.
7878

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- MODULE.bazel
2+
+++ MODULE.bazel
3+
@@ -11,5 +11,9 @@
4+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5+
# See the License for the specific language governing permissions and
6+
# limitations under the License.
7+
+module(name = "perfetto")
8+
+bazel_dep(name = "perfetto_cfg", version = "0.0.0")
9+
+bazel_dep(name = "platforms", version = "1.0.0")
10+
+bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
11+
12+
bazel_dep(name = "rules_android", version = "0.6.0")

0 commit comments

Comments
 (0)