Compare commits

...

1 Commits

Author SHA1 Message Date
Channing Conger
3f3f09e7bc Setup a new v8-poc package
This is a new package that depends on rusty-v8 for embedding a v8
engine.  This builds and works on non-musl platforms now because
rusty-v8 provides versions for that.  But we mocked out the loading of
a musl built library.

TODO: iterate on providing the musl built version for musl-linux builds.
TODO: create a release workflow for publishing the artifact that rusty-v8 can link against
2026-03-17 10:59:25 -07:00
10 changed files with 407 additions and 7 deletions

View File

@@ -132,6 +132,21 @@ crate.annotation(
workspace_cargo_toml = "rust/runfiles/Cargo.toml",
)
crate.annotation(
build_script_data_select = {
"aarch64-unknown-linux-musl": ["//third_party/v8:rusty_v8_archive"],
"x86_64-unknown-linux-musl": ["//third_party/v8:rusty_v8_archive"],
},
build_script_env_select = {
# Replace the placeholder archive with a musl-built librusty_v8 artifact before
# enabling codex-v8-poc's `rusty_v8` feature for musl Cargo or Bazel builds.
"aarch64-unknown-linux-musl": "{\"RUSTY_V8_ARCHIVE\":\"$(execpath //third_party/v8:rusty_v8_archive)\"}",
"x86_64-unknown-linux-musl": "{\"RUSTY_V8_ARCHIVE\":\"$(execpath //third_party/v8:rusty_v8_archive)\"}",
},
crate = "v8",
gen_build_script = "on",
)
llvm = use_extension("@llvm//extensions:llvm.bzl", "llvm")
use_repo(llvm, "llvm-project")

19
MODULE.bazel.lock generated

File diff suppressed because one or more lines are too long

238
codex-rs/Cargo.lock generated
View File

