Repository navigation
Enable Rust code in V8 for workerd - #7925
Conversation
|
💬 Approved with comments — No correctness or security problems. There is one documentation WARNING about the V8 update guide, two comment-wording SUGGESTIONs, and an INFO noting that the lockfiles and the V8 patch were not checked line by line. Findings: 1 warning · 1 info · 2 suggestions The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔧 Fix with your agentPaste the following into your coding agent to investigate and fix these issues. 📋 Code Quality: 💬 1 info · 2 suggestionsThe change works as intended. Two comment-wording nits from the last review are still open, and some files were not checked line by line. Recommendation: 💬 Optional Nits
View full review
This review did not check 📝 Documentation:
|
44889ff to
2ffd438
Compare
|
Since last review: 0 resolved, 1 still open, 1 new. Temporal build wiring now normalizes generated Bazel content across checkout line endings. Not re-run: api-compat, compat-flags, jsg-gc, kj-style, memory-safety (no author changes in their files since the last review) Reviewed commit: 08d0f09e · github run |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7925 +/- ##
==========================================
- Coverage 69.45% 69.45% -0.01%
==========================================
Files 696 696
Lines 181369 181370 +1
Branches 29176 29176
==========================================
- Hits 125966 125965 -1
Misses 38359 38359
- Partials 17044 17046 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I like option A. I don't like B and C, they seem like way more trouble than they are worth. Right now it doesn't look like V8 patches any of its Rust dependencies it pulls from crates.io. If it ever did in the future, couldn't we just like copy their patches folder into ours? |
813bd05 to
c37dbfc
Compare
V8 ships harmony_temporal enabled by default, so building V8 with V8_TEMPORAL_SUPPORT would add Temporal and Date.prototype.toTemporalInstant to every Worker. Pass --noharmony-temporal before the configured V8 flags, so the API surface is unchanged and v8Flags can still enable Temporal locally. Exposing Temporal needs a compatibility flag and a real clock for Temporal.Now, which jsg currently stubs to return 0. The new test checks that neither global is visible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c37dbfc to
4c3bec9
Compare
Adds temporal_capi 0.2.6 (feature zoneinfo64) and temporal_rs 0.2.6 (no default features, float64_representable_durations), the versions and features in Chromium's chromium_crates_io at the third_party/rust revision V8 15.7.112.5's DEPS pins. They are built from crates.io by the existing crate_universe setup. The crates' new dependencies are locked to Chromium's versions where they fit the existing lockfile (diplomat-runtime 0.15.2, ixdtf 0.6.6). icu_calendar is 2.3.0 rather than Chromium's 2.2.1, which requires icu_collections ~2.2 and would conflict with the 2.3 already locked; no existing crate changes version. A crate annotation exposes the crate's diplomat-generated C++ headers, and //deps/rust:temporal_capi bundles them with the crate and the Rust runtime for V8 to depend on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds a V8 patch that builds Temporal in V8's Bazel build behind --@v8//:v8_enable_temporal_support, linking the temporal_capi target named by --@v8//:v8_temporal_capi. Without ICU, the patch also bakes ICU's tzres/zoneinfo64.res into V8 as GN does; with ICU, which workerd uses, Temporal reads it from ICU's data. .bazelrc turns both on, pointing at //deps/rust:temporal_capi. Temporal stays hidden from Workers through --noharmony-temporal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4c3bec9 to
08d0f09
Compare
In our internal repo, we build all our C++ and Rust code with V8's own toolchain. We also rely on V8's GN build, which is more maintained by them.
In workerd, we prefer to be flexible on what toolchains are used and we use V8's Bazel build. How, then, can we get Rust code, like Temporal, building? It turns out it's not too hard, it's just a bit yucky:
Optional follow-ups:
A. We could lock the versions of the crates V8 depends on to match V8. Might prevent trouble in the future? Trivially easy. See #7926.
B. We could add a new hub in rules_rust and let V8 and workerd have their own crate version pins. Clanker assures me this works but I don't like the sound of this.
C. Use V8's vendored crates even for stuff we could get from crates.io. I asked my clanker to implement this and it produced an unholy mess, so I would need to work on this manually, and I don't have bandwidth right now.
Note: this does not enable Temporal and I did a test to prove it won't lead to any mysterious enablement.
I tagged @fhanau as our build expert, and @logan-gatlin because he's dealt with ICU and Rust recently and might have some insight into our best approach.