mirror of
https://github.com/openai/codex.git
synced 2026-10-29 19:08:43 +00:00
Generate Rust bindings that match Bazel-built V8 archives (#57644)
## Why Pre-generated bindings can disagree with native V8 layouts, including CppGC member storage and the inline typed-array size. Source archives need bindings generated with the same headers, defines, and target configuration. ## What changed - Generate bindings through Bazel using the archive's C++ compilation metadata, and include them in Darwin and Linux release pairs and source builds. - Select native Windows MSVC archives and matching bindings together with `--//:rusty_v8_from_source=true`, and generate target-specific Windows GNU bindings. - Pin a corrected `rusty_v8` revision for Cargo and Bazel, and track native Windows LLVM tools and resources as action inputs so pin changes invalidate cached actions. - Run release and canary Cargo smoke tests with explicit target triples, required Linux linkers, and `--include-ignored`. ## Testing Add `codex-v8-poc` coverage for CppGC member size, alignment, tracing, and weak references; typed-array contents and backing-store promotion; and microtask queues across garbage collection and context reassignment. Enable the otherwise ignored CppGC ABI checks for Bazel source builds and staged release smoke tests. GitOrigin-RevId: 9edfa057a0ef2e323543bb8132c070d336ded1b2
This commit is contained in:
@@ -50,7 +50,7 @@ class RustyV8BazelTest(unittest.TestCase):
|
||||
"x86_64_unknown_linux_musl",
|
||||
]:
|
||||
self.assertIn(
|
||||
f":src_binding_release_{selector}_{version_suffix}_release",
|
||||
f":src_binding_{selector}_{version_suffix}_bazel",
|
||||
build_bazel,
|
||||
)
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ CANARY_PATH_PATTERNS = {
|
||||
"MODULE.bazel",
|
||||
"MODULE.bazel.lock",
|
||||
"codex-rs/Cargo.toml",
|
||||
"codex-rs/v8-poc/**",
|
||||
"patches/BUILD.bazel",
|
||||
"patches/llvm_*.patch",
|
||||
"patches/rules_cc_*.patch",
|
||||
|
||||
@@ -95,13 +95,13 @@ jobs:
|
||||
sandbox: true
|
||||
target: aarch64-unknown-linux-gnu
|
||||
variant: ptrcomp-sandbox
|
||||
- runner: macos-15-xlarge
|
||||
- runner: macos-15-intel
|
||||
bazel_config: ci-macos
|
||||
platform: macos_amd64
|
||||
sandbox: false
|
||||
target: x86_64-apple-darwin
|
||||
variant: release
|
||||
- runner: macos-15-xlarge
|
||||
- runner: macos-15-intel
|
||||
bazel_config: ci-macos
|
||||
platform: macos_amd64
|
||||
sandbox: true
|
||||
@@ -164,6 +164,7 @@ jobs:
|
||||
uses: dtolnay/rust-toolchain@e081816240890017053eacbb1bdf337761dc5582 # 1.95.0
|
||||
with:
|
||||
toolchain: "1.95.0"
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Build Bazel V8 release pair
|
||||
env:
|
||||
@@ -220,6 +221,26 @@ jobs:
|
||||
|
||||
python3 .github/scripts/rusty_v8_bazel.py stage-release-pair "${stage_args[@]}"
|
||||
|
||||
# Larger Linux runner images may omit the host linker used by Cargo build scripts.
|
||||
- name: Install native Linux Cargo smoke dependencies
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
packages=(build-essential)
|
||||
if [[ "${TARGET}" == *-musl ]]; then
|
||||
packages+=(musl-tools)
|
||||
fi
|
||||
sudo apt-get update -y
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "${packages[@]}"
|
||||
if [[ "${TARGET}" == *-musl ]]; then
|
||||
# Use musl only for target links; Cargo build scripts still link on the glibc host.
|
||||
linker_var="CARGO_TARGET_${TARGET^^}_LINKER"
|
||||
echo "${linker_var//-/_}=$(command -v musl-gcc)" >> "${GITHUB_ENV}"
|
||||
fi
|
||||
|
||||
- name: Smoke test staged artifact with Cargo
|
||||
env:
|
||||
SANDBOX: ${{ matrix.sandbox }}
|
||||
@@ -228,16 +249,6 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
host_arch="$(uname -m)"
|
||||
case "${TARGET}:${host_arch}" in
|
||||
x86_64-apple-darwin:x86_64|aarch64-apple-darwin:arm64|x86_64-unknown-linux-gnu:x86_64|aarch64-unknown-linux-gnu:aarch64)
|
||||
;;
|
||||
*)
|
||||
echo "Skipping non-native Cargo smoke for ${TARGET} on ${host_arch}."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
archive="$(find "dist/${TARGET}" -maxdepth 1 -type f -name 'librusty_v8_*.a.gz' -print -quit)"
|
||||
binding="$(find "dist/${TARGET}" -maxdepth 1 -type f -name 'src_binding_*.rs' -print -quit)"
|
||||
if [[ -z "${archive}" || -z "${binding}" ]]; then
|
||||
@@ -245,10 +256,11 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo_args=(test -p codex-v8-poc)
|
||||
cargo_args=(test -p codex-v8-poc --target "${TARGET}")
|
||||
if [[ "${SANDBOX}" == "true" ]]; then
|
||||
cargo_args+=(--features sandbox)
|
||||
fi
|
||||
cargo_args+=(-- --include-ignored)
|
||||
|
||||
(
|
||||
cd codex-rs
|
||||
|
||||
@@ -109,13 +109,13 @@ jobs:
|
||||
sandbox: true
|
||||
target: aarch64-unknown-linux-gnu
|
||||
variant: ptrcomp-sandbox
|
||||
- runner: macos-15-xlarge
|
||||
- runner: macos-15-intel
|
||||
bazel_config: ci-macos
|
||||
platform: macos_amd64
|
||||
sandbox: false
|
||||
target: x86_64-apple-darwin
|
||||
variant: release
|
||||
- runner: macos-15-xlarge
|
||||
- runner: macos-15-intel
|
||||
bazel_config: ci-macos
|
||||
platform: macos_amd64
|
||||
sandbox: true
|
||||
@@ -177,6 +177,7 @@ jobs:
|
||||
uses: dtolnay/rust-toolchain@e081816240890017053eacbb1bdf337761dc5582 # 1.95.0
|
||||
with:
|
||||
toolchain: "1.95.0"
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Build Bazel V8 release pair
|
||||
env:
|
||||
@@ -230,6 +231,26 @@ jobs:
|
||||
|
||||
python3 .github/scripts/rusty_v8_bazel.py stage-release-pair "${stage_args[@]}"
|
||||
|
||||
# Larger Linux runner images may omit the host linker used by Cargo build scripts.
|
||||
- name: Install native Linux Cargo smoke dependencies
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
packages=(build-essential)
|
||||
if [[ "${TARGET}" == *-musl ]]; then
|
||||
packages+=(musl-tools)
|
||||
fi
|
||||
sudo apt-get update -y
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "${packages[@]}"
|
||||
if [[ "${TARGET}" == *-musl ]]; then
|
||||
# Use musl only for target links; Cargo build scripts still link on the glibc host.
|
||||
linker_var="CARGO_TARGET_${TARGET^^}_LINKER"
|
||||
echo "${linker_var//-/_}=$(command -v musl-gcc)" >> "${GITHUB_ENV}"
|
||||
fi
|
||||
|
||||
- name: Smoke test staged artifact with Cargo
|
||||
env:
|
||||
SANDBOX: ${{ matrix.sandbox }}
|
||||
@@ -238,16 +259,6 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
host_arch="$(uname -m)"
|
||||
case "${TARGET}:${host_arch}" in
|
||||
x86_64-apple-darwin:x86_64|aarch64-apple-darwin:arm64|x86_64-unknown-linux-gnu:x86_64|aarch64-unknown-linux-gnu:aarch64)
|
||||
;;
|
||||
*)
|
||||
echo "Skipping non-native Cargo smoke for ${TARGET} on ${host_arch}."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
archive="$(find "dist/${TARGET}" -maxdepth 1 -type f -name 'librusty_v8_*.a.gz' -print -quit)"
|
||||
binding="$(find "dist/${TARGET}" -maxdepth 1 -type f -name 'src_binding_*.rs' -print -quit)"
|
||||
if [[ -z "${archive}" || -z "${binding}" ]]; then
|
||||
@@ -255,10 +266,11 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo_args=(test -p codex-v8-poc)
|
||||
cargo_args=(test -p codex-v8-poc --target "${TARGET}")
|
||||
if [[ "${SANDBOX}" == "true" ]]; then
|
||||
cargo_args+=(--features sandbox)
|
||||
fi
|
||||
cargo_args+=(-- --include-ignored)
|
||||
|
||||
(
|
||||
cd codex-rs
|
||||
|
||||
+3
-3
@@ -879,10 +879,10 @@ use_repo(
|
||||
http_archive(
|
||||
name = "v8_crate_152_2_0",
|
||||
build_file = "//third_party/v8:v8_crate.BUILD.bazel",
|
||||
sha256 = "a10fe1a92da5c32c7c7f838ce36c0ccfcfd5edf0865b58bdde820aa64cea9888",
|
||||
strip_prefix = "v8-152.2.0",
|
||||
sha256 = "e2e7f9961af59dbb749a60ac0a3c34c9680f6b86dd04277f2715356b5a52feab",
|
||||
strip_prefix = "rusty_v8-350c5a859a9b3c84ab8701b3ad51e3b7699b30c0",
|
||||
type = "tar.gz",
|
||||
urls = ["https://static.crates.io/crates/v8/v8-152.2.0.crate"],
|
||||
urls = ["https://github.com/seanh-oai/rusty_v8/archive/350c5a859a9b3c84ab8701b3ad51e3b7699b30c0.tar.gz"],
|
||||
)
|
||||
|
||||
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
|
||||
Generated
+1
-1
@@ -1394,6 +1394,7 @@
|
||||
"git+https://github.com/openai-oss-forks/tokio-tungstenite?rev=0e5b2d73aa18dd9f0a50ee9ff199d5aef7594186#0e5b2d73aa18dd9f0a50ee9ff199d5aef7594186_tokio-tungstenite": "{\"dependencies\":[{\"default_features\":false,\"features\":[\"sink\",\"std\"],\"name\":\"futures-util\",\"optional\":false,\"req\":\"0.3.28\"},{\"name\":\"log\",\"req\":\"0.4.17\"},{\"default_features\":true,\"features\":[],\"name\":\"native-tls-crate\",\"optional\":true,\"package\":\"native-tls\",\"req\":\"0.2.11\"},{\"default_features\":false,\"features\":[],\"name\":\"rustls\",\"optional\":true,\"req\":\"0.23.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-native-certs\",\"optional\":true,\"req\":\"0.8.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-pki-types\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":false,\"features\":[\"io-util\"],\"name\":\"tokio\",\"optional\":false,\"req\":\"1.0.0\"},{\"default_features\":true,\"features\":[],\"name\":\"tokio-native-tls\",\"optional\":true,\"req\":\"0.3.1\"},{\"default_features\":false,\"features\":[],\"name\":\"tokio-rustls\",\"optional\":true,\"req\":\"0.26.0\"},{\"default_features\":false,\"features\":[],\"name\":\"tungstenite\",\"optional\":false},{\"default_features\":true,\"features\":[],\"name\":\"webpki-roots\",\"optional\":true,\"req\":\"0.26.0\"}],\"features\":{\"__rustls-tls\":[\"rustls\",\"rustls-pki-types\",\"tokio-rustls\",\"stream\",\"tungstenite/__rustls-tls\",\"handshake\"],\"connect\":[\"stream\",\"tokio/net\",\"tokio/time\",\"handshake\"],\"default\":[\"connect\",\"handshake\"],\"handshake\":[\"tungstenite/handshake\"],\"native-tls\":[\"native-tls-crate\",\"tokio-native-tls\",\"stream\",\"tungstenite/native-tls\",\"handshake\"],\"native-tls-vendored\":[\"native-tls\",\"native-tls-crate/vendored\",\"tungstenite/native-tls-vendored\"],\"proxy\":[\"tungstenite/proxy\",\"tokio/net\",\"handshake\"],\"rustls-tls-native-roots\":[\"__rustls-tls\",\"rustls-native-certs\"],\"rustls-tls-webpki-roots\":[\"__rustls-tls\",\"webpki-roots\"],\"stream\":[],\"url\":[\"tungstenite/url\"]},\"strip_prefix\":\"\"}",
|
||||
"git+https://github.com/openai-oss-forks/tungstenite-rs?rev=4fffad30fe373adbdcffab9545e9e9bf4f2fc19f#4fffad30fe373adbdcffab9545e9e9bf4f2fc19f_tungstenite": "{\"dependencies\":[{\"name\":\"bytes\",\"req\":\"1.9.0\"},{\"default_features\":true,\"features\":[],\"name\":\"data-encoding\",\"optional\":true,\"req\":\"2\"},{\"default_features\":false,\"features\":[\"zlib-rs\"],\"name\":\"flate2\",\"optional\":true,\"req\":\"1.1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"headers\",\"optional\":true,\"req\":\"0.4.0\"},{\"default_features\":true,\"features\":[],\"name\":\"http\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"httparse\",\"optional\":true,\"req\":\"1.3.4\"},{\"name\":\"log\",\"req\":\"0.4.8\"},{\"default_features\":true,\"features\":[],\"name\":\"native-tls-crate\",\"optional\":true,\"package\":\"native-tls\",\"req\":\"0.2.3\"},{\"name\":\"rand\",\"req\":\"0.9.0\"},{\"default_features\":false,\"features\":[\"std\"],\"name\":\"rustls\",\"optional\":true,\"req\":\"0.23.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-native-certs\",\"optional\":true,\"req\":\"0.8.0\"},{\"default_features\":true,\"features\":[],\"name\":\"rustls-pki-types\",\"optional\":true,\"req\":\"1.0\"},{\"default_features\":true,\"features\":[],\"name\":\"sha1\",\"optional\":true,\"req\":\"0.10\"},{\"name\":\"thiserror\",\"req\":\"2.0.7\"},{\"default_features\":true,\"features\":[],\"name\":\"url\",\"optional\":true,\"req\":\"2.1.0\"},{\"name\":\"utf-8\",\"req\":\"0.7.5\"},{\"default_features\":true,\"features\":[],\"name\":\"webpki-roots\",\"optional\":true,\"req\":\"0.26\"}],\"features\":{\"__rustls-tls\":[\"rustls\",\"rustls-pki-types\"],\"default\":[\"handshake\"],\"deflate\":[\"headers\",\"flate2\"],\"handshake\":[\"data-encoding\",\"headers\",\"httparse\",\"sha1\"],\"headers\":[\"http\",\"dep:headers\"],\"native-tls\":[\"native-tls-crate\"],\"native-tls-vendored\":[\"native-tls\",\"native-tls-crate/vendored\"],\"proxy\":[\"handshake\"],\"rustls-tls-native-roots\":[\"__rustls-tls\",\"rustls-native-certs\"],\"rustls-tls-webpki-roots\":[\"__rustls-tls\",\"webpki-roots\"],\"url\":[\"dep:url\"]},\"strip_prefix\":\"\"}",
|
||||
"git+https://github.com/rust-lang/rust-clippy?rev=21baba9c10c5d179915cae82e6247bc2337872fb#21baba9c10c5d179915cae82e6247bc2337872fb_clippy_utils": "{\"dependencies\":[{\"default_features\":false,\"features\":[],\"name\":\"arrayvec\",\"optional\":false,\"req\":\"0.7\"},{\"name\":\"itertools\",\"req\":\"0.15\"},{\"name\":\"rustc_apfloat\",\"req\":\"0.2.0\"}],\"features\":{},\"strip_prefix\":\"clippy_utils\"}",
|
||||
"git+https://github.com/seanh-oai/rusty_v8.git?rev=350c5a859a9b3c84ab8701b3ad51e3b7699b30c0#350c5a859a9b3c84ab8701b3ad51e3b7699b30c0_v8": "{\"dependencies\":[{\"name\":\"bitflags\",\"req\":\"2.5\"},{\"name\":\"paste\",\"req\":\"1.0\"},{\"default_features\":true,\"features\":[\"zoneinfo64\"],\"name\":\"temporal_capi\",\"optional\":false,\"req\":\"0.2.3\"},{\"kind\":\"build\",\"name\":\"bindgen\",\"req\":\"0.72\"},{\"kind\":\"build\",\"name\":\"fslock\",\"req\":\"0.2\"},{\"kind\":\"build\",\"name\":\"gzip-header\",\"req\":\"1.0.0\"},{\"kind\":\"build\",\"name\":\"home\",\"req\":\"0\"},{\"kind\":\"build\",\"name\":\"miniz_oxide\",\"req\":\"0.8.8\"},{\"kind\":\"build\",\"name\":\"which\",\"req\":\"6\"}],\"features\":{\"default\":[\"use_custom_libcxx\"],\"simdutf\":[],\"use_custom_libcxx\":[],\"v8_enable_pointer_compression\":[],\"v8_enable_sandbox\":[\"v8_enable_pointer_compression\"],\"v8_enable_v8_checks\":[]},\"strip_prefix\":\"\"}",
|
||||
"git2_0.21.0": "{\"dependencies\":[{\"name\":\"bitflags\",\"req\":\"^2.1.0\"},{\"features\":[\"derive\"],\"kind\":\"dev\",\"name\":\"clap\",\"req\":\"^4.4.13\"},{\"name\":\"libc\",\"req\":\"^0.2\"},{\"name\":\"libgit2-sys\",\"req\":\"^0.18.4\"},{\"name\":\"log\",\"req\":\"^0.4.8\"},{\"name\":\"openssl-probe\",\"optional\":true,\"req\":\"^0.1\",\"target\":\"cfg(all(unix, not(target_os = \\\"macos\\\")))\"},{\"name\":\"openssl-sys\",\"optional\":true,\"req\":\"^0.9.45\",\"target\":\"cfg(all(unix, not(target_os = \\\"macos\\\")))\"},{\"kind\":\"dev\",\"name\":\"tempfile\",\"req\":\"^3.1.0\"},{\"features\":[\"formatting\"],\"kind\":\"dev\",\"name\":\"time\",\"req\":\"^0.3.47\"},{\"name\":\"url\",\"optional\":true,\"req\":\"^2.5.4\"},{\"kind\":\"dev\",\"name\":\"url\",\"req\":\"^2.5.4\"}],\"features\":{\"cred\":[\"dep:url\"],\"default\":[],\"https\":[\"libgit2-sys/https\",\"openssl-sys\",\"openssl-probe\",\"cred\"],\"ssh\":[\"libgit2-sys/ssh\",\"cred\"],\"unstable\":[],\"unstable-sha256\":[\"libgit2-sys/unstable-sha256\"],\"vendored-libgit2\":[\"libgit2-sys/vendored\"],\"vendored-openssl\":[\"openssl-sys/vendored\",\"libgit2-sys/vendored-openssl\"],\"zlib-ng-compat\":[\"libgit2-sys/zlib-ng-compat\"]}}",
|
||||
"gix-actor_0.44.0": "{\"dependencies\":[{\"default_features\":false,\"features\":[\"std\",\"unicode\"],\"name\":\"bstr\",\"req\":\"^1.12.0\"},{\"name\":\"document-features\",\"optional\":true,\"req\":\"^0.2.0\"},{\"name\":\"gix-date\",\"req\":\"^0.18.0\"},{\"features\":[\"bstr\"],\"name\":\"gix-error\",\"req\":\"^0.5.0\"},{\"kind\":\"dev\",\"name\":\"insta\",\"req\":\"^1.46.3\"},{\"kind\":\"dev\",\"name\":\"pretty_assertions\",\"req\":\"^1.0.0\"},{\"default_features\":false,\"features\":[\"derive\"],\"name\":\"serde\",\"optional\":true,\"req\":\"^1.0.114\"}],\"features\":{\"serde\":[\"dep:serde\",\"bstr/serde\",\"gix-date/serde\"]}}",
|
||||
"gix-attributes_0.37.0": "{\"dependencies\":[{\"default_features\":false,\"features\":[\"std\",\"unicode\"],\"name\":\"bstr\",\"req\":\"^1.12.0\"},{\"kind\":\"dev\",\"name\":\"criterion\",\"req\":\"^0.8.2\"},{\"name\":\"document-features\",\"optional\":true,\"req\":\"^0.2.1\"},{\"features\":[\"bstr\"],\"name\":\"gix-error\",\"req\":\"^0.5.0\"},{\"name\":\"gix-glob\",\"req\":\"^0.29.0\"},{\"name\":\"gix-parallel\",\"req\":\"^0.50.0\"},{\"name\":\"gix-path\",\"req\":\"^0.14.0\"},{\"name\":\"gix-quote\",\"req\":\"^0.10.0\"},{\"name\":\"gix-trace\",\"req\":\"^0.3.0\"},{\"kind\":\"dev\",\"name\":\"insta\",\"req\":\"^1.46.3\"},{\"default_features\":false,\"features\":[\"derive\"],\"name\":\"serde\",\"optional\":true,\"req\":\"^1.0.114\"},{\"name\":\"smallvec\",\"req\":\"^1.15.1\"},{\"name\":\"unicode-bom\",\"req\":\"^2.0.3\"}],\"features\":{\"serde\":[\"dep:serde\",\"bstr/serde\",\"gix-glob/serde\"]}}",
|
||||
@@ -2230,7 +2231,6 @@
|
||||
"utf8_iter_1.0.4": "{\"dependencies\":[],\"features\":{}}",
|
||||
"utf8parse_0.2.2": "{\"dependencies\":[],\"features\":{\"default\":[],\"nightly\":[]}}",
|
||||
"uuid_1.20.0": "{\"dependencies\":[{\"name\":\"arbitrary\",\"optional\":true,\"req\":\"^1.1.3\"},{\"default_features\":false,\"name\":\"atomic\",\"optional\":true,\"req\":\"^0.6\"},{\"default_features\":false,\"name\":\"borsh\",\"optional\":true,\"req\":\"^1\"},{\"default_features\":false,\"name\":\"borsh-derive\",\"optional\":true,\"req\":\"^1\"},{\"features\":[\"derive\"],\"name\":\"bytemuck\",\"optional\":true,\"req\":\"^1.20.0\"},{\"name\":\"getrandom\",\"optional\":true,\"req\":\"^0.3\",\"target\":\"cfg(not(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\"))))\"},{\"default_features\":false,\"name\":\"js-sys\",\"optional\":true,\"req\":\"^0.3\",\"target\":\"cfg(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\"), target_feature = \\\"atomics\\\"))\"},{\"default_features\":false,\"name\":\"md-5\",\"optional\":true,\"req\":\"^0.10\"},{\"name\":\"rand\",\"optional\":true,\"req\":\"^0.9\",\"target\":\"cfg(not(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\"))))\"},{\"kind\":\"dev\",\"name\":\"rustversion\",\"req\":\"^1\"},{\"kind\":\"dev\",\"name\":\"serde\",\"req\":\"^1.0.221\"},{\"default_features\":false,\"name\":\"serde_core\",\"optional\":true,\"req\":\"^1.0.221\"},{\"kind\":\"dev\",\"name\":\"serde_derive\",\"req\":\"^1.0.221\"},{\"kind\":\"dev\",\"name\":\"serde_json\",\"req\":\"^1.0\"},{\"kind\":\"dev\",\"name\":\"serde_test\",\"req\":\"^1.0.56\"},{\"default_features\":false,\"name\":\"sha1_smol\",\"optional\":true,\"req\":\"^1\"},{\"name\":\"slog\",\"optional\":true,\"req\":\"^2\"},{\"kind\":\"dev\",\"name\":\"trybuild\",\"req\":\"^1.0.52\"},{\"name\":\"uuid-rng-internal-lib\",\"optional\":true,\"package\":\"uuid-rng-internal\",\"req\":\"^1.20.0\",\"target\":\"cfg(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\")))\"},{\"default_features\":false,\"features\":[\"msrv\"],\"name\":\"wasm-bindgen\",\"optional\":true,\"req\":\"^0.2\",\"target\":\"cfg(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\")))\"},{\"kind\":\"dev\",\"name\":\"wasm-bindgen\",\"req\":\"^0.2\",\"target\":\"cfg(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\")))\"},{\"kind\":\"dev\",\"name\":\"wasm-bindgen-test\",\"req\":\"^0.3\",\"target\":\"cfg(all(target_arch = \\\"wasm32\\\", any(target_os = \\\"unknown\\\", target_os = \\\"none\\\")))\"},{\"features\":[\"derive\"],\"name\":\"zerocopy\",\"optional\":true,\"req\":\"^0.8\"}],\"features\":{\"atomic\":[\"dep:atomic\"],\"borsh\":[\"dep:borsh\",\"dep:borsh-derive\"],\"default\":[\"std\"],\"fast-rng\":[\"rng\",\"dep:rand\"],\"js\":[\"dep:wasm-bindgen\",\"dep:js-sys\"],\"macro-diagnostics\":[],\"md5\":[\"dep:md-5\"],\"rng\":[\"dep:getrandom\"],\"rng-getrandom\":[\"rng\",\"dep:getrandom\",\"uuid-rng-internal-lib\",\"uuid-rng-internal-lib/getrandom\"],\"rng-rand\":[\"rng\",\"dep:rand\",\"uuid-rng-internal-lib\",\"uuid-rng-internal-lib/rand\"],\"serde\":[\"dep:serde_core\"],\"sha1\":[\"dep:sha1_smol\"],\"std\":[\"wasm-bindgen?/std\",\"js-sys?/std\"],\"v1\":[\"atomic\"],\"v3\":[\"md5\"],\"v4\":[\"rng\"],\"v5\":[\"sha1\"],\"v6\":[\"atomic\"],\"v7\":[\"rng\"],\"v8\":[]}}",
|
||||
"v8_152.2.0": "{\"dependencies\":[{\"kind\":\"dev\",\"name\":\"align-data\",\"req\":\"^0.1.0\"},{\"kind\":\"build\",\"name\":\"bindgen\",\"req\":\"^0.72\"},{\"kind\":\"dev\",\"name\":\"bindgen\",\"req\":\"^0.72\"},{\"name\":\"bitflags\",\"req\":\"^2.5\"},{\"kind\":\"dev\",\"name\":\"bytes\",\"req\":\"^1\"},{\"kind\":\"build\",\"name\":\"fslock\",\"req\":\"^0.2\"},{\"kind\":\"dev\",\"name\":\"fslock\",\"req\":\"^0.2\"},{\"kind\":\"build\",\"name\":\"gzip-header\",\"req\":\"^1.0.0\"},{\"kind\":\"dev\",\"name\":\"gzip-header\",\"req\":\"^1.0.0\"},{\"kind\":\"build\",\"name\":\"home\",\"req\":\"^0\"},{\"kind\":\"dev\",\"name\":\"home\",\"req\":\"^0\"},{\"kind\":\"build\",\"name\":\"miniz_oxide\",\"req\":\"^0.8.8\"},{\"kind\":\"dev\",\"name\":\"miniz_oxide\",\"req\":\"^0.8.8\"},{\"name\":\"paste\",\"req\":\"^1.0\"},{\"kind\":\"dev\",\"name\":\"rustversion\",\"req\":\"^1\"},{\"features\":[\"zoneinfo64\"],\"name\":\"temporal_capi\",\"req\":\"^0.2.3\"},{\"kind\":\"dev\",\"name\":\"trybuild\",\"req\":\"^1.0.96\"},{\"kind\":\"build\",\"name\":\"which\",\"req\":\"^6\"},{\"kind\":\"dev\",\"name\":\"which\",\"req\":\"^6\"}],\"features\":{\"default\":[\"use_custom_libcxx\"],\"simdutf\":[],\"use_custom_libcxx\":[],\"v8_enable_pointer_compression\":[],\"v8_enable_sandbox\":[\"v8_enable_pointer_compression\"],\"v8_enable_v8_checks\":[]}}",
|
||||
"valuable_0.1.1": "{\"dependencies\":[{\"kind\":\"dev\",\"name\":\"criterion\",\"req\":\"^0.3\"},{\"name\":\"valuable-derive\",\"optional\":true,\"req\":\"=0.1.1\"}],\"features\":{\"alloc\":[],\"default\":[\"std\"],\"derive\":[\"valuable-derive\"],\"std\":[\"alloc\"]}}",
|
||||
"vcpkg_0.2.15": "{\"dependencies\":[{\"kind\":\"dev\",\"name\":\"lazy_static\",\"req\":\"^1\"},{\"kind\":\"dev\",\"name\":\"tempdir\",\"req\":\"^0.3.7\"}],\"features\":{}}",
|
||||
"version-compare_0.2.1": "{\"dependencies\":[],\"features\":{}}",
|
||||
|
||||
Generated
+1
-2
@@ -16599,8 +16599,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "v8"
|
||||
version = "152.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a10fe1a92da5c32c7c7f838ce36c0ccfcfd5edf0865b58bdde820aa64cea9888"
|
||||
source = "git+https://github.com/seanh-oai/rusty_v8.git?rev=350c5a859a9b3c84ab8701b3ad51e3b7699b30c0#350c5a859a9b3c84ab8701b3ad51e3b7699b30c0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bitflags 2.13.1",
|
||||
|
||||
@@ -674,6 +674,7 @@ opt-level = 0
|
||||
crossterm = { git = "https://github.com/openai-oss-forks/crossterm", rev = "ed1cdab335221515706178d68495bba2aed1924f" }
|
||||
tokio-tungstenite = { git = "https://github.com/openai-oss-forks/tokio-tungstenite", rev = "0e5b2d73aa18dd9f0a50ee9ff199d5aef7594186" }
|
||||
tungstenite = { git = "https://github.com/openai-oss-forks/tungstenite-rs", rev = "4fffad30fe373adbdcffab9545e9e9bf4f2fc19f" }
|
||||
v8 = { git = "https://github.com/seanh-oai/rusty_v8.git", rev = "350c5a859a9b3c84ab8701b3ad51e3b7699b30c0" }
|
||||
|
||||
# Uncomment to debug local changes.
|
||||
# rmcp = { path = "../../rust-sdk/crates/rmcp" }
|
||||
|
||||
@@ -332,6 +332,7 @@ allow-git = [
|
||||
"https://github.com/openai-oss-forks/crossterm",
|
||||
"https://github.com/openai-oss-forks/tokio-tungstenite",
|
||||
"https://github.com/openai-oss-forks/tungstenite-rs",
|
||||
"https://github.com/seanh-oai/rusty_v8.git",
|
||||
]
|
||||
|
||||
[sources.allow-org]
|
||||
|
||||
@@ -5,6 +5,11 @@ codex_rust_crate(
|
||||
crate_features = ["sandbox"],
|
||||
crate_name = "codex_v8_poc",
|
||||
deps_extra = ["@crates//:v8"],
|
||||
# The ignored CppGC ABI checks require the native archive/binding pair.
|
||||
unit_test_args = select({
|
||||
"//third_party/v8:use_rusty_v8_prebuilts": [],
|
||||
"//conditions:default": ["--include-ignored"],
|
||||
}),
|
||||
)
|
||||
|
||||
alias(
|
||||
|
||||
+321
-3
@@ -47,11 +47,17 @@ mod tests {
|
||||
|
||||
let context = v8::Context::new(scope, Default::default());
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
|
||||
evaluate_script(scope, expression).to_rust_string_lossy(scope)
|
||||
}
|
||||
|
||||
fn evaluate_script<'s>(
|
||||
scope: &mut v8::PinScope<'s, '_>,
|
||||
expression: &str,
|
||||
) -> v8::Local<'s, v8::Value> {
|
||||
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)
|
||||
script.run(scope).expect("expression should evaluate")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -69,6 +75,62 @@ mod tests {
|
||||
assert_eq!(super::linked_v8_has_sandbox(), cfg!(feature = "sandbox"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires a native V8 pair and corrected rusty_v8; published 152.2.0 has an incompatible CppGC ABI"]
|
||||
fn cppgc_member_storage_satisfies_alignment() {
|
||||
use v8::cppgc;
|
||||
|
||||
struct Item;
|
||||
// SAFETY: Item contains no GC references to trace.
|
||||
unsafe impl cppgc::GarbageCollected for Item {
|
||||
fn trace(&self, _: &mut cppgc::Visitor) {}
|
||||
|
||||
fn get_name(&self) -> &'static std::ffi::CStr {
|
||||
c"Item"
|
||||
}
|
||||
}
|
||||
|
||||
// In pinned V8 the C++ slot is either a uint32_t or native pointer.
|
||||
// No Member construction occurs until we know Rust can satisfy both.
|
||||
for (name, size, alignment) in [
|
||||
(
|
||||
"Member",
|
||||
size_of::<cppgc::Member<Item>>(),
|
||||
align_of::<cppgc::Member<Item>>(),
|
||||
),
|
||||
(
|
||||
"WeakMember",
|
||||
size_of::<cppgc::WeakMember<Item>>(),
|
||||
align_of::<cppgc::WeakMember<Item>>(),
|
||||
),
|
||||
] {
|
||||
assert!(matches!(size, 4 | 8), "unexpected {name} size: {size}");
|
||||
assert_eq!(
|
||||
alignment, size,
|
||||
"{name} storage does not meet C++ alignment"
|
||||
);
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct BytePrefix {
|
||||
prefix: u8,
|
||||
strong: cppgc::Member<Item>,
|
||||
weak: cppgc::WeakMember<Item>,
|
||||
}
|
||||
#[repr(C)]
|
||||
struct WordPrefix {
|
||||
prefix: u32,
|
||||
strong: cppgc::Member<Item>,
|
||||
weak: cppgc::WeakMember<Item>,
|
||||
}
|
||||
let strong_align = align_of::<cppgc::Member<Item>>();
|
||||
let weak_align = align_of::<cppgc::WeakMember<Item>>();
|
||||
assert_eq!(std::mem::offset_of!(BytePrefix, strong) % strong_align, 0);
|
||||
assert_eq!(std::mem::offset_of!(BytePrefix, weak) % weak_align, 0);
|
||||
assert_eq!(std::mem::offset_of!(WordPrefix, strong) % strong_align, 0);
|
||||
assert_eq!(std::mem::offset_of!(WordPrefix, weak) % weak_align, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn evaluates_integer_addition() {
|
||||
assert_eq!(evaluate_expression("1 + 2"), "3");
|
||||
@@ -79,6 +141,262 @@ mod tests {
|
||||
assert_eq!(evaluate_expression("'hello ' + 'world'"), "hello world");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reads_typed_array_contents_with_the_compiled_binding_size() {
|
||||
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);
|
||||
|
||||
for length in [0, 1, 63, 64, 65] {
|
||||
let expression = format!("new Uint8Array({length}).fill(90)");
|
||||
let value = evaluate_script(scope, &expression);
|
||||
let view = v8::Local::<v8::ArrayBufferView>::try_from(value).unwrap();
|
||||
let on_heap =
|
||||
v8::TYPED_ARRAY_MAX_SIZE_IN_HEAP != 0 && length <= v8::TYPED_ARRAY_MAX_SIZE_IN_HEAP;
|
||||
// Check native placement before asking C++ to copy into storage:
|
||||
// stale size-zero bindings must fail here rather than abort in FFI.
|
||||
assert_eq!(view.has_buffer(), !on_heap, "byte length {length}");
|
||||
|
||||
let mut storage = vec![0; v8::TYPED_ARRAY_MAX_SIZE_IN_HEAP];
|
||||
let storage_ptr = storage.as_ptr();
|
||||
let contents = view.get_contents(&mut storage);
|
||||
assert_eq!(contents, vec![90; length], "byte length {length}");
|
||||
if on_heap {
|
||||
assert_eq!(contents.as_ptr(), storage_ptr);
|
||||
}
|
||||
// Reading inline contents copies bytes without promoting the view.
|
||||
assert_eq!(view.has_buffer(), !on_heap, "byte length {length}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_array_backing_store_promotion_survives_collection() {
|
||||
enum Promotion {
|
||||
Data,
|
||||
BackingStore,
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for promotion in [Promotion::Data, Promotion::BackingStore] {
|
||||
let value = evaluate_script(scope, "new Uint8Array(64).fill(90)");
|
||||
let view = v8::Local::<v8::ArrayBufferView>::try_from(value).unwrap();
|
||||
let data = match promotion {
|
||||
Promotion::Data => view.data(),
|
||||
Promotion::BackingStore => {
|
||||
view.get_backing_store().unwrap().data().unwrap().as_ptr()
|
||||
}
|
||||
};
|
||||
let backing_store = view.get_backing_store().unwrap();
|
||||
assert!(view.has_buffer());
|
||||
assert_eq!(backing_store.data().unwrap().as_ptr(), data);
|
||||
|
||||
scope.low_memory_notification();
|
||||
|
||||
assert_eq!(view.data(), data);
|
||||
assert_eq!(backing_store.data().unwrap().as_ptr(), data);
|
||||
assert_eq!(
|
||||
backing_store
|
||||
.iter()
|
||||
.map(std::cell::Cell::get)
|
||||
.collect::<Vec<_>>(),
|
||||
vec![90; 64]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn microtask_queue_runs_promises_across_collection_and_context_reassignment() {
|
||||
initialize_v8();
|
||||
let isolate = &mut v8::Isolate::new(Default::default());
|
||||
let queue = v8::MicrotaskQueue::new(isolate, v8::MicrotasksPolicy::Explicit);
|
||||
{
|
||||
v8::scope!(let scope, isolate);
|
||||
let context = v8::Context::new(scope, Default::default());
|
||||
let default_queue = context.get_microtask_queue().unwrap();
|
||||
context.set_microtask_queue(queue.as_ref());
|
||||
{
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
evaluate_script(
|
||||
scope,
|
||||
"globalThis.results = []; \
|
||||
Promise.resolve(1).then(value => results.push(value)); \
|
||||
(async () => { results.push(await Promise.resolve(2)); })();",
|
||||
);
|
||||
|
||||
scope.low_memory_notification();
|
||||
assert_eq!(
|
||||
evaluate_script(scope, "JSON.stringify(results)").to_rust_string_lossy(scope),
|
||||
"[]"
|
||||
);
|
||||
queue.perform_checkpoint(scope);
|
||||
assert_eq!(
|
||||
evaluate_script(scope, "JSON.stringify(results)").to_rust_string_lossy(scope),
|
||||
"[1,2]"
|
||||
);
|
||||
}
|
||||
|
||||
// V8 requires exiting the context before replacing its queue.
|
||||
// Keep the handle alive until the context releases its queue, for
|
||||
// both GC-rooted and uniquely owned queue storage.
|
||||
context.set_microtask_queue(default_queue);
|
||||
assert!(std::ptr::eq(
|
||||
context.get_microtask_queue().unwrap(),
|
||||
default_queue
|
||||
));
|
||||
}
|
||||
drop(queue);
|
||||
isolate.low_memory_notification();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires a native V8 pair and corrected rusty_v8; published 152.2.0 has an incompatible CppGC ABI"]
|
||||
fn compiled_cppgc_members_match_bindings_and_survive_collection() {
|
||||
use std::ffi::c_void;
|
||||
use v8::cppgc;
|
||||
|
||||
// A small prefix exercises the Rust slot alignment before C++ access.
|
||||
#[repr(C)]
|
||||
struct Node {
|
||||
value: u32,
|
||||
next: cppgc::Member<Node>,
|
||||
weak: cppgc::WeakMember<Node>,
|
||||
}
|
||||
|
||||
// SAFETY: every Member and WeakMember owned by Node is traced.
|
||||
unsafe impl cppgc::GarbageCollected for Node {
|
||||
fn trace(&self, visitor: &mut cppgc::Visitor) {
|
||||
visitor.trace(&self.next);
|
||||
visitor.trace(&self.weak);
|
||||
}
|
||||
|
||||
fn get_name(&self) -> &'static std::ffi::CStr {
|
||||
c"v8-poc cppgc Node"
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" {
|
||||
fn cppgc__Member__CONSTRUCT(storage: *mut c_void, object: *mut c_void);
|
||||
fn cppgc__Member__Get(storage: *const c_void) -> *mut c_void;
|
||||
fn cppgc__Member__DESTRUCT(storage: *mut c_void);
|
||||
fn cppgc__WeakMember__CONSTRUCT(storage: *mut c_void, object: *mut c_void);
|
||||
fn cppgc__WeakMember__Get(storage: *const c_void) -> *mut c_void;
|
||||
fn cppgc__WeakMember__DESTRUCT(storage: *mut c_void);
|
||||
}
|
||||
|
||||
// Fail before accessing an incorrectly aligned Rust slot through FFI.
|
||||
cppgc_member_storage_satisfies_alignment();
|
||||
initialize_v8();
|
||||
// Member::empty() calls C++ into a Rust stack slot sized by bindgen.
|
||||
// Validate that size BEFORE calling it: a stale 4-byte binding for an
|
||||
// 8-byte archive must fail an assertion, never overwrite a Rust slot.
|
||||
// All supported native CPPGC pointers fit a usize. A null pointer
|
||||
// initializes its full declared storage to zero in both encodings.
|
||||
#[repr(C, align(16))]
|
||||
struct Slot([u8; 4 * size_of::<usize>()]);
|
||||
for (name, size, construct, get, destruct) in [
|
||||
(
|
||||
"Member",
|
||||
size_of::<cppgc::Member<Node>>(),
|
||||
cppgc__Member__CONSTRUCT as unsafe extern "C" fn(*mut c_void, *mut c_void),
|
||||
cppgc__Member__Get as unsafe extern "C" fn(*const c_void) -> *mut c_void,
|
||||
cppgc__Member__DESTRUCT as unsafe extern "C" fn(*mut c_void),
|
||||
),
|
||||
(
|
||||
"WeakMember",
|
||||
size_of::<cppgc::WeakMember<Node>>(),
|
||||
cppgc__WeakMember__CONSTRUCT as unsafe extern "C" fn(*mut c_void, *mut c_void),
|
||||
cppgc__WeakMember__Get as unsafe extern "C" fn(*const c_void) -> *mut c_void,
|
||||
cppgc__WeakMember__DESTRUCT as unsafe extern "C" fn(*mut c_void),
|
||||
),
|
||||
] {
|
||||
let mut slot = Slot([0xa5; 4 * size_of::<usize>()]);
|
||||
assert!(
|
||||
size <= size_of::<usize>(),
|
||||
"unexpected {name} binding size {size}"
|
||||
);
|
||||
let ptr = slot.0.as_mut_ptr().cast();
|
||||
// SAFETY: the aligned slot has enough room for either pointer
|
||||
// encoding and its guard; the object is destroyed before reuse.
|
||||
let is_null = unsafe {
|
||||
construct(ptr, std::ptr::null_mut());
|
||||
let is_null = get(ptr).is_null();
|
||||
destruct(ptr);
|
||||
is_null
|
||||
};
|
||||
assert!(is_null, "{name} failed to return its constructed null");
|
||||
assert!(
|
||||
slot.0[..size].iter().all(|byte| *byte == 0),
|
||||
"{name} binding is too large"
|
||||
);
|
||||
assert!(
|
||||
slot.0[size..].iter().all(|byte| *byte == 0xa5),
|
||||
"{name} binding is too small"
|
||||
);
|
||||
}
|
||||
|
||||
let mut heap = cppgc::Heap::create(v8::V8::get_current_platform(), Default::default());
|
||||
heap.enable_detached_garbage_collections_for_testing();
|
||||
{
|
||||
// SAFETY: each temporary pointer is kept on this stack and moved
|
||||
// immediately into a traced Member or a Persistent GC root.
|
||||
let root = unsafe {
|
||||
let child = cppgc::make_garbage_collected(
|
||||
&heap,
|
||||
Node {
|
||||
value: 42,
|
||||
next: cppgc::Member::empty(),
|
||||
weak: cppgc::WeakMember::empty(),
|
||||
},
|
||||
);
|
||||
let weak_only = cppgc::make_garbage_collected(
|
||||
&heap,
|
||||
Node {
|
||||
value: 7,
|
||||
next: cppgc::Member::empty(),
|
||||
weak: cppgc::WeakMember::empty(),
|
||||
},
|
||||
);
|
||||
let parent = cppgc::make_garbage_collected(
|
||||
&heap,
|
||||
Node {
|
||||
value: 1,
|
||||
next: cppgc::Member::new(&child),
|
||||
weak: cppgc::WeakMember::new(&weak_only),
|
||||
},
|
||||
);
|
||||
cppgc::Persistent::new(&parent)
|
||||
};
|
||||
// SAFETY: root and its traced Member are the only strong pointers
|
||||
// in use. The weak-only object must be collectible without stack
|
||||
// scanning. No UnsafePtr from allocation is dereferenced again.
|
||||
unsafe {
|
||||
heap.collect_garbage_for_testing(cppgc::EmbedderStackState::NoHeapPointers);
|
||||
let parent = root.get().expect("persistent root should survive");
|
||||
assert_eq!(parent.value, 1);
|
||||
assert_eq!(
|
||||
parent
|
||||
.next
|
||||
.get()
|
||||
.expect("traced child should survive")
|
||||
.value,
|
||||
42
|
||||
);
|
||||
assert!(
|
||||
parent.weak.get().is_none(),
|
||||
"weak-only target should be collected"
|
||||
);
|
||||
}
|
||||
}
|
||||
heap.terminate();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_crdtp_dispatchable_messages() {
|
||||
let cbor = v8::crdtp::json_to_cbor(br#"{"id":7,"method":"Runtime.evaluate","params":{}}"#)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Reuse rules_cc's installed SDK setup with an explicitly declared LLVM repo.
|
||||
# Only the V8 repository has native_llvm; ordinary local_config_cc behaves
|
||||
# exactly as upstream, including the caller's BAZEL_LLVM/USE_CLANG_CL.
|
||||
# Preserve DUMPBIN when selecting clang-cl; the upstream MSVC template uses it.
|
||||
# Only the V8 repository has native_llvm; ordinary local_config_cc keeps its
|
||||
# installed compiler and input files. Track the fetched LLVM tools and resources
|
||||
# as action inputs so changes to the pin invalidate cached compilation and links.
|
||||
diff --git a/cc/private/toolchain/windows_cc_configure.bzl b/cc/private/toolchain/windows_cc_configure.bzl
|
||||
--- a/cc/private/toolchain/windows_cc_configure.bzl
|
||||
+++ b/cc/private/toolchain/windows_cc_configure.bzl
|
||||
@@ -35,3 +35,75 @@ diff --git a/cc/private/toolchain/windows_cc_configure.bzl b/cc/private/toolchai
|
||||
build_tools["LINK"] = find_llvm_tool(repository_ctx, llvm_path, "lld-link.exe")
|
||||
if not build_tools["LINK"]:
|
||||
build_tools["LINK"] = find_msvc_tool(repository_ctx, vc_path, "link.exe", "x64")
|
||||
@@ -923,6 +930,12 @@
|
||||
)
|
||||
|
||||
template_vars = dict()
|
||||
+ native_llvm = getattr(repository_ctx.attr, "native_llvm", None)
|
||||
+ for group in ["compiler_files", "linker_files", "archiver_files", "all_files"]:
|
||||
+ files = [str(native_llvm.same_package_label(group))] if native_llvm else []
|
||||
+ if native_llvm and group == "all_files":
|
||||
+ files.append(":msvc_compiler_files")
|
||||
+ template_vars["%{native_llvm_" + group + "}"] = repr(files)
|
||||
msvc_vars_x64 = _get_msvc_vars(repository_ctx, paths, "x64")
|
||||
template_vars.update(msvc_vars_x64)
|
||||
template_vars.update(_get_clang_cl_vars(repository_ctx, paths, msvc_vars_x64, "x64"))
|
||||
diff --git a/cc/private/toolchain/BUILD.windows.tpl b/cc/private/toolchain/BUILD.windows.tpl
|
||||
--- a/cc/private/toolchain/BUILD.windows.tpl
|
||||
+++ b/cc/private/toolchain/BUILD.windows.tpl
|
||||
@@ -67,7 +67,22 @@
|
||||
"%{msvc_deps_scanner_wrapper_path_x64}",
|
||||
"%{msvc_deps_scanner_wrapper_path_arm}",
|
||||
"%{msvc_deps_scanner_wrapper_path_arm64}",
|
||||
- ]
|
||||
+ ] + %{native_llvm_compiler_files}
|
||||
+)
|
||||
+
|
||||
+filegroup(
|
||||
+ name = "msvc_all_files",
|
||||
+ srcs = %{native_llvm_all_files},
|
||||
+)
|
||||
+
|
||||
+filegroup(
|
||||
+ name = "msvc_linker_files",
|
||||
+ srcs = %{native_llvm_linker_files},
|
||||
+)
|
||||
+
|
||||
+filegroup(
|
||||
+ name = "msvc_archiver_files",
|
||||
+ srcs = %{native_llvm_archiver_files},
|
||||
)
|
||||
|
||||
# Hardcoded toolchain, legacy behaviour.
|
||||
@@ -301,12 +316,12 @@
|
||||
name = "cc-compiler-x64_windows",
|
||||
toolchain_identifier = "msvc_x64",
|
||||
toolchain_config = ":msvc_x64",
|
||||
- all_files = ":empty",
|
||||
- ar_files = ":empty",
|
||||
+ all_files = ":msvc_all_files",
|
||||
+ ar_files = ":msvc_archiver_files",
|
||||
as_files = ":msvc_compiler_files",
|
||||
compiler_files = ":msvc_compiler_files",
|
||||
dwp_files = ":empty",
|
||||
- linker_files = ":empty",
|
||||
+ linker_files = ":msvc_linker_files",
|
||||
objcopy_files = ":empty",
|
||||
strip_files = ":empty",
|
||||
supports_param_files = 1,
|
||||
@@ -526,12 +541,12 @@
|
||||
name = "cc-compiler-arm64_windows",
|
||||
toolchain_identifier = "msvc_arm64",
|
||||
toolchain_config = ":msvc_arm64",
|
||||
- all_files = ":empty",
|
||||
- ar_files = ":empty",
|
||||
+ all_files = ":msvc_all_files",
|
||||
+ ar_files = ":msvc_archiver_files",
|
||||
as_files = ":msvc_compiler_files",
|
||||
compiler_files = ":msvc_compiler_files",
|
||||
dwp_files = ":empty",
|
||||
- linker_files = ":empty",
|
||||
+ linker_files = ":msvc_linker_files",
|
||||
objcopy_files = ":empty",
|
||||
strip_files = ":empty",
|
||||
supports_param_files = 1,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# What: make `rusty_v8` accept Bazel-provided archives and bindings for the
|
||||
# windows-gnullvm experiment.
|
||||
# Scope: `rusty_v8` build.rs only; no V8 source or Bazel rule changes.
|
||||
# Make rusty_v8 use the Bazel-provided archive and bindings. Mark the Git
|
||||
# checkout's vendored third_party directory as a package so rules_rs does not
|
||||
# stage libc++ test names containing '=' as Cargo build-script runfiles.
|
||||
|
||||
--- a/build.rs
|
||||
+++ b/build.rs
|
||||
@@ -72,3 +72,7 @@
|
||||
if target.contains("msvc") {
|
||||
// nothing to link to
|
||||
} else if target.contains("apple")
|
||||
--- /dev/null
|
||||
+++ b/third_party/BUILD.bazel
|
||||
@@ -0,0 +1 @@
|
||||
+package(default_visibility = ["//visibility:private"])
|
||||
|
||||
Vendored
+206
-81
@@ -2,6 +2,7 @@ load("@@//third_party/v8:artifact_profile.bzl", "v8_artifact_files")
|
||||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
load("@rules_cc//cc:cc_static_library.bzl", "cc_static_library")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("@rules_rs//rs:rules_rust_bindgen.bzl", "rust_bindgen")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -93,20 +94,6 @@ alias(
|
||||
actual = ":v8_152_2_0_x86_64_pc_windows_gnullvm_bazel",
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "src_binding_release_x86_64_pc_windows_gnullvm_152_2_0_release",
|
||||
# `rusty_v8` does not publish a Windows GNU binding file. The generated
|
||||
# binding only describes this V8 release's C++ API surface, so reuse the
|
||||
# Linux release binding while the windows-gnullvm archive build is still
|
||||
# experimental.
|
||||
actual = ":src_binding_release_x86_64_unknown_linux_gnu_152_2_0_release",
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "src_binding_release_aarch64_pc_windows_gnullvm_152_2_0_release",
|
||||
actual = ":src_binding_release_aarch64_unknown_linux_gnu_152_2_0_release",
|
||||
)
|
||||
|
||||
# Both ordinary consumers and source consumers use the current sandbox ABI.
|
||||
# Switch the archive and binding together for source instrumentation. The same
|
||||
# root setting is visible in the @v8_targets copy used by rules_rs.
|
||||
@@ -176,14 +163,14 @@ alias(
|
||||
actual = select({
|
||||
"@rules_rs//rs/platforms/config:aarch64-apple-darwin": ":v8_152_2_0_aarch64_apple_darwin_bazel",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-gnullvm": ":v8_152_2_0_aarch64_pc_windows_gnullvm",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":v8_152_2_0_aarch64_pc_windows_msvc",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":v8_152_2_0_aarch64_pc_windows_msvc_bazel",
|
||||
"@rules_rs//rs/platforms/config:aarch64-unknown-linux-gnu": ":v8_152_2_0_aarch64_unknown_linux_gnu_bazel",
|
||||
# Rust's compiler-builtins archive does not supply V8's __clear_cache.
|
||||
# Use the merged archive containing the ARM64 compiler-rt builtins.
|
||||
":platform_aarch64_unknown_linux_musl": ":v8_152_2_0_aarch64_unknown_linux_musl_release",
|
||||
"@rules_rs//rs/platforms/config:x86_64-apple-darwin": ":v8_152_2_0_x86_64_apple_darwin_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-gnullvm": ":v8_152_2_0_x86_64_pc_windows_gnullvm",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":v8_152_2_0_x86_64_pc_windows_msvc",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":v8_152_2_0_x86_64_pc_windows_msvc_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-unknown-linux-gnu": ":v8_152_2_0_x86_64_unknown_linux_gnu_bazel",
|
||||
":platform_x86_64_unknown_linux_musl": ":v8_152_2_0_x86_64_unknown_linux_musl_release",
|
||||
"//conditions:default": ":v8_152_2_0_x86_64_unknown_linux_gnu_bazel",
|
||||
@@ -216,17 +203,17 @@ alias(
|
||||
alias(
|
||||
name = "rusty_v8_source_binding_for_target",
|
||||
actual = select({
|
||||
"@rules_rs//rs/platforms/config:aarch64-apple-darwin": ":src_binding_release_aarch64_apple_darwin_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-gnullvm": ":src_binding_release_aarch64_pc_windows_gnullvm_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":src_binding_release_aarch64_pc_windows_msvc_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:aarch64-unknown-linux-gnu": ":src_binding_release_aarch64_unknown_linux_gnu_152_2_0_release",
|
||||
":platform_aarch64_unknown_linux_musl": ":src_binding_release_aarch64_unknown_linux_musl_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:x86_64-apple-darwin": ":src_binding_release_x86_64_apple_darwin_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-gnullvm": ":src_binding_release_x86_64_pc_windows_gnullvm_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":src_binding_release_x86_64_pc_windows_msvc_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:x86_64-unknown-linux-gnu": ":src_binding_release_x86_64_unknown_linux_gnu_152_2_0_release",
|
||||
":platform_x86_64_unknown_linux_musl": ":src_binding_release_x86_64_unknown_linux_musl_152_2_0_release",
|
||||
"//conditions:default": ":src_binding_release_x86_64_unknown_linux_gnu_152_2_0_release",
|
||||
"@rules_rs//rs/platforms/config:aarch64-apple-darwin": ":src_binding_aarch64_apple_darwin_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-gnullvm": ":src_binding_aarch64_pc_windows_gnullvm_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":src_binding_aarch64_pc_windows_msvc_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:aarch64-unknown-linux-gnu": ":src_binding_aarch64_unknown_linux_gnu_152_2_0_bazel",
|
||||
":platform_aarch64_unknown_linux_musl": ":src_binding_aarch64_unknown_linux_musl_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-apple-darwin": ":src_binding_x86_64_apple_darwin_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-gnullvm": ":src_binding_x86_64_pc_windows_gnullvm_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":src_binding_x86_64_pc_windows_msvc_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-unknown-linux-gnu": ":src_binding_x86_64_unknown_linux_gnu_152_2_0_bazel",
|
||||
":platform_x86_64_unknown_linux_musl": ":src_binding_x86_64_unknown_linux_musl_152_2_0_bazel",
|
||||
"//conditions:default": ":src_binding_x86_64_unknown_linux_gnu_152_2_0_bazel",
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -420,6 +407,184 @@ alias(
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
# Bindgen reads the same CcInfo as the C++ archive. Pass local libc++ options
|
||||
# explicitly because CcInfo propagates defines and headers, but not copts.
|
||||
cc_library(
|
||||
name = "binding_headers_152_2_0",
|
||||
hdrs = [
|
||||
"@v8_crate_152_2_0//:binding_hpp",
|
||||
"@v8_crate_152_2_0//:support_h",
|
||||
],
|
||||
tags = ["manual"],
|
||||
# Bindgen asks the toolchain for C flags, which omit its C++ header search
|
||||
# paths. Source profiles use the workspace headers; release profiles get
|
||||
# their pinned Chromium headers from the profiled binding dependency.
|
||||
deps = [":v8_152_2_0_binding"] + select({
|
||||
":use_rusty_v8_custom_libcxx": [],
|
||||
"@platforms//os:osx": [],
|
||||
"//conditions:default": [
|
||||
"@llvm-project//libcxx:headers",
|
||||
"@llvm-project//libcxxabi:headers",
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
rust_bindgen(
|
||||
name = "binding_generated_152_2_0",
|
||||
bindgen_flags = [
|
||||
"--generate-cstr",
|
||||
"--rustified-enum=.*UseCounterFeature",
|
||||
"--rustified-enum=.*ModuleImportPhase",
|
||||
"--rustified-enum=.*Intercepted",
|
||||
"--bitfield-enum=.*GCType",
|
||||
"--bitfield-enum=.*GCCallbackFlags",
|
||||
"--allowlist-item=v8__.*",
|
||||
"--allowlist-item=cppgc__.*",
|
||||
"--allowlist-item=RustObj",
|
||||
"--allowlist-item=memory_span_t",
|
||||
"--allowlist-item=const_memory_span_t",
|
||||
"--allowlist-item=ExternalConstOneByteStringResource",
|
||||
"--blocklist-item=cppgc.*Visitor",
|
||||
"--blocklist-item=RustObj.*Trace",
|
||||
],
|
||||
cc_lib = ":binding_headers_152_2_0",
|
||||
clang_flags = [
|
||||
"-x",
|
||||
"c++",
|
||||
"-std=c++20",
|
||||
] + V8_CUSTOM_LIBCXX_COPTS + select({
|
||||
# Match the C++ toolchain. Bindgen asks for C flags and otherwise
|
||||
# enables C++20 modules, for which the macOS SDK's types are cyclic.
|
||||
"@platforms//os:osx": [
|
||||
"-Xclang",
|
||||
"-fno-cxx-modules",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"@rules_rs//rs/platforms/config:aarch64-apple-darwin": ["--target=arm64-apple-darwin"],
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-gnullvm": ["--target=aarch64-w64-windows-gnu"],
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ["--target=aarch64-pc-windows-msvc"],
|
||||
"@llvm//platforms/config:linux_aarch64": ["--target=aarch64-unknown-linux-gnu"],
|
||||
":platform_aarch64_unknown_linux_musl": ["--target=aarch64-unknown-linux-musl"],
|
||||
"@rules_rs//rs/platforms/config:x86_64-apple-darwin": ["--target=x86_64-apple-darwin"],
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-gnullvm": ["--target=x86_64-w64-windows-gnu"],
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ["--target=x86_64-pc-windows-msvc"],
|
||||
"@llvm//platforms/config:linux_x86_64": ["--target=x86_64-unknown-linux-gnu"],
|
||||
":platform_x86_64_unknown_linux_musl": ["--target=x86_64-unknown-linux-musl"],
|
||||
}),
|
||||
header = "@v8_crate_152_2_0//:binding_hpp",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_aarch64_pc_windows_msvc_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "sandbox_release",
|
||||
tags = ["manual"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:aarch64",
|
||||
"@platforms//os:windows",
|
||||
"@llvm//constraints/windows/abi:msvc",
|
||||
],
|
||||
v8_cpu = "arm64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_x86_64_pc_windows_msvc_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "sandbox_release",
|
||||
tags = ["manual"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:windows",
|
||||
"@llvm//constraints/windows/abi:msvc",
|
||||
],
|
||||
v8_cpu = "x64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_aarch64_pc_windows_gnullvm_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:aarch64",
|
||||
"@platforms//os:windows",
|
||||
"@llvm//constraints/windows/abi:gnullvm",
|
||||
],
|
||||
v8_cpu = "arm64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_x86_64_pc_windows_gnullvm_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
target_compatible_with = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:windows",
|
||||
"@llvm//constraints/windows/abi:gnullvm",
|
||||
],
|
||||
v8_cpu = "x64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_aarch64_apple_darwin_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
v8_cpu = "arm64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_x86_64_apple_darwin_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
v8_cpu = "x64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_aarch64_unknown_linux_gnu_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
v8_cpu = "arm64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_x86_64_unknown_linux_gnu_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
v8_cpu = "x64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_aarch64_unknown_linux_musl_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
v8_cpu = "arm64",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "src_binding_x86_64_unknown_linux_musl_152_2_0_bazel",
|
||||
srcs = [":binding_generated_152_2_0"],
|
||||
profile = "source",
|
||||
tags = ["manual"],
|
||||
v8_cpu = "x64",
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "rusty_v8_native_windows_binding_for_target",
|
||||
actual = select({
|
||||
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":src_binding_aarch64_pc_windows_msvc_152_2_0_bazel",
|
||||
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":src_binding_x86_64_pc_windows_msvc_152_2_0_bazel",
|
||||
}),
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "_v8_152_2_0_aarch64_apple_darwin_bazel",
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
@@ -541,51 +706,11 @@ cc_static_library(
|
||||
]
|
||||
]
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_apple_darwin_152_2_0_release",
|
||||
srcs = ["@v8_crate_152_2_0//:src_binding_release_aarch64_apple_darwin"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_apple_darwin_152_2_0_release",
|
||||
srcs = ["@v8_crate_152_2_0//:src_binding_release_x86_64_apple_darwin"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_unknown_linux_gnu_152_2_0_release",
|
||||
srcs = ["@v8_crate_152_2_0//:src_binding_release_aarch64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_unknown_linux_gnu_152_2_0_release",
|
||||
srcs = ["@v8_crate_152_2_0//:src_binding_release_x86_64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_unknown_linux_musl_152_2_0_release",
|
||||
srcs = ["@v8_crate_152_2_0//:src_binding_release_aarch64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_unknown_linux_musl_152_2_0_release",
|
||||
srcs = ["@v8_crate_152_2_0//:src_binding_release_x86_64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "src_binding_release_aarch64_pc_windows_msvc_152_2_0_release",
|
||||
actual = "@rusty_v8_152_2_0_aarch64_pc_windows_msvc_binding//file",
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "src_binding_release_x86_64_pc_windows_msvc_152_2_0_release",
|
||||
actual = "@rusty_v8_152_2_0_x86_64_pc_windows_msvc_binding//file",
|
||||
)
|
||||
|
||||
v8_artifact_files(
|
||||
name = "rusty_v8_release_pair_x86_64_apple_darwin",
|
||||
srcs = [
|
||||
":_v8_152_2_0_x86_64_apple_darwin_bazel",
|
||||
":src_binding_release_x86_64_apple_darwin_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "release",
|
||||
v8_cpu = "x64",
|
||||
@@ -595,7 +720,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_release_pair_aarch64_apple_darwin",
|
||||
srcs = [
|
||||
":_v8_152_2_0_aarch64_apple_darwin_bazel",
|
||||
":src_binding_release_aarch64_apple_darwin_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "release",
|
||||
v8_cpu = "arm64",
|
||||
@@ -605,7 +730,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_release_pair_x86_64_unknown_linux_gnu",
|
||||
srcs = [
|
||||
":_v8_152_2_0_x86_64_unknown_linux_gnu_bazel",
|
||||
":src_binding_release_x86_64_unknown_linux_gnu_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "release",
|
||||
v8_cpu = "x64",
|
||||
@@ -615,7 +740,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_release_pair_aarch64_unknown_linux_gnu",
|
||||
srcs = [
|
||||
":_v8_152_2_0_aarch64_unknown_linux_gnu_bazel",
|
||||
":src_binding_release_aarch64_unknown_linux_gnu_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "release",
|
||||
v8_cpu = "arm64",
|
||||
@@ -625,7 +750,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_release_pair_x86_64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":_v8_152_2_0_x86_64_unknown_linux_musl_release",
|
||||
":src_binding_release_x86_64_unknown_linux_musl_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "release",
|
||||
v8_cpu = "x64",
|
||||
@@ -635,7 +760,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_release_pair_aarch64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":_v8_152_2_0_aarch64_unknown_linux_musl_release",
|
||||
":src_binding_release_aarch64_unknown_linux_musl_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "release",
|
||||
v8_cpu = "arm64",
|
||||
@@ -644,16 +769,16 @@ v8_artifact_files(
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_x86_64_pc_windows_msvc",
|
||||
srcs = [
|
||||
":src_binding_release_x86_64_pc_windows_msvc_152_2_0_release",
|
||||
":v8_152_2_0_x86_64_pc_windows_msvc",
|
||||
"@rusty_v8_152_2_0_x86_64_pc_windows_msvc_binding//file",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_aarch64_pc_windows_msvc",
|
||||
srcs = [
|
||||
":src_binding_release_aarch64_pc_windows_msvc_152_2_0_release",
|
||||
":v8_152_2_0_aarch64_pc_windows_msvc",
|
||||
"@rusty_v8_152_2_0_aarch64_pc_windows_msvc_binding//file",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -661,7 +786,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_sandbox_release_pair_x86_64_apple_darwin",
|
||||
srcs = [
|
||||
":_v8_152_2_0_x86_64_apple_darwin_bazel",
|
||||
":src_binding_release_x86_64_apple_darwin_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "sandbox_release",
|
||||
v8_cpu = "x64",
|
||||
@@ -671,7 +796,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_sandbox_release_pair_aarch64_apple_darwin",
|
||||
srcs = [
|
||||
":_v8_152_2_0_aarch64_apple_darwin_bazel",
|
||||
":src_binding_release_aarch64_apple_darwin_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "sandbox_release",
|
||||
v8_cpu = "arm64",
|
||||
@@ -681,7 +806,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_sandbox_release_pair_x86_64_unknown_linux_gnu",
|
||||
srcs = [
|
||||
":_v8_152_2_0_x86_64_unknown_linux_gnu_bazel",
|
||||
":src_binding_release_x86_64_unknown_linux_gnu_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "sandbox_release",
|
||||
v8_cpu = "x64",
|
||||
@@ -691,7 +816,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_sandbox_release_pair_aarch64_unknown_linux_gnu",
|
||||
srcs = [
|
||||
":_v8_152_2_0_aarch64_unknown_linux_gnu_bazel",
|
||||
":src_binding_release_aarch64_unknown_linux_gnu_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "sandbox_release",
|
||||
v8_cpu = "arm64",
|
||||
@@ -701,7 +826,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_sandbox_release_pair_x86_64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":_v8_152_2_0_x86_64_unknown_linux_musl_release",
|
||||
":src_binding_release_x86_64_unknown_linux_musl_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "sandbox_release",
|
||||
v8_cpu = "x64",
|
||||
@@ -711,7 +836,7 @@ v8_artifact_files(
|
||||
name = "rusty_v8_sandbox_release_pair_aarch64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":_v8_152_2_0_aarch64_unknown_linux_musl_release",
|
||||
":src_binding_release_aarch64_unknown_linux_musl_152_2_0_release",
|
||||
":binding_generated_152_2_0",
|
||||
],
|
||||
profile = "sandbox_release",
|
||||
v8_cpu = "arm64",
|
||||
|
||||
Vendored
+31
-22
@@ -6,7 +6,7 @@ Bazel consumer builds use:
|
||||
- Codex-published sandbox archive/binding pairs on Darwin, GNU/musl Linux,
|
||||
and Windows MSVC (x64 and arm64), with checksums pinned from the trusted
|
||||
release manifests
|
||||
- source-built V8 archives on Windows GNU
|
||||
- source-built V8 archives and matching generated bindings on Windows GNU
|
||||
|
||||
Local Cargo builds still use upstream prebuilt `rusty_v8` archives by default.
|
||||
Selected Cargo CI, release, and package builds override
|
||||
@@ -15,14 +15,17 @@ sets those variables independently in `MODULE.bazel`, selecting the pair above
|
||||
for its consumers. All Bazel compilation modes use the same published V8
|
||||
release archive on supported platforms.
|
||||
|
||||
The Bazel `v8` crate feature selection enables V8's in-process sandbox.
|
||||
Darwin/Linux consumers use the matching published pair by default.
|
||||
For a source build use `--//:rusty_v8_from_source=true`; both archive and
|
||||
bindings then come from the source path. Source targets enforce the workspace
|
||||
runtime and sandbox/pointer-compression ABI. Release-pair targets enforce either
|
||||
the legacy or the sandbox ABI plus Chromium's pinned runtime. Target CPU follows
|
||||
the named artifact. The underlying V8 settings are internal, and callers do
|
||||
not pass separate V8 feature or libc++ flags.
|
||||
The Bazel `v8` crate and its native source targets enable V8's in-process
|
||||
sandbox and pointer compression. For instrumentation, use
|
||||
`--//:rusty_v8_from_source=true`: on Darwin, Linux and native Windows MSVC
|
||||
the archive and bindings both come from source instead of the pinned published
|
||||
sandbox pair. The published archive cannot incorporate native debug or sanitizer
|
||||
settings.
|
||||
|
||||
Source targets enforce the workspace runtime and sandbox/pointer-compression
|
||||
ABI. Release-pair targets enforce either the legacy or sandbox ABI plus
|
||||
Chromium's pinned runtime. Target CPU follows the named artifact. These V8
|
||||
settings are internal; callers do not pass separate V8 feature or libc++ flags.
|
||||
|
||||
Current pinned versions:
|
||||
|
||||
@@ -130,20 +133,25 @@ This depends on libc++'s shared exception-object ABI; updates to either libc++
|
||||
revision must keep the native GNU link/runtime checks passing. The Bazel pair targets above still point directly to source
|
||||
targets so a new release or canary never depends on an older published copy.
|
||||
|
||||
Native Windows x64 and ARM64 hosts can build sandbox archives with pinned
|
||||
clang-cl and the installed Microsoft SDK using
|
||||
Native Windows x64 and ARM64 hosts can build sandbox archives and matching
|
||||
Rust bindings with pinned clang-cl and the installed Microsoft SDK using
|
||||
`//third_party/v8:v8_152_2_0_x86_64_pc_windows_msvc_bazel` and
|
||||
`//third_party/v8:v8_152_2_0_aarch64_pc_windows_msvc_bazel`.
|
||||
`//third_party/v8:rusty_v8_native_windows_archive_for_target` selects these source
|
||||
outputs directly. These targets bundle Chromium libc++ and compiler builtins,
|
||||
and fix pointer compression and sandboxing to the published Windows contract.
|
||||
The owned engine policy also preserves the GN MSVC defaults for GC-managed
|
||||
microtask queues, random Wasm module generation, disabled imminent-deprecation
|
||||
warnings, and external TypedArray backing stores. Other source targets retain
|
||||
the published Unix policy, including a 64-byte inline TypedArray threshold.
|
||||
These are fixed platform choices, not additional developer build switches.
|
||||
Matching generated Rust bindings, consumer selection, and publishing integration
|
||||
are added separately; existing MSVC consumers continue using the prebuilt pair.
|
||||
The producer selectors `//third_party/v8:rusty_v8_native_windows_archive_for_target`
|
||||
and `//third_party/v8:rusty_v8_native_windows_binding_for_target` select source
|
||||
outputs directly. Both use the same sandbox, pointer compression, target CPU,
|
||||
and Chromium libc++ profile. The bindings use V8's compiled headers and defines
|
||||
so their sizes follow the archive, including CppGC members. Default MSVC
|
||||
consumers keep the published pair; `--//:rusty_v8_from_source=true` selects
|
||||
the newly built archive and bindings together.
|
||||
|
||||
The owned engine policy preserves the GN MSVC defaults for GC-managed microtask
|
||||
queues, random Wasm module generation, disabled imminent-deprecation warnings,
|
||||
and external TypedArray backing stores. Other source targets retain the published
|
||||
Unix policy, including a 64-byte inline TypedArray threshold. Generated Rust
|
||||
bindings use that same threshold; never pair a native 64-byte threshold with
|
||||
GN's size-zero binding constant. These are fixed platform choices, not additional
|
||||
developer build switches.
|
||||
|
||||
Use a native Visual Studio Developer PowerShell with the C++ tools and Windows
|
||||
SDK available. The SDK supplies headers, libraries, `dumpbin.exe`, and the
|
||||
@@ -152,7 +160,8 @@ assembler. From the repo root, build the archive for that host:
|
||||
```powershell
|
||||
bazel build --config=ci-windows-msvc `
|
||||
--host_platform=//:local_windows_msvc --platforms=//:local_windows_msvc `
|
||||
//third_party/v8:rusty_v8_native_windows_archive_for_target
|
||||
//third_party/v8:rusty_v8_native_windows_archive_for_target `
|
||||
//third_party/v8:rusty_v8_native_windows_binding_for_target
|
||||
```
|
||||
|
||||
Bazel fetches and verifies LLVM 22.1.8 for the host, the same major and patch
|
||||
|
||||
Vendored
+18
@@ -32,6 +32,24 @@ package(default_visibility = ["//visibility:public"])
|
||||
exports_files(["BUILD.bazel"])
|
||||
filegroup(name = "llvm-readobj", srcs = glob(["bin/llvm-readobj.exe"], allow_empty = True))
|
||||
filegroup(name = "llvm-lib", srcs = glob(["bin/llvm-lib.exe"], allow_empty = True))
|
||||
# Tool paths alone do not invalidate cached C++ actions when the pin changes.
|
||||
# Keep compiler resources and bundled runtime DLLs in the toolchain inputs.
|
||||
filegroup(
|
||||
name = "compiler_files",
|
||||
srcs = glob(["bin/clang-cl.exe", "bin/*.dll", "lib/clang/*/include/**"], allow_empty = True),
|
||||
)
|
||||
filegroup(
|
||||
name = "linker_files",
|
||||
srcs = glob(["bin/lld-link.exe", "bin/*.dll"], allow_empty = True),
|
||||
)
|
||||
filegroup(
|
||||
name = "archiver_files",
|
||||
srcs = glob(["bin/llvm-lib.exe", "bin/*.dll"], allow_empty = True),
|
||||
)
|
||||
filegroup(
|
||||
name = "all_files",
|
||||
srcs = [":compiler_files", ":linker_files", ":archiver_files"],
|
||||
)
|
||||
[
|
||||
filegroup(
|
||||
name = "builtins_" + arch,
|
||||
|
||||
Vendored
+5
-30
@@ -5,6 +5,11 @@ filegroup(
|
||||
srcs = ["src/binding.cc"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "binding_hpp",
|
||||
srcs = ["src/binding.hpp"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "crdtp_binding_cc",
|
||||
srcs = ["src/crdtp_binding.cc"],
|
||||
@@ -14,33 +19,3 @@ 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_x86_64_apple_darwin",
|
||||
srcs = ["gen/src_binding_release_x86_64-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"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_pc_windows_msvc",
|
||||
srcs = ["gen/src_binding_release_x86_64-pc-windows-msvc.rs"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_pc_windows_msvc",
|
||||
srcs = ["gen/src_binding_release_aarch64-pc-windows-msvc.rs"],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user