Skip to content

Commit e25c4f1

Browse files
committed
chore: use bazel repos for missing v8 dependencies
Signed-off-by: Matt Leon <[email protected]>
1 parent be9340f commit e25c4f1

File tree

5 files changed

+230
-5
lines changed

5 files changed

+230
-5
lines changed

bazel/external/dragonbox.BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
licenses(["notice"]) # Apache 2
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
cc_library(
8+
name = "dragonbox",
9+
srcs = [],
10+
hdrs = ["include/dragonbox/dragonbox.h"],
11+
includes = ["include/"],
12+
)

bazel/external/fp16.BUILD

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
licenses(["notice"]) # MIT
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
cc_library(
8+
name = "FP16",
9+
hdrs = [
10+
"include/fp16.h",
11+
"include/fp16/bitcasts.h",
12+
"include/fp16/fp16.h",
13+
],
14+
includes = ["include/"],
15+
)

bazel/external/simdutf.BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
licenses(["notice"]) # Apache 2
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
cc_library(
8+
name = "simdutf",
9+
srcs = ["simdutf.cpp"],
10+
hdrs = ["simdutf.h"],
11+
)

bazel/external/v8.patch

Lines changed: 134 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# 1. Disable pointer compression (limits the maximum number of WasmVMs).
2-
# 2. Don't expose Wasm C API (only Wasm C++ API).
3-
# 3. Revert v8 commit b26554ec368e9553782012c96aa5e99b163eaff2, which removed
4-
# use of _allowlist_function_transition from v8 bazel/defs.bzl, since it is
5-
# still required by the version of Bazel we currently use (6.5.0).
1+
From bc2a85e39fd55879b9baed51429c08b27d5514c8 Mon Sep 17 00:00:00 2001
2+
From: Matt Leon <[email protected]>
3+
Date: Wed, 16 Jul 2025 16:55:02 -0400
4+
Subject: [PATCH 1/6] Disable pointer compression
5+
6+
Pointer compression limits the maximum number of WasmVMs.
7+
8+
Signed-off-by: Matt Leon <[email protected]>
9+
---
10+
BUILD.bazel | 2 +-
11+
1 file changed, 1 insertion(+), 1 deletion(-)
612

713
diff --git a/BUILD.bazel b/BUILD.bazel
814
index 3f5a87d054e..0a693b7ee10 100644
@@ -17,6 +23,25 @@ index 3f5a87d054e..0a693b7ee10 100644
1723
)
1824

