Compare commits

...

10 Commits

Author SHA1 Message Date
Channing Conger
131ecf8840 Fix staged runtime archive links 2026-03-14 08:55:18 +00:00
Channing Conger
a8b23627a0 Make sure we download all 2026-03-14 08:39:31 +00:00
Channing Conger
9ef9d5d5f5 Was not including headers 2026-03-14 08:28:24 +00:00
Channing Conger
e268210ea5 Fix rusty_v8 runtime archive staging in CI 2026-03-14 08:15:19 +00:00
Channing Conger
e1ce599001 Address codex review + build failure 2026-03-14 07:56:15 +00:00
Channing Conger
23ede7ee13 Add a v8-poc crate to test musl and non-musl binding 2026-03-14 07:36:23 +00:00
Channing Conger
c91fc32b4a Move to github bundle cache 2026-03-14 07:21:55 +00:00
Channing Conger
70ead086a7 rusty_v8 fixup 2026-03-14 06:57:31 +00:00
Channing Conger
3463b323e1 Working v8 musl build 2026-03-14 06:10:42 +00:00
pakrym-oai
7ec408fa32 Add Bazel musl V8 build workflow 2026-03-13 20:23:20 +00:00
12 changed files with 2245 additions and 0 deletions

641
.github/scripts/rusty_v8_bazel.py vendored Normal file
View File

