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:
Sean Huang
2026-10-28 04:48:23 +00:00
committed by copyberry
parent 424916ee94
commit d63fe536ee
17 changed files with 727 additions and 175 deletions
+1 -1
View File
@@ -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,
)
+1
View File
@@ -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",
+25 -13
View File
@@ -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
+25 -13
View File
@@ -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