1925
# Default setting for v8_enable_pointer_compression.
26+
--
27+
2.50.0.727.gbf7dc18ff4-goog
28+
29+
30+
From 61898e9a63ac89a37261c081b84714cfc400a4b1 Mon Sep 17 00:00:00 2001
31+
From: Matt Leon <[email protected]>
32+
Date: Wed, 16 Jul 2025 16:56:31 -0400
33+
Subject: [PATCH 2/6] Restore _allowlist_function_transition
34+
35+
Reverts v8 commit b26554ec368e9553782012c96aa5e99b163eaff2, which removed use of
36+
_allowlist_function_transition from v8 bazel/defs.bzl, since it is still required
37+
by the version of Bazel we currently use (6.5.0).
38+
39+
Signed-off-by: Matt Leon <[email protected]>
40+
---
41+
bazel/defs.bzl | 3 +++
42+
bazel/v8-non-pointer-compression.bzl | 11 +++++++++++
43+
2 files changed, 14 insertions(+)
44+
2045
diff --git a/bazel/defs.bzl b/bazel/defs.bzl
2146
index 0539ea176ac..14d7ace5e59 100644
2247
--- a/bazel/defs.bzl
@@ -53,6 +78,20 @@ index 8c929454840..57336154cf7 100644
5378
},
5479
# Making this executable means it works with "$ bazel run".
5580
executable = True,
81+
--
82+
2.50.0.727.gbf7dc18ff4-goog
83+
84+
85+
From 4a6e7158fd4ca48c75c8e33ea15760c9beea1d2f Mon Sep 17 00:00:00 2001
86+
From: Matt Leon <[email protected]>
87+
Date: Wed, 16 Jul 2025 16:56:52 -0400
88+
Subject: [PATCH 3/6] Don't expose Wasm C API (only Wasm C++ API).
89+
90+
Signed-off-by: Matt Leon <[email protected]>
91+
---
92+
src/wasm/c-api.cc | 4 ++++
93+
1 file changed, 4 insertions(+)
94+
5695
diff --git a/src/wasm/c-api.cc b/src/wasm/c-api.cc
5796
index 05e4029f183..d705be96a16 100644
5897
--- a/src/wasm/c-api.cc
@@ -72,3 +111,93 @@ index 05e4029f183..d705be96a16 100644
72111
} // extern "C"
73112
+
74113
+#endif
114+
--
115+
2.50.0.727.gbf7dc18ff4-goog
116+
117+
118+
From 7b593eb8086dcfe9012d4fa694d622f21dadb731 Mon Sep 17 00:00:00 2001
119+
From: Matt Leon <[email protected]>
120+
Date: Wed, 16 Jul 2025 16:58:02 -0400
121+
Subject: [PATCH 4/6] Stub out fast_float for bazel-supplied version
122+
123+
Signed-off-by: Matt Leon <[email protected]>
124+
---
125+
BUILD.bazel | 2 +-
126+
1 file changed, 1 insertion(+), 1 deletion(-)
127+
128+
diff --git a/BUILD.bazel b/BUILD.bazel
129+
index 0a693b7ee10..eafd9dad20c 100644
130+
--- a/BUILD.bazel
131+
+++ b/BUILD.bazel
132+
@@ -4438,7 +4438,7 @@ v8_library(
133+
],
134+
deps = [
135+
":lib_dragonbox",
136+
- "//third_party/fast_float/src:fast_float",
137+
+ "@fast_float//:fast_float",
138+
":lib_fp16",
139+
":simdutf",
140+
":v8_libbase",
141+
--
142+
2.50.0.727.gbf7dc18ff4-goog
143+
144+
145+
From b442d34b12dd513946f509d9db86839ce8aa4d7f Mon Sep 17 00:00:00 2001
146+
From: Matt Leon <[email protected]>
147+
Date: Wed, 16 Jul 2025 20:04:05 -0400
148+
Subject: [PATCH 5/6] Stub out vendored dependencies for bazel-sourced versions
149+
150+
Signed-off-by: Matt Leon <[email protected]>
151+
---
152+
BUILD.bazel | 6 +++---
153+
1 file changed, 3 insertions(+), 3 deletions(-)
154+
155+
diff --git a/BUILD.bazel b/BUILD.bazel
156+
index eafd9dad20c..ce36666e36e 100644
157+
--- a/BUILD.bazel
158+
+++ b/BUILD.bazel
159+
@@ -4437,10 +4437,10 @@ v8_library(
160+
":noicu/generated_torque_definitions",
161+
],
162+
deps = [
163+
- ":lib_dragonbox",
164+
+ "@dragonbox//:dragonbox",
165+
"@fast_float//:fast_float",
166+
- ":lib_fp16",
167+
- ":simdutf",
168+
+ "@fp16//:FP16",
169+
+ "@simdutf//:simdutf",
170+
":v8_libbase",
171+
"@abseil-cpp//absl/container:btree",
172+
"@abseil-cpp//absl/container:flat_hash_map",
173+
--
174+
2.50.0.727.gbf7dc18ff4-goog
175+
176+
177+
From e0b8f32cc057a3c0875437d5d54d012cabcab458 Mon Sep 17 00:00:00 2001
178+
From: Matt Leon <[email protected]>
179+
Date: Wed, 16 Jul 2025 20:29:10 -0400
180+
Subject: [PATCH 6/6] Add build flags to make V8 compile with GCC
181+
182+
Signed-off-by: Matt Leon <[email protected]>
183+
---
184+
bazel/defs.bzl | 3 +++
185+
1 file changed, 3 insertions(+)
186+
187+
diff --git a/bazel/defs.bzl b/bazel/defs.bzl
188+
index 14d7ace5e59..c7a48d4e805 100644
189+
--- a/bazel/defs.bzl
190+
+++ b/bazel/defs.bzl
191+
@@ -117,6 +117,9 @@ def _default_args():
192+
"-Wno-implicit-int-float-conversion",
193+
"-Wno-deprecated-copy",
194+
"-Wno-non-virtual-dtor",
195+
+ "-Wno-invalid-offsetof",
196+
+ "-Wno-dangling-pointer",
197+
+ "-Wno-dangling-reference",
198+
"-isystem .",
199+
],
200+
"//conditions:default": [],
201+
--
202+
2.50.0.727.gbf7dc18ff4-goog
203+

bazel/repositories.bzl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,64 @@ def proxy_wasm_cpp_host_repositories():
177177
"@proxy_wasm_cpp_host//bazel/external:v8.patch",
178178
],
179179
patch_args = ["-p1"],
180+
patch_cmds = [
181+
"find ./src ./include -type f -exec sed -i 's!#include \"third_party/simdutf/simdutf.h\"!#include \"simdutf.h\"!' {} \\;",
182+
"find ./src ./include -type f -exec sed -i 's!#include \"third_party/fp16/src/include/fp16.h\"!#include \"fp16.h\"!' {} \\;",
183+
"find ./src ./include -type f -exec sed -i 's!#include \"third_party/dragonbox/src/include/dragonbox/dragonbox.h\"!#include \"dragonbox/dragonbox.h\"!' {} \\;",
184+
"find ./src ./include -type f -exec sed -i 's!#include \"third_party/fast_float/src/include/fast_float/!#include \"fast_float/!' {} \\;",
185+
],
186+
repo_mapping = {
187+
"@abseil-cpp": "@com_google_absl",
188+
},
189+
)
190+
191+
maybe(
192+
http_archive,
193+
name = "highway",
194+
urls = [
195+
"https://github.com/google/highway/archive/refs/tags/1.2.0.tar.gz",
196+
],
197+
strip_prefix = "highway-1.2.0",
198+
)
199+
200+
maybe(
201+
http_archive,
202+
name = "fast_float",
203+
urls = [
204+
"https://github.com/fastfloat/fast_float/archive/refs/tags/v7.0.0.tar.gz",
205+
],
206+
strip_prefix = "fast_float-7.0.0",
207+
)
208+
209+
maybe(
210+
http_archive,
211+
name = "dragonbox",
212+
urls = [
213+
"https://github.com/jk-jeon/dragonbox/archive/6c7c925b571d54486b9ffae8d9d18a822801cbda.zip",
214+
],
215+
strip_prefix = "dragonbox-6c7c925b571d54486b9ffae8d9d18a822801cbda",
216+
sha256 = "2f10448d665355b41f599e869ac78803f82f13b070ce7ef5ae7b5cceb8a178f3",
217+
build_file = "@proxy_wasm_cpp_host//bazel/external:dragonbox.BUILD",
218+
)
219+
220+
maybe(
221+
http_archive,
222+
name = "fp16",
223+
urls = [
224+
"https://github.com/Maratyszcza/FP16/archive/0a92994d729ff76a58f692d3028ca1b64b145d91.zip",
225+
],
226+
strip_prefix = "FP16-0a92994d729ff76a58f692d3028ca1b64b145d91",
227+
sha256 = "e66e65515fa09927b348d3d584c68be4215cfe664100d01c9dbc7655a5716d70",
228+
build_file = "@proxy_wasm_cpp_host//bazel/external:fp16.BUILD",
229+
)
230+
231+
maybe(
232+
http_archive,
233+
name = "simdutf",
234+
urls = [
235+
"https://github.com/simdutf/simdutf/releases/download/v7.3.0/singleheader.zip",
236+
],
237+
build_file = "@proxy_wasm_cpp_host//bazel/external:simdutf.BUILD",
180238
)
181239

182240
native.bind(

0 commit comments

Comments
 (0)