@@ -0,0 +1,641 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import gzip
import hashlib
import os
import re
import shlex
import shutil
import subprocess
import sys
import tarfile
import tempfile
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
MODULE_BAZEL = ROOT / "MODULE.bazel"
RUNTIME_LIB_FILENAMES = {
"libcxx": "liblibcxx.static.a",
"libcxxabi": "liblibcxxabi.static.a",
"libunwind": "liblibunwind.static.a",
}
RUNTIME_LIB_LABELS = {
"libcxx": "@llvm//runtimes/libcxx:libcxx.static",
"libcxxabi": "@llvm//runtimes/libcxx:libcxxabi.static",
"libunwind": "@llvm//runtimes/libunwind:libunwind.static",
}
VALIDATE_BUNDLE_SUPPORT_LABELS = {
"resource_dir": "@llvm//runtimes:resource_directory",
"crt_objects_dir": "@llvm//runtimes:crt_objects_directory_linux",
"libcxx_library_dir": "@llvm//runtimes/libcxx:libcxx_library_search_directory",
"libunwind_library_dir": "@llvm//runtimes/libunwind:libunwind_library_search_directory",
"musl_library_dir": "@llvm//runtimes/musl:musl_library_search_directory",
"libcxx_headers_dir": "@llvm//runtimes/libcxx:libcxx_headers_include_search_directory",
"libcxxabi_headers_dir": "@llvm//runtimes/libcxx:libcxxabi_headers_include_search_directory",
"musl_headers_dir": "@llvm//runtimes/musl:musl_headers_include_search_directory",
}
COMPILER_RT_BUILTINS_LABEL = "@llvm//runtimes/compiler-rt:clang_rt.builtins.static"
COMPILER_RT_BUILTINS_FILENAME = "libclang_rt.builtins.static.a"
V8_CACHE_KEY_INPUT_PATTERNS = [
".bazelrc",
".bazelversion",
".github/workflows/ci.bazelrc",
".github/scripts/rusty_v8_bazel.py",
"MODULE.bazel",
"MODULE.bazel.lock",
"patches/**",
"third_party/v8/**",
]
def parse_v8_crate_version() -> str:
text = MODULE_BAZEL.read_text()
match = re.search(
r"https://static\.crates\.io/crates/v8/v8-([0-9.]+)\.crate",
text,
)
if match is None:
raise SystemExit("could not determine v8 crate version from MODULE.bazel")
return match.group(1)
def v8_cache_key_inputs() -> list[Path]:
paths: set[Path] = set()
for pattern in V8_CACHE_KEY_INPUT_PATTERNS:
for path in ROOT.glob(pattern):
if path.is_file():
paths.add(path)
if not paths:
raise SystemExit("could not find any inputs for V8 cache key")
return sorted(paths, key=lambda path: path.relative_to(ROOT).as_posix())
def print_cache_key() -> None:
hasher = hashlib.sha256()
for path in v8_cache_key_inputs():
relpath = path.relative_to(ROOT).as_posix()
hasher.update(relpath.encode("utf-8"))
hasher.update(b"\0")
hasher.update(path.read_bytes())
hasher.update(b"\0")
print(hasher.hexdigest())
def bazel_execroot() -> Path:
result = subprocess.run(
["bazel", "info", "execution_root"],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
)
return Path(result.stdout.strip())
def bazel_cache_root() -> Path:
return bazel_execroot().parents[1]
def bazel_output_files(platform: str, labels: list[str]) -> list[Path]:
expression = "set(" + " ".join(labels) + ")"
result = subprocess.run(
[
"bazel",
"cquery",
f"--platforms=@llvm//platforms:{platform}",
"--output=files",
expression,
],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
)
execroot = bazel_execroot()
return [execroot / line.strip() for line in result.stdout.splitlines() if line.strip()]
def first_existing_path(paths: list[Path], description: str) -> Path:
for path in paths:
if path.exists():
return path
raise SystemExit(f"could not find {description}")
def find_single_path(pattern: str, description: str) -> Path:
matches = sorted(bazel_cache_root().glob(pattern))
if not matches:
raise SystemExit(f"could not find {description}")
return matches[-1]
def bazel_output_path(platform: str, label: str, description: str) -> Path:
return first_existing_path(
bazel_output_files(platform, [label]),
description,
)
def toolchain_dir() -> Path:
return find_single_path(
"external/llvm++http_archive+llvm-toolchain-minimal-*",
"llvm toolchain dir",
)
def kernel_headers_dir(target: str) -> Path:
arch = target.split("-", 1)[0]
arch_patterns = {
"x86_64": ["*linux_kernel_headers_x86.*"],
"aarch64": ["*linux_kernel_headers_arm64.*", "*linux_kernel_headers_aarch64.*"],
}.get(arch, [f"*linux_kernel_headers_{arch}.*"])
for pattern in arch_patterns:
matches = sorted((bazel_cache_root() / "external").glob(pattern))
if matches:
return matches[-1] / "include"
raise SystemExit(f"could not find kernel headers dir for {target}")
def static_runtime_libs(platform: str) -> tuple[Path, Path, Path]:
outputs = bazel_output_files(platform, list(RUNTIME_LIB_LABELS.values()))
return (
first_existing_path(
[path for path in outputs if path.name == RUNTIME_LIB_FILENAMES["libcxx"]],
"libcxx static archive",
),
first_existing_path(
[path for path in outputs if path.name == RUNTIME_LIB_FILENAMES["libcxxabi"]],
"libcxxabi static archive",
),
first_existing_path(
[path for path in outputs if path.name == RUNTIME_LIB_FILENAMES["libunwind"]],
"libunwind static archive",
),
)
def compiler_rt_builtins(platform: str) -> Path:
return first_existing_path(
[
path
for path in bazel_output_files(platform, [COMPILER_RT_BUILTINS_LABEL])
if path.name == COMPILER_RT_BUILTINS_FILENAME
],
"compiler-rt builtins static archive",
)
def validate_bundle_support_paths(platform: str) -> dict[str, Path]:
return {
key: bazel_output_path(platform, label, f"{key} output")
for key, label in VALIDATE_BUNDLE_SUPPORT_LABELS.items()
}
def v8_crate_dir() -> Path:
version_suffix = parse_v8_crate_version().replace(".", "_")
path = bazel_cache_root() / "external" / f"+http_archive+v8_crate_{version_suffix}"
return first_existing_path([path], "v8 crate dir")
def cargo_runtime_rustflags_from_libs(
libcxx_static: Path,
libcxxabi_static: Path,
libunwind_static: Path,
compiler_rt_builtins_static: Path | None = None,
) -> str:
flags = [
f"-C link-arg={libcxx_static}",
f"-C link-arg={libcxxabi_static}",
f"-C link-arg={libunwind_static}",
]
if compiler_rt_builtins_static is not None:
flags.append(f"-C link-arg={compiler_rt_builtins_static}")
flags.extend(
[
"-C link-arg=-lc",
"-C link-arg=-lpthread",
"-C link-arg=-ldl",
]
)
return " ".join(flags)
def cargo_runtime_rustflags(platform: str) -> str:
return cargo_runtime_rustflags_from_libs(
*static_runtime_libs(platform),
compiler_rt_builtins(platform),
)
def cargo_target_rustflags_env_var(target: str) -> str:
return f"CARGO_TARGET_{target.upper().replace('-', '_')}_RUSTFLAGS"
def append_flag_string(existing: str | None, extra: str) -> str:
if existing:
return f"{existing} {extra}"
return extra
def staged_cargo_inputs(output_dir: Path, target: str) -> tuple[Path, Path]:
archive = output_dir / f"librusty_v8_release_{target}.a.gz"
binding = output_dir / f"src_binding_release_{target}.rs"
return (
first_existing_path([archive], f"staged V8 archive for {target}"),
first_existing_path([binding], f"staged V8 binding for {target}"),
)
def runtime_output_dir(output_dir: Path) -> Path:
return output_dir / "runtime"
def staged_runtime_libs(output_dir: Path) -> tuple[Path, Path, Path]:
runtime_dir = runtime_output_dir(output_dir)
return (
first_existing_path(
[runtime_dir / RUNTIME_LIB_FILENAMES["libcxx"]],
"staged libcxx static archive",
),
first_existing_path(
[runtime_dir / RUNTIME_LIB_FILENAMES["libcxxabi"]],
"staged libcxxabi static archive",
),
first_existing_path(
[runtime_dir / RUNTIME_LIB_FILENAMES["libunwind"]],
"staged libunwind static archive",
),
)
def staged_compiler_rt_builtins(output_dir: Path) -> Path:
runtime_dir = runtime_output_dir(output_dir)
return first_existing_path(
[runtime_dir / COMPILER_RT_BUILTINS_FILENAME],
"staged compiler-rt builtins static archive",
)
def print_cargo_env(platform: str, target: str, output_dir: Path) -> None:
archive, binding = staged_cargo_inputs(output_dir, target)
target_rustflags_var = cargo_target_rustflags_env_var(target)
runtime_libs = tuple(path.resolve() for path in staged_runtime_libs(output_dir))
cargo_rustflags = cargo_runtime_rustflags_from_libs(
*runtime_libs,
staged_compiler_rt_builtins(output_dir).resolve(),
)
print(f"export RUSTY_V8_ARCHIVE={shlex.quote(str(archive.resolve()))}")
print(f"export RUSTY_V8_SRC_BINDING_PATH={shlex.quote(str(binding.resolve()))}")
print(f"export CODEX_V8_RUSTFLAGS={shlex.quote(cargo_rustflags)}")
print(
f'export {target_rustflags_var}="${{{target_rustflags_var}:+${target_rustflags_var} }}$CODEX_V8_RUSTFLAGS"'
)
def write_cargo_smoke_project(project_dir: Path, crate_dir: Path) -> None:
project_dir.mkdir(parents=True, exist_ok=True)
(project_dir / "src").mkdir(exist_ok=True)
(project_dir / "Cargo.toml").write_text(
f"""[package]
name = "cargo_v8_smoke"
version = "0.1.0"
edition = "2021"
[dependencies]
v8 = {{ path = "{crate_dir.as_posix()}" }}
"""
)
(project_dir / "src/main.rs").write_text(
"""fn main() {
let platform = v8::new_default_platform(0, false).make_shared();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
{
let isolate = &mut v8::Isolate::new(v8::CreateParams::default());
v8::scope!(let handle_scope, isolate);
let context = v8::Context::new(handle_scope, Default::default());
let scope = &mut v8::ContextScope::new(handle_scope, context);
let code = v8::String::new(scope, "1 + 2").unwrap();
let script = v8::Script::compile(scope, code, None).unwrap();
let result = script.run(scope).unwrap();
let value = result.integer_value(scope).unwrap();
assert_eq!(value, 3);
println!("{value}");
}
unsafe {
v8::V8::dispose();
}
v8::V8::dispose_platform();
}
"""
)
def add_regular_file_to_tar(
tar: tarfile.TarFile,
*,
source: Path,
arcname: str,
) -> None:
info = tar.gettarinfo(str(source), arcname=arcname)
info.uid = 0
info.gid = 0
info.uname = ""
info.gname = ""
info.mtime = 0
with source.open("rb") as src:
tar.addfile(info, src)
def write_bundle_archive(
*,
output_path: Path,
target: str,
lib_path: Path,
binding_path: Path,
include_root: Path,
runtime_libs: tuple[Path, Path, Path],
) -> None:
bundle_root = f"rusty_v8_{target}"
with output_path.open("wb") as dst:
with gzip.GzipFile(
filename="",
mode="wb",
fileobj=dst,
compresslevel=9,
mtime=0,
) as gz:
with tarfile.open(
fileobj=gz,
mode="w",
format=tarfile.PAX_FORMAT,
) as tar:
add_regular_file_to_tar(
tar,
source=lib_path,
arcname=f"{bundle_root}/lib/librusty_v8.a",
)
add_regular_file_to_tar(
tar,
source=binding_path,
arcname=f"{bundle_root}/src_binding_release.rs",
)
for runtime_lib in runtime_libs:
add_regular_file_to_tar(
tar,
source=runtime_lib,
arcname=f"{bundle_root}/runtime/{runtime_lib.name}",
)
for header_path in sorted(include_root.rglob("*")):
if not header_path.is_file():
continue
relpath = header_path.relative_to(include_root.parent)
add_regular_file_to_tar(
tar,
source=header_path,
arcname=f"{bundle_root}/{relpath.as_posix()}",
)
def validate_bundle(platform: str, target: str, bundle_path: Path) -> None:
support_paths = validate_bundle_support_paths(platform)
toolchain = toolchain_dir()
kernel_headers = kernel_headers_dir(target)
compiler_rt = bazel_cache_root() / "external/llvm++llvm_source+compiler-rt/include"
with tempfile.TemporaryDirectory(prefix="rusty-v8-bundle-") as tmpdir:
tmpdir_path = Path(tmpdir)
with tarfile.open(bundle_path, "r:gz") as tar:
tar.extractall(tmpdir_path, filter="data")
bundle_root = tmpdir_path / f"rusty_v8_{target}"
libcxx_static, libcxxabi_static, libunwind_static = staged_runtime_libs(bundle_root)
output_binary = tmpdir_path / "non_bazel_v8_smoke_test"
cmd = [
str(toolchain / "bin/clang++"),
"-target",
target,
"--sysroot=/dev/null",
"-static-pie",
"-fuse-ld=lld",
"-rtlib=compiler-rt",
"-nostdlib++",
"--unwindlib=none",
"-resource-dir",
str(support_paths["resource_dir"]),
"-B" + str(support_paths["crt_objects_dir"]),
"-L" + str(support_paths["libcxx_library_dir"]),
"-L" + str(support_paths["libunwind_library_dir"]),
"-L" + str(support_paths["musl_library_dir"]),
"-nostdlibinc",
"-isystem",
str(support_paths["libcxx_headers_dir"]),
"-isystem",
str(support_paths["libcxxabi_headers_dir"]),
"-isystem",
str(kernel_headers),
"-isystem",
str(support_paths["musl_headers_dir"]),
"-isystem",
str(compiler_rt),
"-Xclang",
"-internal-isystem",
"-Xclang",
str(toolchain / "lib/clang/22/include"),
"-std=c++20",
"-I" + str(bundle_root / "include"),
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-Wl,--push-state",
"-Wl,--as-needed",
"-lpthread",
"-ldl",
"-Wl,--pop-state",
str(ROOT / "third_party/v8/smoke_test.cc"),
str(bundle_root / "lib/librusty_v8.a"),
str(libcxx_static),
str(libcxxabi_static),
str(libunwind_static),
"-Wl,-S",
"-Wl,-soname,non_bazel_v8_smoke_test",
"-Wl,--no-as-needed",
"-ldl",
"-pthread",
"-o",
str(output_binary),
]
subprocess.run(cmd, cwd=ROOT, check=True)
subprocess.run([str(output_binary)], cwd=ROOT, check=True)
print(output_binary)
def validate_cargo_bundle(platform: str, target: str, bundle_path: Path) -> None:
crate_dir = v8_crate_dir()
target_rustflags_var = cargo_target_rustflags_env_var(target)
with tempfile.TemporaryDirectory(prefix="rusty-v8-cargo-") as tmpdir:
tmpdir_path = Path(tmpdir)
with tarfile.open(bundle_path, "r:gz") as tar:
tar.extractall(tmpdir_path, filter="data")
bundle_root = tmpdir_path / f"rusty_v8_{target}"
project_dir = tmpdir_path / "cargo_smoke"
write_cargo_smoke_project(project_dir, crate_dir)
env = os.environ.copy()
env["RUSTY_V8_ARCHIVE"] = str(bundle_root / "lib/librusty_v8.a")
env["RUSTY_V8_SRC_BINDING_PATH"] = str(bundle_root / "src_binding_release.rs")
bundle_runtime_rustflags = cargo_runtime_rustflags_from_libs(
*staged_runtime_libs(bundle_root),
staged_compiler_rt_builtins(bundle_root),
)
env[target_rustflags_var] = append_flag_string(
env.get(target_rustflags_var),
bundle_runtime_rustflags,
)
subprocess.run(
["cargo", "run", "--target", target],
cwd=project_dir,
env=env,
check=True,
)
print(project_dir / "target" / target / "debug" / "cargo_v8_smoke")
def stage_release_assets(platform: str, target: str, output_dir: Path) -> None:
target_suffix = target.replace("-", "_")
version_suffix = parse_v8_crate_version().replace(".", "_")
lib_label = f"//third_party/v8:v8_{version_suffix}_{target_suffix}"
binding_label = f"//third_party/v8:src_binding_release_{target_suffix}"
outputs = bazel_output_files(platform, [lib_label, binding_label])
try:
lib_path = next(path for path in outputs if path.suffix == ".a")
except StopIteration as exc:
raise SystemExit(f"missing static archive output for {target}") from exc
try:
binding_path = next(path for path in outputs if path.suffix == ".rs")
except StopIteration as exc:
raise SystemExit(f"missing binding output for {target}") from exc
output_dir.mkdir(parents=True, exist_ok=True)
archive_name = f"librusty_v8_release_{target}.a.gz"
binding_name = f"src_binding_release_{target}.rs"
bundle_name = f"rusty_v8_bundle_{target}.tar.gz"
runtime_dir = runtime_output_dir(output_dir)
runtime_dir.mkdir(exist_ok=True)
with lib_path.open("rb") as src, (output_dir / archive_name).open("wb") as dst:
with gzip.GzipFile(
filename="",
mode="wb",
fileobj=dst,
compresslevel=9,
mtime=0,
) as gz:
shutil.copyfileobj(src, gz)
shutil.copyfile(binding_path, output_dir / binding_name)
staged_runtime_paths = []
for runtime_lib in static_runtime_libs(platform):
staged_runtime_path = runtime_dir / runtime_lib.name
shutil.copyfile(runtime_lib, staged_runtime_path)
staged_runtime_paths.append(staged_runtime_path)
builtins_path = compiler_rt_builtins(platform)
staged_builtins_path = runtime_dir / builtins_path.name
shutil.copyfile(builtins_path, staged_builtins_path)
staged_runtime_paths.append(staged_builtins_path)
write_bundle_archive(
output_path=output_dir / bundle_name,
target=target,
lib_path=lib_path,
binding_path=binding_path,
include_root=bazel_execroot() / "external" / "v8+" / "include",
runtime_libs=tuple(staged_runtime_paths),
)
print(output_dir / archive_name)
print(output_dir / binding_name)
print(output_dir / bundle_name)
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="command", required=True)
subparsers.add_parser("print-version")
subparsers.add_parser("print-cache-key")
stage_parser = subparsers.add_parser("stage")
stage_parser.add_argument("--platform", required=True)
stage_parser.add_argument("--target", required=True)
stage_parser.add_argument("--output-dir", required=True)
validate_parser = subparsers.add_parser("validate-bundle")
validate_parser.add_argument("--platform", required=True)
validate_parser.add_argument("--target", required=True)
validate_parser.add_argument("--bundle-path", required=True)
cargo_validate_parser = subparsers.add_parser("validate-cargo")
cargo_validate_parser.add_argument("--platform", required=True)
cargo_validate_parser.add_argument("--target", required=True)
cargo_validate_parser.add_argument("--bundle-path", required=True)
print_env_parser = subparsers.add_parser("print-cargo-env")
print_env_parser.add_argument("--platform", required=True)
print_env_parser.add_argument("--target", required=True)
print_env_parser.add_argument("--output-dir", required=True)
return parser.parse_args()
def main() -> int:
args = parse_args()
if args.command == "print-version":
print(parse_v8_crate_version())
return 0
if args.command == "print-cache-key":
print_cache_key()
return 0
if args.command == "stage":
stage_release_assets(
platform=args.platform,
target=args.target,
output_dir=Path(args.output_dir),
)
return 0
if args.command == "validate-bundle":
validate_bundle(
platform=args.platform,
target=args.target,
bundle_path=Path(args.bundle_path),
)
return 0
if args.command == "validate-cargo":
validate_cargo_bundle(
platform=args.platform,
target=args.target,
bundle_path=Path(args.bundle_path),
)
return 0
if args.command == "print-cargo-env":
print_cargo_env(
platform=args.platform,
target=args.target,
output_dir=Path(args.output_dir),
)
return 0
raise SystemExit(f"unsupported command: {args.command}")
if __name__ == "__main__":
sys.exit(main())

