Skip to content

Commit 1d5c469

Browse files
committed
add rust backed node buffer implementation
1 parent b4fc0eb commit 1d5c469

26 files changed

Lines changed: 1800 additions & 13 deletions

File tree

deps/rust/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ crates_vendor(
6565
"lol_html_c_api_include_lol_html_h": "include/lol_html.h",
6666
},
6767
)],
68+
# simdutf compiles C++ via the cc crate; workerd uses libc++ not libstdc++.
69+
# build_script_toolchains provides Bazel's C++ toolchain to the cc crate
70+
# so it uses the same clang/libc++ as workerd. CXXSTDLIB tells cc to link libc++.
71+
"simdutf": [crate.annotation(
72+
build_script_env = {
73+
"CXXSTDLIB": "c++",
74+
},
75+
build_script_toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
76+
)],
6877
},
6978
cargo_bazel = CARGO_BAZEL,
7079
cargo_lockfile = "//deps/rust:Cargo.lock",

deps/rust/Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/rust/cargo.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ PACKAGES = WORKERD_CXX_PACKAGES | {
2828
"ruff_python_parser": crate.spec(git = "https://github.com/astral-sh/ruff", tag = "0.12.1"),
2929
# param_extractor depends on unbounded_depth feature
3030
"serde_json": crate.spec(version = "1", features = ["unbounded_depth"]),
31+
"simdutf": crate.spec(version = "0"),
3132
"serde": crate.spec(version = "1", features = ["derive"]),
3233
"thiserror": crate.spec(version = "2"),
3334
# tokio is huge, let's enable only features when we actually need them.

deps/rust/crates/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ alias(
337337
tags = ["manual"],
338338
)
339339

340+
alias(
341+
name = "simdutf-0.7.0",
342+
actual = "@crates_vendor__simdutf-0.7.0//:simdutf",
343+
tags = ["manual"],
344+
)
345+
346+
alias(
347+
name = "simdutf",
348+
actual = "@crates_vendor__simdutf-0.7.0//:simdutf",
349+
tags = ["manual"],
350+
)
351+
340352
alias(
341353
name = "static_assertions-1.1.0",
342354
actual = "@crates_vendor__static_assertions-1.1.0//:static_assertions",
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
###############################################################################
2+
# @generated
3+
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
4+
# regenerate this file, run the following:
5+
#
6+
# bazel run @@//deps/rust:crates_vendor
7+
###############################################################################
8+
#
9+
# MANUALLY PATCHED: The simdutf Rust crate normally compiles its own copy of
10+
# the simdutf C++ library via a build script. Since workerd already vendors
11+
# simdutf as @simdutf//:simdutf (which exports the simdutf_* extern "C"
12+
# functions that the Rust crate expects), we skip the build script entirely
13+
# and link directly against workerd's copy.
14+
15+
load("@rules_rust//rust:defs.bzl", "rust_library")
16+
17+
package(default_visibility = ["//visibility:public"])
18+
19+
rust_library(
20+
name = "simdutf",
21+
srcs = glob(
22+
include = ["**/*.rs"],
23+
allow_empty = True,
24+
),
25+
compile_data = glob(
26+
include = ["**"],
27+
allow_empty = True,
28+
exclude = [
29+
"**/* *",
30+
".tmp_git_root/**/*",
31+
"BUILD",
32+
"BUILD.bazel",
33+
"WORKSPACE",
34+
"WORKSPACE.bazel",
35+
],
36+
),
37+
crate_root = "src/lib.rs",
38+
edition = "2021",
39+
rustc_flags = [
40+
"--cap-lints=allow",
41+
],
42+
tags = [
43+
"cargo-bazel",
44+
"crate-name=simdutf",
45+
"manual",
46+
"noclippy",
47+
"norustfmt",
48+
],
49+
version = "0.7.0",
50+
deps = [
51+
"@crates_vendor__bitflags-2.11.0//:bitflags",
52+
"@simdutf",
53+
],
54+
)

deps/rust/crates/defs.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ _NORMAL_DEPENDENCIES = {
319319
"scratch": Label("@crates_vendor//:scratch-1.0.9"),
320320
"serde": Label("@crates_vendor//:serde-1.0.228"),
321321
"serde_json": Label("@crates_vendor//:serde_json-1.0.149"),
322+
"simdutf": Label("@crates_vendor//:simdutf-0.7.0"),
322323
"static_assertions": Label("@crates_vendor//:static_assertions-1.1.0"),
323324
"swc_common": Label("@crates_vendor//:swc_common-18.0.1"),
324325
"swc_ts_fast_strip": Label("@crates_vendor//:swc_ts_fast_strip-43.0.0"),
@@ -2059,6 +2060,16 @@ def crate_repositories():
20592060
build_file = Label("//deps/rust/crates:BUILD.simd-adler32-0.3.8.bazel"),
20602061
)
20612062

2063+
maybe(
2064+
http_archive,
2065+
name = "crates_vendor__simdutf-0.7.0",
2066+
sha256 = "5f542752c7335a9174e7bb81112c3ca1415a7a6b6ec2c3e840aca347a30f9141",
2067+
type = "tar.gz",
2068+
urls = ["https://static.crates.io/crates/simdutf/0.7.0/download"],
2069+
strip_prefix = "simdutf-0.7.0",
2070+
build_file = Label("//deps/rust/crates:BUILD.simdutf-0.7.0.bazel"),
2071+
)
2072+
20622073
maybe(
20632074
http_archive,
20642075
name = "crates_vendor__siphasher-0.3.11",
@@ -2855,6 +2866,7 @@ def crate_repositories():
28552866
struct(repo = "crates_vendor__scratch-1.0.9", is_dev_dep = False),
28562867
struct(repo = "crates_vendor__serde-1.0.228", is_dev_dep = False),
28572868
struct(repo = "crates_vendor__serde_json-1.0.149", is_dev_dep = False),
2869+
struct(repo = "crates_vendor__simdutf-0.7.0", is_dev_dep = False),
28582870
struct(repo = "crates_vendor__static_assertions-1.1.0", is_dev_dep = False),
28592871
struct(repo = "crates_vendor__swc_common-18.0.1", is_dev_dep = False),
28602872
struct(repo = "crates_vendor__swc_ts_fast_strip-43.0.0", is_dev_dep = False),

src/rust/api/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ wd_rust_crate(
1111
visibility = ["//visibility:public"],
1212
deps = [
1313
"//src/rust/jsg",
14+
"//src/rust/nbytes",
15+
"@crates_vendor//:simdutf",
1416
"@crates_vendor//:thiserror",
1517
],
1618
)

0 commit comments

Comments
 (0)