@@ -948,6 +948,8 @@ dependencies = [
"cexpr",
"clang-sys",
"itertools 0.13.0",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
@@ -1151,6 +1153,16 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0"
[[package]]
name = "calendrical_calculations"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a0b39595c6ee54a8d0900204ba4c401d0ab4eb45adaf07178e8d017541529e7"
dependencies = [
"core_maths",
"displaydoc",
]
[[package]]
name = "cassowary"
version = "0.3.0"
@@ -1579,7 +1591,7 @@ dependencies = [
"thiserror 2.0.18",
"tokio",
"url",
"which",
"which 8.0.0",
"wiremock",
"zip",
]
@@ -1924,7 +1936,7 @@ dependencies = [
"url",
"uuid",
"walkdir",
"which",
"which 8.0.0",
"wildmatch",
"windows-sys 0.52.0",
"wiremock",
@@ -2135,7 +2147,7 @@ dependencies = [
"serde_json",
"tokio",
"tracing",
"which",
"which 8.0.0",
"wiremock",
]
@@ -2375,7 +2387,7 @@ dependencies = [
"tracing",
"urlencoding",
"webbrowser",
"which",
"which 8.0.0",
]
[[package]]
@@ -2415,7 +2427,7 @@ dependencies = [
"tree-sitter",
"tree-sitter-bash",
"url",
"which",
"which 8.0.0",
]
[[package]]
@@ -2575,7 +2587,7 @@ dependencies = [
"uuid",
"vt100",
"webbrowser",
"which",
"which 8.0.0",
"windows-sys 0.52.0",
"winsplit",
]
@@ -2665,7 +2677,7 @@ dependencies = [
"uuid",
"vt100",
"webbrowser",
"which",
"which 8.0.0",
"windows-sys 0.52.0",
"winsplit",
]
@@ -2836,6 +2848,14 @@ dependencies = [
"regex-lite",
]
[[package]]
name = "codex-v8-poc"
version = "0.0.0"
dependencies = [
"pretty_assertions",
"v8",
]
[[package]]
name = "codex-windows-sandbox"
version = "0.0.0"
@@ -3041,6 +3061,15 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "core_maths"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30"
dependencies = [
"libm",
]
[[package]]
name = "core_test_support"
version = "0.0.0"
@@ -3638,6 +3667,38 @@ dependencies = [
"subtle",
]
[[package]]
name = "diplomat"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9adb46b05e2f53dcf6a7dfc242e4ce9eb60c369b6b6eb10826a01e93167f59c6"
dependencies = [
"diplomat_core",
"proc-macro2",
"quote",
"syn 2.0.114",
]
[[package]]
name = "diplomat-runtime"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0569bd3caaf13829da7ee4e83dbf9197a0e1ecd72772da6d08f0b4c9285c8d29"
[[package]]
name = "diplomat_core"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51731530ed7f2d4495019abc7df3744f53338e69e2863a6a64ae91821c763df1"
dependencies = [
"proc-macro2",
"quote",
"serde",
"smallvec",
"strck",
"syn 2.0.114",
]
[[package]]
name = "dirs"
version = "6.0.0"
@@ -4244,6 +4305,16 @@ dependencies = [
"libc",
]
[[package]]
name = "fslock"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "futures"
version = "0.3.31"
@@ -4472,6 +4543,15 @@ dependencies = [
"regex-syntax 0.8.8",
]
[[package]]
name = "gzip-header"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95cc527b92e6029a62960ad99aa8a6660faa4555fe5f731aab13aa6a921795a2"
dependencies = [
"crc32fast",
]
[[package]]
name = "h2"
version = "0.4.13"
@@ -4929,6 +5009,28 @@ dependencies = [
"cc",
]
[[package]]
name = "icu_calendar"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f0e52e009b6b16ba9c0693578796f2dd4aaa59a7f8f920423706714a89ac4e"
dependencies = [
"calendrical_calculations",
"displaydoc",
"icu_calendar_data",
"icu_locale",
"icu_locale_core",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_calendar_data"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "527f04223b17edfe0bd43baf14a0cb1b017830db65f3950dc00224860a9a446d"
[[package]]
name = "icu_collections"
version = "2.1.1"
@@ -5363,6 +5465,12 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
[[package]]
name = "ixdtf"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84de9d95a6d2547d9b77ee3f25fa0ee32e3c3a6484d47a55adebc0439c077992"
[[package]]
name = "jiff"
version = "0.2.18"
@@ -7087,6 +7195,16 @@ dependencies = [
"yansi",
]
[[package]]
name = "prettyplease"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn 2.0.114",
]
[[package]]
name = "proc-macro-crate"
version = "3.4.0"
@@ -7919,6 +8037,16 @@ dependencies = [
"webpki-roots 1.0.5",
]
[[package]]
name = "resb"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a067ab3b5ca3b4dc307d0de9cf75f9f5e6ca9717b192b2f28a36c83e5de9e76"
dependencies = [
"potential_utf",
"serde_core",
]
[[package]]
name = "resolv-conf"
version = "0.7.6"
@@ -9299,6 +9427,15 @@ dependencies = [
"serde_json",
]
[[package]]
name = "strck"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42316e70da376f3d113a68d138a60d8a9883c604fe97942721ec2068dab13a9f"
dependencies = [
"unicode-ident",
]
[[package]]
name = "streaming-iterator"
version = "0.1.9"
@@ -9528,6 +9665,39 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "temporal_capi"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a151e402c2bdb6a3a2a2f3f225eddaead2e7ce7dd5d3fa2090deb11b17aa4ed8"
dependencies = [
"diplomat",
"diplomat-runtime",
"icu_calendar",
"icu_locale",
"num-traits",
"temporal_rs",
"timezone_provider",
"writeable",
"zoneinfo64",
]
[[package]]
name = "temporal_rs"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88afde3bd75d2fc68d77a914bece426aa08aa7649ffd0cdd4a11c3d4d33474d1"
dependencies = [
"core_maths",
"icu_calendar",
"icu_locale",
"ixdtf",
"num-traits",
"timezone_provider",
"tinystr",
"writeable",
]
[[package]]
name = "term"
version = "0.7.0"
@@ -9735,6 +9905,18 @@ dependencies = [
"time-core",
]
[[package]]
name = "timezone_provider"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9ba0000e9e73862f3e7ca1ff159e2ddf915c9d8bb11e38a7874760f445d993"
dependencies = [
"tinystr",
"zerotrie",
"zerovec",
"zoneinfo64",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"
@@ -10534,6 +10716,23 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "v8"
version = "142.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f566072bd76b2631d0dca1d90a766c943863b1fd6b01312281dc919816de976d"
dependencies = [
"bindgen",
"bitflags 2.10.0",
"fslock",
"gzip-header",
"home",
"miniz_oxide",
"paste",
"temporal_capi",
"which 6.0.3",
]
[[package]]
name = "valuable"
version = "0.1.1"
@@ -10833,6 +11032,18 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]]
name = "which"
version = "6.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f"
dependencies = [
"either",
"home",
"rustix 0.38.44",
"winsafe",
]
[[package]]
name = "which"
version = "8.0.0"
@@ -11836,6 +12047,19 @@ version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ff05f8caa9038894637571ae6b9e29466c1f4f829d26c9b28f869a29cbe3445"
[[package]]
name = "zoneinfo64"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2e5597efbe7c421da8a7fd396b20b571704e787c21a272eecf35dfe9d386f0"
dependencies = [
"calendrical_calculations",
"icu_locale_core",
"potential_utf",
"resb",
"serde",
]
[[package]]
name = "zopfli"
version = "0.8.3"

View File

@@ -43,6 +43,7 @@ members = [
"otel",
"tui",
"tui_app_server",
"v8-poc",
"utils/absolute-path",
"utils/cargo-bin",
"utils/git",
@@ -131,6 +132,7 @@ codex-stdio-to-uds = { path = "stdio-to-uds" }
codex-test-macros = { path = "test-macros" }
codex-tui = { path = "tui" }
codex-tui-app-server = { path = "tui_app_server" }
codex-v8-poc = { path = "v8-poc" }
codex-utils-absolute-path = { path = "utils/absolute-path" }
codex-utils-approval-presets = { path = "utils/approval-presets" }
codex-utils-cache = { path = "utils/cache" }
@@ -238,6 +240,7 @@ regex-lite = "0.1.8"
reqwest = "0.12"
rmcp = { version = "0.15.0", default-features = false }
runfiles = { git = "https://github.com/dzbarsky/rules_rust", rev = "b56cbaa8465e74127f1ea216f813cd377295ad81" }
v8 = "142.1.0"
rustls = { version = "0.23", default-features = false, features = [
"ring",
"std",

View File

@@ -42,6 +42,13 @@ In some cases, an upstream crate may need a patch or a `crate.annotation` in `..
to have it build in Bazel's sandbox or make it cross-compilation-friendly. If you see issues,
feel free to ping zbarsky or mbolin.
One current example is `rusty_v8`: normal workspace builds should consume a prebuilt archive
through `RUSTY_V8_ARCHIVE` rather than trying to build V8 from source inside every Bazel action.
The placeholder Bazel label lives at `//third_party/v8:rusty_v8_archive`; replace that target's
underlying file with the musl-built archive before enabling the `codex-v8-poc` crate's
`rusty_v8` feature for musl targets in Cargo or Bazel. Non-musl Bazel targets are left to the
crate's default build-script behavior.
When you add a new crate or binary:
1. Add it to the Cargo workspace as usual.

View File

@@ -0,0 +1,12 @@
load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "v8-poc",
crate_name = "codex_v8_poc",
)
codex_rust_crate(
name = "v8-poc-rusty-v8",
crate_features = ["rusty_v8"],
crate_name = "codex_v8_poc",
)

View File

@@ -0,0 +1,22 @@
[package]
name = "codex-v8-poc"
version.workspace = true
edition.workspace = true
license.workspace = true
[lib]
name = "codex_v8_poc"
path = "src/lib.rs"
[features]
default = []
rusty_v8 = ["dep:v8"]
[lints]
workspace = true
[dependencies]
v8 = { workspace = true, optional = true }
[dev-dependencies]
pretty_assertions = { workspace = true }

View File

@@ -0,0 +1,72 @@
//! Bazel-wired proof-of-concept crate reserved for future V8 experiments.
/// Returns the Bazel label for this proof-of-concept crate.
#[must_use]
pub fn bazel_target() -> &'static str {
"//codex-rs/v8-poc:v8-poc"
}
/// Returns the embedded V8 version when the optional `rusty_v8` feature is enabled.
#[cfg(feature = "rusty_v8")]
#[must_use]
pub fn embedded_v8_version() -> &'static str {
v8::V8::get_version()
}
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use super::bazel_target;
#[cfg(feature = "rusty_v8")]
use std::sync::Once;
#[cfg(feature = "rusty_v8")]
fn initialize_v8() {
static INIT: Once = Once::new();
INIT.call_once(|| {
v8::V8::initialize_platform(v8::new_default_platform(0, false).make_shared());
v8::V8::initialize();
});
}
#[cfg(feature = "rusty_v8")]
fn evaluate_expression(expression: &str) -> String {
initialize_v8();
let isolate = &mut v8::Isolate::new(Default::default());
v8::scope!(let scope, isolate);
let context = v8::Context::new(scope, Default::default());
let scope = &mut v8::ContextScope::new(scope, context);
let source = v8::String::new(scope, expression).expect("expression should be valid UTF-8");
let script = v8::Script::compile(scope, source, None).expect("expression should compile");
let result = script.run(scope).expect("expression should evaluate");
result.to_rust_string_lossy(scope)
}
#[test]
fn exposes_expected_bazel_target() {
assert_eq!(bazel_target(), "//codex-rs/v8-poc:v8-poc");
}
#[cfg(feature = "rusty_v8")]
#[test]
fn exposes_embedded_v8_version() {
assert!(!super::embedded_v8_version().is_empty());
}
#[cfg(feature = "rusty_v8")]
#[test]
fn evaluates_integer_addition() {
assert_eq!(evaluate_expression("1 + 2"), "3");
}
#[cfg(feature = "rusty_v8")]
#[test]
fn evaluates_string_concatenation() {
assert_eq!(evaluate_expression("'hello ' + 'world'"), "hello world");
}
}

11
third_party/v8/BUILD.bazel vendored Normal file
View File

@@ -0,0 +1,11 @@
package(default_visibility = ["//visibility:public"])
alias(
name = "rusty_v8_archive",
actual = ":rusty_v8_archive_placeholder",
)
filegroup(
name = "rusty_v8_archive_placeholder",
srcs = ["README.md"],
)

15
third_party/v8/README.md vendored Normal file
View File

@@ -0,0 +1,15 @@
# `rusty_v8` Artifact Placeholder
The Bazel label `//third_party/v8:rusty_v8_archive` currently resolves to this placeholder file.
Replace the filegroup target in `third_party/v8/BUILD.bazel` with the real musl-built
`librusty_v8` archive before enabling the `codex-v8-poc` crate's `rusty_v8` feature for musl
targets.
Expected artifact examples:
- `librusty_v8_release_x86_64-unknown-linux-musl.a`
- `librusty_v8_release_aarch64-unknown-linux-musl.a`
Non-musl Bazel builds intentionally do not receive `RUSTY_V8_ARCHIVE`; they fall back to
`rusty_v8`'s default build-script behavior instead.