View File

@@ -0,0 +1,223 @@
name: rusty-v8-bazel-build
on:
pull_request:
paths:
- ".bazelrc"
- ".bazelversion"
- ".github/workflows/ci.bazelrc"
- ".github/workflows/rusty-v8-bazel-build.yml"
- ".github/scripts/rusty_v8_bazel.py"
- "MODULE.bazel"
- "MODULE.bazel.lock"
- "codex-rs/v8-poc/**"
- "patches/**"
- "third_party/v8/**"
- "**/*.bzl"
- "**/BUILD"
- "**/BUILD.bazel"
push:
branches:
- main
paths:
- ".bazelrc"
- ".bazelversion"
- ".github/workflows/ci.bazelrc"
- ".github/workflows/rusty-v8-bazel-build.yml"
- ".github/scripts/rusty_v8_bazel.py"
- "MODULE.bazel"
- "MODULE.bazel.lock"
- "codex-rs/v8-poc/**"
- "patches/**"
- "third_party/v8/**"
- "**/*.bzl"
- "**/BUILD"
- "**/BUILD.bazel"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}::${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
permissions:
contents: read
actions: read
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
platform: linux_amd64_musl
target: x86_64-unknown-linux-musl
- runner: ubuntu-24.04-arm
platform: linux_aarch64_musl
target: aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Bazel
uses: bazelbuild/setup-bazelisk@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@1.93.0
with:
targets: ${{ matrix.target }}
- name: Compute V8 bundle cache key
id: cache_key
shell: bash
run: |
set -euo pipefail
echo "key=rusty-v8-bundle-v2-${{ matrix.target }}-$(python3 .github/scripts/rusty_v8_bazel.py print-cache-key)" >> "$GITHUB_OUTPUT"
- name: Restore staged V8 bundle cache
id: bundle_cache_restore
uses: actions/cache/restore@v5
with:
path: dist/${{ matrix.target }}
key: ${{ steps.cache_key.outputs.key }}
- name: Build Bazel V8 musl artifacts
if: ${{ steps.bundle_cache_restore.outputs.cache-hit != 'true' }}
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
shell: bash
run: |
set -euo pipefail
version="$(python3 .github/scripts/rusty_v8_bazel.py print-version)"
version_suffix="${version//./_}"
target_suffix="${TARGET//-/_}"
lib_target="//third_party/v8:v8_${version_suffix}_${target_suffix}"
binding_target="//third_party/v8:src_binding_release_${target_suffix}"
runtime_targets=(
'@llvm//runtimes/libcxx:libcxx.static'
'@llvm//runtimes/libcxx:libcxxabi.static'
'@llvm//runtimes/libunwind:libunwind.static'
'@llvm//runtimes/compiler-rt:clang_rt.builtins.static'
'@llvm//runtimes:resource_directory'
'@llvm//runtimes:crt_objects_directory_linux'
'@llvm//runtimes/libcxx:libcxx_library_search_directory'
'@llvm//runtimes/libunwind:libunwind_library_search_directory'
'@llvm//runtimes/musl:musl_library_search_directory'
'@llvm//runtimes/libcxx:libcxx_headers_include_search_directory'
'@llvm//runtimes/libcxx:libcxxabi_headers_include_search_directory'
'@llvm//runtimes/musl:musl_headers_include_search_directory'
)
bazel_args=(
build
"--platforms=@llvm//platforms:${PLATFORM}"
--remote_download_toplevel
"${lib_target}"
"${binding_target}"
"${runtime_targets[@]}"
'--remote_download_regex=.*third_party/v8/libv8_.*\.a$'
'--remote_download_regex=.*third_party/v8/src_binding_release_.*\.rs$'
'--remote_download_regex=.*liblibcxx\.static\.a$'
'--remote_download_regex=.*liblibcxxabi\.static\.a$'
'--remote_download_regex=.*liblibunwind\.static\.a$'
'--remote_download_regex=.*libclang_rt\.builtins\.static\.a$'
--build_metadata=REPO_URL=https://github.com/${GITHUB_REPOSITORY}.git
--build_metadata=COMMIT_SHA=$(git rev-parse HEAD)
--build_metadata=ROLE=CI
--build_metadata=VISIBILITY=PUBLIC
)
if [[ -n "${BUILDBUDDY_API_KEY:-}" ]]; then
bazel \
--noexperimental_remote_repo_contents_cache \
--bazelrc=.github/workflows/ci.bazelrc \
"${bazel_args[@]}" \
"--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
else
bazel \
--noexperimental_remote_repo_contents_cache \
"${bazel_args[@]}" \
--remote_cache= \
--remote_executor=
fi
- name: Stage rusty_v8 release assets
if: ${{ steps.bundle_cache_restore.outputs.cache-hit != 'true' }}
env:
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
shell: bash
run: |
set -euo pipefail
output_dir="dist/${TARGET}"
python3 .github/scripts/rusty_v8_bazel.py stage \
--platform "${PLATFORM}" \
--target "${TARGET}" \
--output-dir "${output_dir}"
- name: Validate staged bundle outside Bazel
if: ${{ steps.bundle_cache_restore.outputs.cache-hit != 'true' }}
env:
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
shell: bash
run: |
set -euo pipefail
python3 .github/scripts/rusty_v8_bazel.py validate-bundle \
--platform "${PLATFORM}" \
--target "${TARGET}" \
--bundle-path "dist/${TARGET}/rusty_v8_bundle_${TARGET}.tar.gz"
- name: Validate staged bundle with Cargo
if: ${{ steps.bundle_cache_restore.outputs.cache-hit != 'true' }}
env:
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
shell: bash
run: |
set -euo pipefail
python3 .github/scripts/rusty_v8_bazel.py validate-cargo \
--platform "${PLATFORM}" \
--target "${TARGET}" \
--bundle-path "dist/${TARGET}/rusty_v8_bundle_${TARGET}.tar.gz"
- name: Save staged V8 bundle cache
if: ${{ steps.bundle_cache_restore.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v5
with:
path: dist/${{ matrix.target }}
key: ${{ steps.cache_key.outputs.key }}
- name: Build codex-v8-poc against staged bundle
env:
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
shell: bash
run: |
set -euo pipefail
eval "$(python3 .github/scripts/rusty_v8_bazel.py print-cargo-env \
--platform "${PLATFORM}" \
--target "${TARGET}" \
--output-dir "dist/${TARGET}")"
cargo test \
--manifest-path codex-rs/v8-poc/Cargo.toml \
--locked \
--lib \
--target "${TARGET}"
- name: Upload staged artifacts
uses: actions/upload-artifact@v7
with:
name: rusty-v8-${{ matrix.target }}
path: dist/${{ matrix.target }}/*

View File

@@ -1,5 +1,7 @@
module(name = "codex")
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "llvm", version = "0.6.7")
@@ -174,6 +176,253 @@ crate.annotation(
inject_repo(crate, "alsa_lib")
bazel_dep(name = "v8", version = "14.6.202.11")
archive_override(
module_name = "v8",
integrity = "sha256-Ju45oFJMyCWyT/r+d+MDsCbCeoDBisGaj4+KZYIIYSU=",
patch_cmds = ["""
python3 - <<'PY'
from pathlib import Path
module = Path("MODULE.bazel")
text = module.read_text()
start = text.index("# Define the local LLVM toolchain repository\\n")
end = text.index('libcxx_repository(\\n name = "libcxx",\\n)\\n') + len('libcxx_repository(\\n name = "libcxx",\\n)\\n')
text = text[:start] + text[end:]
fast_float_build = '''load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "fast_float",
hdrs = glob(["include/fast_float/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
'''
simdutf_build = '''load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "simdutf",
srcs = ["simdutf.cpp"],
hdrs = ["simdutf.h"],
copts = ["-std=c++20"],
includes = ["."],
visibility = ["//visibility:public"],
)
'''
dragonbox_build = '''load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "dragonbox",
hdrs = ["include/dragonbox/dragonbox.h"],
includes = ["include"],
visibility = ["//visibility:public"],
)
'''
fp16_build = '''load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "fp16",
hdrs = glob(["include/**/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
'''
highway_patch_cmd = '''python3 - <<'PY'
from pathlib import Path
build = Path("BUILD")
text = build.read_text()
text = text.replace(
'load("@rules_cc//cc:defs.bzl", "cc_test")',
'load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")',
)
build.write_text(text)
PY'''
module_insertion = f'''bazel_dep(name = "rules_license", version = "0.0.4")
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "highway",
patch_cmds = [{highway_patch_cmd!r}],
sha256 = "7e0be78b8318e8bdbf6fa545d2ecb4c90f947df03f7aadc42c1967f019e63343",
strip_prefix = "highway-1.2.0",
urls = ["https://github.com/google/highway/archive/refs/tags/1.2.0.tar.gz"],
)
git_repository(
name = "icu",
build_file = "@v8//:bazel/BUILD.icu",
commit = "a86a32e67b8d1384b33f8fa48c83a6079b86f8cd",
patch_cmds = ["find source -name BUILD.bazel | xargs rm"],
patch_cmds_win = ["Get-ChildItem -Path source -File -Include BUILD.bazel -Recurse | Remove-Item"],
remote = "https://chromium.googlesource.com/chromium/deps/icu.git",
)
http_archive(
name = "fast_float",
build_file_content = {fast_float_build!r},
sha256 = "e14a33089712b681d74d94e2a11362643bd7d769ae8f7e7caefe955f57f7eacd",
strip_prefix = "fast_float-8.0.2",
urls = ["https://github.com/fastfloat/fast_float/archive/refs/tags/v8.0.2.tar.gz"],
)
git_repository(
name = "simdutf",
build_file_content = {simdutf_build!r},
commit = "93b35aec29256f705c97f675fe4623578bd7a395",
remote = "https://chromium.googlesource.com/chromium/src/third_party/simdutf",
)
git_repository(
name = "dragonbox",
build_file_content = {dragonbox_build!r},
commit = "beeeef91cf6fef89a4d4ba5e95d47ca64ccb3a44",
remote = "https://chromium.googlesource.com/external/github.com/jk-jeon/dragonbox.git",
)
git_repository(
name = "fp16",
build_file_content = {fp16_build!r},
commit = "3d2de1816307bac63c16a297e8c4dc501b4076df",
remote = "https://chromium.googlesource.com/external/github.com/Maratyszcza/FP16.git",
)
'''
text = text.replace('bazel_dep(name = "highway", version = "1.2.0")\\n', module_insertion)
module.write_text(text)
defs = Path("bazel/defs.bzl")
text = defs.read_text()
text = text.replace(' deps = [":define_flags", "@libcxx//:libc++"],\\n', ' deps = [":define_flags"],\\n')
text = text.replace(
' "//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"],\\n',
' "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],\\n',
)
defs.write_text(text)
build = Path("BUILD.bazel")
text = build.read_text()
text = text.replace(' default = "none",\\n', ' default = "False",\\n', 1)
text = text.replace("//external:icu", "@icu//:icu")
text = text.replace("//third_party/fast_float/src:fast_float", "@fast_float//:fast_float")
text = text.replace(
'alias(\\n name = "core_lib_icu",\\n actual = "icu/v8",\\n)\\n',
'alias(\\n name = "core_lib_icu",\\n actual = "icu/v8",\\n visibility = ["//visibility:public"],\\n)\\n',
)
text = text.replace(
' srcs = [\\n "include/js_protocol.pdl",\\n "src/inspector/inspector_protocol_config.json",\\n ],\\n',
' srcs = [\\n "include/js_protocol.pdl",\\n "src/inspector/inspector_protocol_config.json",\\n "third_party/inspector_protocol/code_generator.py",\\n "third_party/inspector_protocol/pdl.py",\\n "third_party/inspector_protocol/lib/Forward_h.template",\\n "third_party/inspector_protocol/lib/Object_cpp.template",\\n "third_party/inspector_protocol/lib/Object_h.template",\\n "third_party/inspector_protocol/lib/Protocol_cpp.template",\\n "third_party/inspector_protocol/lib/ValueConversions_cpp.template",\\n "third_party/inspector_protocol/lib/ValueConversions_h.template",\\n "third_party/inspector_protocol/lib/Values_cpp.template",\\n "third_party/inspector_protocol/lib/Values_h.template",\\n "third_party/inspector_protocol/templates/Exported_h.template",\\n "third_party/inspector_protocol/templates/Imported_h.template",\\n "third_party/inspector_protocol/templates/TypeBuilder_cpp.template",\\n "third_party/inspector_protocol/templates/TypeBuilder_h.template",\\n ],\\n',
1,
)
text = text.replace(
' cmd = "$(location :code_generator) --jinja_dir . \\\\\\n --inspector_protocol_dir third_party/inspector_protocol \\\\\\n --config $(location :src/inspector/inspector_protocol_config.json) \\\\\\n --config_value protocol.path=$(location :include/js_protocol.pdl) \\\\\\n --output_base $(@D)/src/inspector",\\n',
' cmd = "INSPECTOR_PROTOCOL_DIR=$$(dirname $(execpath third_party/inspector_protocol/code_generator.py)); \\\\\\n PYTHONPATH=$$INSPECTOR_PROTOCOL_DIR:external/rules_python++pip+v8_python_deps_311_jinja2/site-packages:external/rules_python++pip+v8_python_deps_311_markupsafe/site-packages:$${PYTHONPATH-} \\\\\\n python3 $(execpath third_party/inspector_protocol/code_generator.py) --jinja_dir . \\\\\\n --inspector_protocol_dir $$INSPECTOR_PROTOCOL_DIR \\\\\\n --config $(location :src/inspector/inspector_protocol_config.json) \\\\\\n --config_value protocol.path=$(location :include/js_protocol.pdl) \\\\\\n --output_base $(@D)/src/inspector",\\n',
1,
)
text = text.replace(
' tools = [\\n ":code_generator",\\n ],\\n',
' tools = [\\n requirement("jinja2"),\\n requirement("markupsafe"),\\n ],\\n',
1,
)
text = text.replace(
'cc_library(\\n name = "simdutf",\\n srcs = ["third_party/simdutf/simdutf.cpp"],\\n hdrs = ["third_party/simdutf/simdutf.h"],\\n copts = select({\\n "@v8//bazel/config:is_clang": ["-std=c++20"],\\n "@v8//bazel/config:is_gcc": ["-std=gnu++2a"],\\n "@v8//bazel/config:is_windows": ["/std:c++20"],\\n "//conditions:default": [],\\n }),\\n)\\n',
'alias(\\n name = "simdutf",\\n actual = "@simdutf//:simdutf",\\n)\\n',
1,
)
text = text.replace(
'v8_library(\\n name = "lib_dragonbox",\\n srcs = ["third_party/dragonbox/src/include/dragonbox/dragonbox.h"],\\n hdrs = [\\n "third_party/dragonbox/src/include/dragonbox/dragonbox.h",\\n ],\\n includes = [\\n "third_party/dragonbox/src/include",\\n ],\\n)\\n',
'alias(\\n name = "lib_dragonbox",\\n actual = "@dragonbox//:dragonbox",\\n)\\n',
1,
)
text = text.replace(
'v8_library(\\n name = "lib_fp16",\\n srcs = ["third_party/fp16/src/include/fp16.h"],\\n hdrs = [\\n "third_party/fp16/src/include/fp16/fp16.h",\\n "third_party/fp16/src/include/fp16/bitcasts.h",\\n "third_party/fp16/src/include/fp16/macros.h",\\n ],\\n includes = [\\n "third_party/fp16/src/include",\\n ],\\n)\\n',
'alias(\\n name = "lib_fp16",\\n actual = "@fp16//:fp16",\\n)\\n',
1,
)
needle = 'filegroup(\\n name = "d8_files",\\n'
insert = 'cc_library(\\n name = "rusty_v8_internal_headers",\\n hdrs = [\\n "src/libplatform/default-platform.h",\\n ],\\n strip_include_prefix = "",\\n visibility = ["//visibility:public"],\\n)\\n\\n'
if needle not in text:
raise SystemExit("could not find d8_files insertion point")
build.write_text(text.replace(needle, insert + needle, 1))
stack_trace = Path("src/base/debug/stack_trace_posix.cc")
text = stack_trace.read_text()
text = text.replace(
'bool dump_stack_in_signal_handler = true;\\n\\n// The prefix used for mangled symbols, per the Itanium C++ ABI:\\n// http://www.codesourcery.com/cxx-abi/abi.html#mangling\\nconst char kMangledSymbolPrefix[] = "_Z";\\n\\n// Characters that can be used for symbols, generated by Ruby:\\n// ((\\'a\\'..\\'z\\').to_a+(\\'A\\'..\\'Z\\').to_a+(\\'0\\'..\\'9\\').to_a + [\\'_\\']).join\\nconst char kSymbolCharacters[] =\\n "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";\\n\\n#if HAVE_EXECINFO_H\\n',
'bool dump_stack_in_signal_handler = true;\\n\\n#if HAVE_EXECINFO_H\\n// The prefix used for mangled symbols, per the Itanium C++ ABI:\\n// http://www.codesourcery.com/cxx-abi/abi.html#mangling\\nconst char kMangledSymbolPrefix[] = "_Z";\\n\\n// Characters that can be used for symbols, generated by Ruby:\\n// ((\\'a\\'..\\'z\\').to_a+(\\'A\\'..\\'Z\\').to_a+(\\'0\\'..\\'9\\').to_a + [\\'_\\']).join\\nconst char kSymbolCharacters[] =\\n "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";\\n\\n',
1,
)
stack_trace.write_text(text)
platform_posix = Path("src/base/platform/platform-posix.cc")
text = platform_posix.read_text()
text = text.replace(
'#if defined(V8_LIBC_GLIBC)\\nextern "C" void* __libc_stack_end;\\n#endif\\n',
'',
1,
)
text = text.replace(
'#if defined(V8_LIBC_GLIBC)\\n // pthread_getattr_np can fail for the main thread.\\n // For the main thread we prefer using __libc_stack_end (if it exists) since\\n // it generally provides a tighter limit for CSS.\\n return __libc_stack_end;\\n#else\\n return nullptr;\\n#endif // !defined(V8_LIBC_GLIBC)\\n',
' return nullptr;\\n',
1,
)
text = text.replace(
'#if defined(V8_LIBC_GLIBC)\\n // __libc_stack_end is process global and thus is only valid for\\n // the main thread. Check whether this is the main thread by checking\\n // __libc_stack_end is within the thread\\'s stack.\\n if ((base <= __libc_stack_end) && (__libc_stack_end <= stack_start)) {\\n DCHECK(MainThreadIsCurrentThread());\\n return __libc_stack_end;\\n }\\n#endif // !defined(V8_LIBC_GLIBC)\\n',
'',
1,
)
platform_posix.write_text(text)
thread_isolated_allocator = Path("src/libplatform/default-thread-isolated-allocator.cc")
text = thread_isolated_allocator.read_text()
text = text.replace(
"bool KernelHasPkruFix() {\\n",
"[[maybe_unused]] bool KernelHasPkruFix() {\\n",
1,
)
thread_isolated_allocator.write_text(text)
for path in Path("src").rglob("*"):
if not path.is_file():
continue
text = path.read_text()
text = text.replace('"third_party/fp16/src/include/fp16.h"', '"fp16.h"')
text = text.replace('"third_party/simdutf/simdutf.h"', '"simdutf.h"')
text = text.replace(
'"third_party/fast_float/src/include/fast_float/fast_float.h"',
'"fast_float/fast_float.h"',
)
text = text.replace(
'"third_party/fast_float/src/include/fast_float/float_common.h"',
'"fast_float/float_common.h"',
)
text = text.replace(
'"third_party/dragonbox/src/include/dragonbox/dragonbox.h"',
'"dragonbox/dragonbox.h"',
)
path.write_text(text)
icu_build = Path("bazel/BUILD.icu")
text = icu_build.read_text()
if 'load("@rules_cc//cc:defs.bzl", "cc_library")\\n\\n' not in text:
text = 'load("@rules_cc//cc:defs.bzl", "cc_library")\\n\\n' + text
icu_build.write_text(text)
PY
"""],
strip_prefix = "v8-14.6.202.11",
urls = ["https://github.com/v8/v8/archive/refs/tags/14.6.202.11.tar.gz"],
)
http_archive(
name = "v8_crate_146_4_0",
build_file = "//third_party/v8:v8_crate.BUILD.bazel",
sha256 = "d97bcac5cdc5a195a4813f1855a6bc658f240452aac36caa12fd6c6f16026ab1",
strip_prefix = "v8-146.4.0",
type = "tar.gz",
urls = ["https://static.crates.io/crates/v8/v8-146.4.0.crate"],
)
use_repo(crate, "crates")
bazel_dep(name = "libcap", version = "2.27.bcr.1")

5
MODULE.bazel.lock generated
View File

@@ -12,6 +12,7 @@
"https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16",
"https://bcr.bazel.build/modules/abseil-cpp/20250127.1/MODULE.bazel": "c4a89e7ceb9bf1e25cf84a9f830ff6b817b72874088bf5141b314726e46a57c1",
"https://bcr.bazel.build/modules/abseil-cpp/20250512.1/MODULE.bazel": "d209fdb6f36ffaf61c509fcc81b19e81b411a999a934a032e10cd009a0226215",
"https://bcr.bazel.build/modules/abseil-cpp/20250814.0/MODULE.bazel": "c43c16ca2c432566cdb78913964497259903ebe8fb7d9b57b38e9f1425b427b8",
"https://bcr.bazel.build/modules/abseil-cpp/20250814.1/MODULE.bazel": "51f2312901470cdab0dbdf3b88c40cd21c62a7ed58a3de45b365ddc5b11bcab2",
"https://bcr.bazel.build/modules/abseil-cpp/20250814.1/source.json": "cea3901d7e299da7320700abbaafe57a65d039f10d0d7ea601c4a66938ea4b0c",
"https://bcr.bazel.build/modules/alsa_lib/1.2.9.bcr.4/MODULE.bazel": "66842efc2b50b7c12274a5218d468119a5d6f9dc46a5164d9496fb517f64aba6",
@@ -104,6 +105,7 @@
"https://bcr.bazel.build/modules/platforms/1.0.0/source.json": "f4ff1fd412e0246fd38c82328eb209130ead81d62dcd5a9e40910f867f733d96",
"https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7",
"https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c",
"https://bcr.bazel.build/modules/protobuf/27.1/MODULE.bazel": "703a7b614728bb06647f965264967a8ef1c39e09e8f167b3ca0bb1fd80449c0d",
"https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df",
"https://bcr.bazel.build/modules/protobuf/29.0-rc3/MODULE.bazel": "33c2dfa286578573afc55a7acaea3cada4122b9631007c594bf0729f41c8de92",
"https://bcr.bazel.build/modules/protobuf/29.1/MODULE.bazel": "557c3457560ff49e122ed76c0bc3397a64af9574691cb8201b4e46d4ab2ecb95",
@@ -167,6 +169,7 @@
"https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3",
"https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5",
"https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0",
"https://bcr.bazel.build/modules/rules_license/0.0.4/MODULE.bazel": "6a88dd22800cf1f9f79ba32cacad0d3a423ed28efa2c2ed5582eaa78dd3ac1e5",
"https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d",
"https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c",
"https://bcr.bazel.build/modules/rules_license/1.0.0/source.json": "a52c89e54cc311196e478f8382df91c15f7a2bfdf4c6cd0e2675cc2ff0b56efb",
@@ -181,6 +184,7 @@
"https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7",
"https://bcr.bazel.build/modules/rules_proto/6.0.0-rc1/MODULE.bazel": "1e5b502e2e1a9e825eef74476a5a1ee524a92297085015a052510b09a1a09483",
"https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73",
"https://bcr.bazel.build/modules/rules_proto/7.0.2/MODULE.bazel": "bf81793bd6d2ad89a37a40693e56c61b0ee30f7a7fdbaf3eabbf5f39de47dea2",
"https://bcr.bazel.build/modules/rules_proto/7.1.0/MODULE.bazel": "002d62d9108f75bb807cd56245d45648f38275cb3a99dcd45dfb864c5d74cb96",
"https://bcr.bazel.build/modules/rules_proto/7.1.0/source.json": "39f89066c12c24097854e8f57ab8558929f9c8d474d34b2c00ac04630ad8940e",
"https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f",
@@ -190,6 +194,7 @@
"https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58",
"https://bcr.bazel.build/modules/rules_python/0.33.2/MODULE.bazel": "3e036c4ad8d804a4dad897d333d8dce200d943df4827cb849840055be8d2e937",
"https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c",
"https://bcr.bazel.build/modules/rules_python/1.0.0/MODULE.bazel": "898a3d999c22caa585eb062b600f88654bf92efb204fa346fb55f6f8edffca43",
"https://bcr.bazel.build/modules/rules_python/1.3.0/MODULE.bazel": "8361d57eafb67c09b75bf4bbe6be360e1b8f4f18118ab48037f2bd50aa2ccb13",
"https://bcr.bazel.build/modules/rules_python/1.4.1/MODULE.bazel": "8991ad45bdc25018301d6b7e1d3626afc3c8af8aaf4bc04f23d0b99c938b73a6",
"https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8",

1
codex-rs/v8-poc/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target/

870
codex-rs/v8-poc/Cargo.lock generated Normal file
View File

@@ -0,0 +1,870 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aho-corasick"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
dependencies = [
"memchr",
]
[[package]]
name = "autocfg"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]]
name = "bindgen"
version = "0.72.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"itertools",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn",
]
[[package]]
name = "bitflags"
version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
[[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 = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "clang-sys"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "codex-v8-poc"
version = "0.0.0"
dependencies = [
"v8",
]
[[package]]
name = "core_maths"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30"
dependencies = [
"libm",
]
[[package]]
name = "crc32fast"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
dependencies = [
"cfg-if",
]
[[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",
]
[[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",
]
[[package]]
name = "displaydoc"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "errno"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]]
name = "fslock"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "glob"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
[[package]]
name = "gzip-header"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95cc527b92e6029a62960ad99aa8a6660faa4555fe5f731aab13aa6a921795a2"
dependencies = [
"crc32fast",
]
[[package]]
name = "home"
version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
dependencies = [
"windows-sys 0.61.2",
]
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43"
dependencies = [
"displaydoc",
"potential_utf",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_locale"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "532b11722e350ab6bf916ba6eb0efe3ee54b932666afec989465f9243fe6dd60"
dependencies = [
"icu_collections",
"icu_locale_core",
"icu_locale_data",
"icu_provider",
"potential_utf",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_locale_core"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6"
dependencies = [
"displaydoc",
"litemap",
"serde",
"tinystr",
"writeable",
"zerovec",
]
[[package]]
name = "icu_locale_data"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c5f1d16b4c3a2642d3a719f18f6b06070ab0aef246a6418130c955ae08aa831"
[[package]]
name = "icu_provider"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614"
dependencies = [
"displaydoc",
"icu_locale_core",
"serde",
"stable_deref_trait",
"writeable",
"yoke",
"zerofrom",
"zerotrie",
"zerovec",
]
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]]
name = "ixdtf"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84de9d95a6d2547d9b77ee3f25fa0ee32e3c3a6484d47a55adebc0439c077992"
[[package]]
name = "libc"
version = "0.2.183"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
[[package]]
name = "libloading"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
dependencies = [
"cfg-if",
"windows-link",
]
[[package]]
name = "libm"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "litemap"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77"
[[package]]
name = "log"
version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "memchr"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "potential_utf"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77"
dependencies = [
"serde_core",
"writeable",
"zerovec",
]
[[package]]
name = "prettyplease"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn",
]
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
[[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 = "rustc-hash"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "rustix"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.59.0",
]
[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "smallvec"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "stable_deref_trait"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "strck"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42316e70da376f3d113a68d138a60d8a9883c604fe97942721ec2068dab13a9f"
dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "synstructure"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[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 = "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 = "tinystr"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869"
dependencies = [
"displaydoc",
"serde_core",
"zerovec",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "v8"
version = "146.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97bcac5cdc5a195a4813f1855a6bc658f240452aac36caa12fd6c6f16026ab1"
dependencies = [
"bindgen",
"bitflags",
"fslock",
"gzip-header",
"home",
"miniz_oxide",
"paste",
"temporal_capi",
"which",
]
[[package]]
name = "which"
version = "6.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f"
dependencies = [
"either",
"home",
"rustix",
"winsafe",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winsafe"
version = "0.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
[[package]]
name = "writeable"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
[[package]]
name = "yoke"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954"
dependencies = [
"stable_deref_trait",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "zerofrom"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "zerotrie"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851"
dependencies = [
"displaydoc",
]
[[package]]
name = "zerovec"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002"
dependencies = [
"serde",
"yoke",
"zerofrom",
"zerovec-derive",
]
[[package]]
name = "zerovec-derive"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[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",
]

View File

@@ -0,0 +1,18 @@
[package]
name = "codex-v8-poc"
version = "0.0.0"
edition = "2024"
license = "Apache-2.0"
publish = false
[workspace]
resolver = "2"
[lib]
doctest = false
name = "codex_v8_poc"
path = "src/lib.rs"
[dependencies]
# Keep this in sync with the v8 crate pinned in MODULE.bazel.
v8 = "=146.4.0"

View File

@@ -0,0 +1,45 @@
use std::sync::Once;
static V8_INIT: Once = Once::new();
fn init_v8() {
V8_INIT.call_once(|| {
let platform = v8::new_default_platform(0, false).make_shared();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
});
}
pub fn evaluate_integer_expression(source: &str) -> Result<i64, String> {
init_v8();
let isolate = &mut v8::Isolate::new(v8::CreateParams::default());
v8::scope!(let handle_scope, isolate);
let context = v8::Context::new(handle_scope, Default::default());
let scope = &mut v8::ContextScope::new(handle_scope, context);
let code = v8::String::new(scope, source)
.ok_or_else(|| "failed to allocate JavaScript source".to_string())?;
let script = v8::Script::compile(scope, code, None)
.ok_or_else(|| "failed to compile JavaScript source".to_string())?;
let result = script
.run(scope)
.ok_or_else(|| "failed to execute JavaScript source".to_string())?;
result
.integer_value(scope)
.ok_or_else(|| "JavaScript expression did not evaluate to an integer".to_string())
}
pub fn smoke_value() -> Result<i64, String> {
evaluate_integer_expression("1 + 2")
}
#[cfg(test)]
mod tests {
use super::smoke_value;
#[test]
fn evaluates_smoke_expression() {
assert_eq!(smoke_value().unwrap(), 3);
}
}

View File

@@ -0,0 +1,5 @@
exports_files([
"aws-lc-sys_memcmp_check.patch",
"toolchains_llvm_bootstrapped_resource_dir.patch",
"windows-link.patch",
])

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

@@ -0,0 +1,124 @@
load("@rules_cc//cc:cc_static_library.bzl", "cc_static_library")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library")
package(default_visibility = ["//visibility:public"])
genrule(
name = "binding_cc",
srcs = ["@v8_crate_146_4_0//:binding_cc"],
outs = ["binding.cc"],
cmd = """
sed \
-e '/#include "v8\\/src\\/flags\\/flags.h"/d' \
-e 's|"v8/src/libplatform/default-platform.h"|"src/libplatform/default-platform.h"|' \
-e 's| namespace i = v8::internal;| (void)usage;|' \
-e '/using HelpOptions = i::FlagList::HelpOptions;/d' \
-e '/HelpOptions help_options = HelpOptions(HelpOptions::kExit, usage);/d' \
-e 's| i::FlagList::SetFlagsFromCommandLine(argc, argv, true, help_options);| v8::V8::SetFlagsFromCommandLine(argc, argv, true);|' \
$(location @v8_crate_146_4_0//:binding_cc) > "$@"
""",
)
genrule(
name = "support_h",
srcs = ["@v8_crate_146_4_0//:support_h"],
outs = ["support.h"],
cmd = "cp $(location @v8_crate_146_4_0//:support_h) $@",
)
cc_library(
name = "v8_146_4_0_binding",
srcs = [":binding_cc"],
hdrs = [":support_h"],
copts = select({
"@v8//bazel/config:is_clang": ["-std=c++20"],
"@v8//bazel/config:is_gcc": ["-std=gnu++2a"],
"@v8//bazel/config:is_windows": ["/std:c++20"],
"//conditions:default": [],
}),
deps = [
"@v8//:core_lib_icu",
"@v8//:rusty_v8_internal_headers",
],
)
cc_library(
name = "v8_146_4_0_public_headers",
hdrs = ["@v8//:public_header_files"],
includes = ["../../external/v8+/include"],
deps = ["@v8//:rusty_v8_internal_headers"],
)
cc_binary(
name = "v8_146_4_0_smoke_test",
srcs = ["smoke_test.cc"],
copts = select({
"@v8//bazel/config:is_clang": ["-std=c++20"],
"@v8//bazel/config:is_gcc": ["-std=gnu++2a"],
"@v8//bazel/config:is_windows": ["/std:c++20"],
"//conditions:default": [],
}),
tags = ["manual"],
deps = [":v8_146_4_0_binding"],
)
cc_import(
name = "v8_146_4_0_x86_64_unknown_linux_musl_archive",
static_library = ":v8_146_4_0_x86_64_unknown_linux_musl",
)
cc_library(
name = "v8_146_4_0_x86_64_unknown_linux_musl_imported",
linkopts = [
"-Wl,--no-as-needed",
"-ldl",
"-pthread",
],
deps = [
":v8_146_4_0_x86_64_unknown_linux_musl_archive",
":v8_146_4_0_public_headers",
],
)
cc_binary(
name = "v8_146_4_0_x86_64_unknown_linux_musl_imported_smoke_test",
srcs = ["smoke_test.cc"],
copts = select({
"@v8//bazel/config:is_clang": ["-std=c++20"],
"@v8//bazel/config:is_gcc": ["-std=gnu++2a"],
"@v8//bazel/config:is_windows": ["/std:c++20"],
"//conditions:default": [],
}),
tags = ["manual"],
deps = [":v8_146_4_0_x86_64_unknown_linux_musl_imported"],
)
cc_static_library(
name = "v8_146_4_0_aarch64_apple_darwin",
deps = [":v8_146_4_0_binding"],
)
cc_static_library(
name = "v8_146_4_0_aarch64_unknown_linux_musl",
deps = [":v8_146_4_0_binding"],
)
cc_static_library(
name = "v8_146_4_0_x86_64_unknown_linux_musl",
deps = [":v8_146_4_0_binding"],
)
filegroup(
name = "src_binding_release_aarch64_apple_darwin",
srcs = ["@v8_crate_146_4_0//:src_binding_release_aarch64_apple_darwin"],
)
filegroup(
name = "src_binding_release_aarch64_unknown_linux_musl",
srcs = ["@v8_crate_146_4_0//:src_binding_release_aarch64_unknown_linux_gnu"],
)
filegroup(
name = "src_binding_release_x86_64_unknown_linux_musl",
srcs = ["@v8_crate_146_4_0//:src_binding_release_x86_64_unknown_linux_gnu"],
)

38
third_party/v8/smoke_test.cc vendored Normal file
View File

@@ -0,0 +1,38 @@
#include <memory>
#include "libplatform/libplatform.h"
#include "v8.h"
int main(int argc, char* argv[]) {
v8::V8::InitializeICUDefaultLocation(argv[0]);
v8::V8::InitializeExternalStartupData(argv[0]);
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
int exit_code = 1;
{
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source =
v8::String::NewFromUtf8Literal(isolate, "1 + 2");
v8::Local<v8::Script> script =
v8::Script::Compile(context, source).ToLocalChecked();
v8::Local<v8::Value> result = script->Run(context).ToLocalChecked();
exit_code = result->Int32Value(context).FromMaybe(-1) == 3 ? 0 : 1;
}
isolate->Dispose();
v8::V8::Dispose();
v8::V8::DisposePlatform();
delete create_params.array_buffer_allocator;
return exit_code;
}

26
third_party/v8/v8_crate.BUILD.bazel vendored Normal file
View File

@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
filegroup(
name = "binding_cc",
srcs = ["src/binding.cc"],
)
filegroup(
name = "support_h",
srcs = ["src/support.h"],
)
filegroup(
name = "src_binding_release_aarch64_apple_darwin",
srcs = ["gen/src_binding_release_aarch64-apple-darwin.rs"],
)
filegroup(
name = "src_binding_release_aarch64_unknown_linux_gnu",
srcs = ["gen/src_binding_release_aarch64-unknown-linux-gnu.rs"],
)
filegroup(
name = "src_binding_release_x86_64_unknown_linux_gnu",
srcs = ["gen/src_binding_release_x86_64-unknown-linux-gnu.rs"],
)