bazel: build rusty_v8 release artifacts hermetically

This commit is contained in:
Channing Conger
2026-05-12 04:12:32 +00:00
parent 7b5a9e84d0
commit 0cbb0b258d
17 changed files with 917 additions and 601 deletions
+75 -44
View File
@@ -22,6 +22,13 @@ config_setting(
],
)
config_setting(
name = "use_rusty_v8_custom_libcxx",
flag_values = {
"@v8//:v8_use_rusty_v8_custom_libcxx": "True",
},
)
alias(
name = "v8_146_4_0_x86_64_apple_darwin",
actual = "@rusty_v8_146_4_0_x86_64_apple_darwin_archive//file",
@@ -165,11 +172,40 @@ alias(
V8_COPTS = ["-std=c++20"]
V8_CUSTOM_LIBCXX_COPTS = select({
":use_rusty_v8_custom_libcxx": [
"-nostdinc++",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"-D_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
],
"//conditions:default": [],
})
V8_STATIC_LIBRARY_FEATURES = [
"-symbol_check",
"-validate-static-library",
]
cc_library(
name = "rusty_v8_custom_libcxx_headers",
deps = [
"@rusty_v8_libcxx//:headers",
"@rusty_v8_libcxxabi//:headers",
],
visibility = ["//visibility:public"],
)
cc_library(
name = "rusty_v8_custom_libcxx_runtime",
deps = [
"@rusty_v8_libcxx//:libcxx",
"@rusty_v8_libcxxabi//:libcxxabi",
],
visibility = ["//visibility:public"],
)
genrule(
name = "binding_cc",
srcs = ["@v8_crate_146_4_0//:binding_cc"],
@@ -239,11 +275,16 @@ cc_library(
name = "v8_147_4_0_binding",
srcs = [":binding_cc_147_4_0"],
hdrs = [":support_h_147_4_0"],
copts = V8_COPTS,
copts = V8_COPTS + V8_CUSTOM_LIBCXX_COPTS,
deps = [
"@v8//:core_lib_icu",
"@v8//:rusty_v8_internal_headers",
],
] + select({
":use_rusty_v8_custom_libcxx": [
":rusty_v8_custom_libcxx_headers",
],
"//conditions:default": [],
}),
)
cc_static_library(
@@ -330,19 +371,28 @@ filegroup(
cc_static_library(
name = "v8_147_4_0_aarch64_apple_darwin_bazel",
deps = [":v8_147_4_0_binding"],
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_147_4_0_binding",
],
features = V8_STATIC_LIBRARY_FEATURES,
)
cc_static_library(
name = "v8_147_4_0_aarch64_unknown_linux_gnu_bazel",
deps = [":v8_147_4_0_binding"],
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_147_4_0_binding",
],
features = V8_STATIC_LIBRARY_FEATURES,
)
cc_static_library(
name = "v8_147_4_0_aarch64_unknown_linux_musl_release_base",
deps = [":v8_147_4_0_binding"],
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_147_4_0_binding",
],
features = V8_STATIC_LIBRARY_FEATURES,
)
@@ -372,31 +422,28 @@ EOF
cc_static_library(
name = "v8_147_4_0_x86_64_apple_darwin_bazel",
deps = [":v8_147_4_0_binding"],
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_147_4_0_binding",
],
features = V8_STATIC_LIBRARY_FEATURES,
)
cc_static_library(
name = "v8_147_4_0_x86_64_unknown_linux_gnu_bazel",
deps = [":v8_147_4_0_binding"],
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_147_4_0_binding",
],
features = V8_STATIC_LIBRARY_FEATURES,
)
cc_static_library(
name = "v8_147_4_0_x86_64_unknown_linux_musl_release",
deps = [":v8_147_4_0_binding"],
features = V8_STATIC_LIBRARY_FEATURES,
)
cc_static_library(
name = "v8_147_4_0_aarch64_pc_windows_msvc_bazel",
deps = [":v8_147_4_0_binding"],
features = V8_STATIC_LIBRARY_FEATURES,
)
cc_static_library(
name = "v8_147_4_0_x86_64_pc_windows_msvc_bazel",
deps = [":v8_147_4_0_binding"],
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_147_4_0_binding",
],
features = V8_STATIC_LIBRARY_FEATURES,
)
@@ -443,32 +490,32 @@ filegroup(
filegroup(
name = "rusty_v8_release_pair_x86_64_apple_darwin",
srcs = [
":v8_146_4_0_x86_64_apple_darwin",
":src_binding_release_x86_64_apple_darwin",
":v8_147_4_0_x86_64_apple_darwin_bazel",
":src_binding_release_x86_64_apple_darwin_147_4_0_release",
],
)
filegroup(
name = "rusty_v8_release_pair_aarch64_apple_darwin",
srcs = [
":v8_146_4_0_aarch64_apple_darwin",
":src_binding_release_aarch64_apple_darwin",
":v8_147_4_0_aarch64_apple_darwin_bazel",
":src_binding_release_aarch64_apple_darwin_147_4_0_release",
],
)
filegroup(
name = "rusty_v8_release_pair_x86_64_unknown_linux_gnu",
srcs = [
":v8_146_4_0_x86_64_unknown_linux_gnu",
":src_binding_release_x86_64_unknown_linux_gnu",
":v8_147_4_0_x86_64_unknown_linux_gnu_bazel",
":src_binding_release_x86_64_unknown_linux_gnu_147_4_0_release",
],
)
filegroup(
name = "rusty_v8_release_pair_aarch64_unknown_linux_gnu",
srcs = [
":v8_146_4_0_aarch64_unknown_linux_gnu",
":src_binding_release_aarch64_unknown_linux_gnu",
":v8_147_4_0_aarch64_unknown_linux_gnu_bazel",
":src_binding_release_aarch64_unknown_linux_gnu_147_4_0_release",
],
)
@@ -551,19 +598,3 @@ filegroup(
":src_binding_release_aarch64_unknown_linux_musl_147_4_0_release",
],
)
filegroup(
name = "rusty_v8_sandbox_release_pair_x86_64_pc_windows_msvc",
srcs = [
":v8_147_4_0_x86_64_pc_windows_msvc_bazel",
":src_binding_release_x86_64_pc_windows_msvc_147_4_0_release",
],
)
filegroup(
name = "rusty_v8_sandbox_release_pair_aarch64_pc_windows_msvc",
srcs = [
":v8_147_4_0_aarch64_pc_windows_msvc_bazel",
":src_binding_release_aarch64_pc_windows_msvc_147_4_0_release",
],
)
+19 -16
View File
@@ -21,7 +21,7 @@ artifact contract.
Current pinned versions:
- Rust crate: `v8 = =147.4.0`
- Embedded upstream V8 source for musl release builds: `14.7.173.20`
- Embedded upstream V8 source for Bazel-produced release builds: `14.7.173.20`
When bumping the Rust crate version, keep the checked-in checksum manifest and
`MODULE.bazel` in sync:
@@ -40,7 +40,7 @@ The consumer-facing selectors are:
- `//third_party/v8:rusty_v8_archive_for_target`
- `//third_party/v8:rusty_v8_binding_for_target`
Current musl release assets are expected at the tag:
Published release assets are expected at the tag:
- `rusty-v8-v<crate_version>`
@@ -57,12 +57,12 @@ their raw names:
- `src_binding_ptrcomp_sandbox_release_<target>.rs`
The dedicated publishing workflow is `.github/workflows/rusty-v8-release.yml`.
For GNU Linux, Darwin, and Windows MSVC, the workflow checks out the exact
upstream `denoland/rusty_v8` tag and uses its `V8_FROM_SOURCE=true` Cargo/GN
build to produce sandbox-profile artifacts with the same archive shape upstream
publishes. Musl remains an extra platform that upstream does not publish, so
tagged runs still build the current musl release pairs with our Bazel producer:
Tagged runs build release artifacts from the Bazel graph itself:
- `//third_party/v8:rusty_v8_release_pair_x86_64_apple_darwin`
- `//third_party/v8:rusty_v8_release_pair_aarch64_apple_darwin`
- `//third_party/v8:rusty_v8_release_pair_x86_64_unknown_linux_gnu`
- `//third_party/v8:rusty_v8_release_pair_aarch64_unknown_linux_gnu`
- `//third_party/v8:rusty_v8_release_pair_x86_64_unknown_linux_musl`
- `//third_party/v8:rusty_v8_release_pair_aarch64_unknown_linux_musl`
@@ -74,16 +74,19 @@ The same run also builds the matching sandbox pair targets:
- `//third_party/v8:rusty_v8_sandbox_release_pair_aarch64_unknown_linux_gnu`
- `//third_party/v8:rusty_v8_sandbox_release_pair_x86_64_unknown_linux_musl`
- `//third_party/v8:rusty_v8_sandbox_release_pair_aarch64_unknown_linux_musl`
- `//third_party/v8:rusty_v8_sandbox_release_pair_x86_64_pc_windows_msvc`
- `//third_party/v8:rusty_v8_sandbox_release_pair_aarch64_pc_windows_msvc`
If a tagged run targets an existing GitHub release, publication amends only the
sandbox-profile files and leaves the current release-profile assets unchanged.
The upstream-shaped GNU, Darwin, and MSVC builds let GN fold custom libc++ into
the final archive the same way `rusty_v8` does for its own releases. Musl
sandbox archives still merge the matching static libc++ and libc++abi runtime
libraries after the Bazel build so Cargo consumers can link them with the `v8`
crate's default `use_custom_libcxx` feature.
The Bazel graph pins the same libc++, libc++abi, and llvm-libc source revisions
used by `rusty_v8 v147.4.0`, compiles published artifact targets with
`--config=rusty-v8-upstream-libcxx`, and folds the matching runtime objects into
the final static archive so Cargo consumers can link it with the `v8` crate's
default `use_custom_libcxx` feature. The config keeps the object files and the
bundled runtime on Chromium's `std::__Cr` ABI namespace instead of mixing those
objects with the toolchain libc++ default namespace.
MSVC is not part of the Bazel-produced matrix yet. The repository's current
hermetic Windows C++ platform is `windows-gnullvm`/`x86_64-w64-windows-gnu`, so
it cannot truthfully reproduce upstream's `*-pc-windows-msvc` archives until we
add a real MSVC-targeting C++ toolchain to the Bazel graph.
Cargo musl builds use `RUSTY_V8_ARCHIVE` plus a downloaded
`RUSTY_V8_SRC_BINDING_PATH` to point at those `openai/codex` release assets
+157
View File
@@ -0,0 +1,157 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@llvm//toolchain/runtimes:cc_runtime_library.bzl", "cc_runtime_stage0_library")
package(default_visibility = ["//visibility:public"])
config_setting(
name = "is_linux",
constraint_values = ["@platforms//os:linux"],
)
config_setting(
name = "is_windows",
constraint_values = ["@platforms//os:windows"],
)
LIBCXX_SRCS = [
"src/algorithm.cpp",
"src/any.cpp",
"src/atomic.cpp",
"src/barrier.cpp",
"src/bind.cpp",
"src/call_once.cpp",
"src/charconv.cpp",
"src/chrono.cpp",
"src/condition_variable.cpp",
"src/condition_variable_destructor.cpp",
"src/error_category.cpp",
"src/exception.cpp",
"src/filesystem/directory_iterator.cpp",
"src/filesystem/filesystem_error.cpp",
"src/filesystem/operations.cpp",
"src/filesystem/path.cpp",
"src/functional.cpp",
"src/future.cpp",
"src/hash.cpp",
"src/ios.cpp",
"src/ios.instantiations.cpp",
"src/iostream.cpp",
"src/locale.cpp",
"src/memory.cpp",
"src/mutex.cpp",
"src/mutex_destructor.cpp",
"src/new.cpp",
"src/new_handler.cpp",
"src/new_helpers.cpp",
"src/optional.cpp",
"src/random.cpp",
"src/random_shuffle.cpp",
"src/regex.cpp",
"src/ryu/d2fixed.cpp",
"src/ryu/d2s.cpp",
"src/ryu/f2s.cpp",
"src/shared_mutex.cpp",
"src/stdexcept.cpp",
"src/string.cpp",
"src/strstream.cpp",
"src/system_error.cpp",
"src/thread.cpp",
"src/typeinfo.cpp",
"src/valarray.cpp",
"src/variant.cpp",
"src/vector.cpp",
"src/verbose_abort.cpp",
]
cc_library(
name = "headers",
hdrs = glob(["include/**"]),
includes = ["include"],
deps = ["@//third_party/v8/libcxx_config:headers"],
)
cc_library(
name = "internal_headers",
hdrs = glob([
"src/**/*.h",
"src/**/*.ipp",
]),
includes = ["src"],
)
cc_runtime_stage0_library(
name = "libcxx",
srcs = LIBCXX_SRCS + select({
":is_linux": [
"src/filesystem/directory_entry.cpp",
"src/filesystem/filesystem_clock.cpp",
],
"//conditions:default": [],
}) + select({
":is_windows": [
"src/support/win32/locale_win32.cpp",
"src/support/win32/support.cpp",
"src/support/win32/thread_win32.cpp",
],
"//conditions:default": [],
}),
copts = [
"-fexceptions",
"-frtti",
"-fstrict-aliasing",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-nostdinc++",
"-std=c++23",
"-Wno-nullability-completeness",
"-Wno-unused-parameter",
"-Wundef",
] + select({
":is_windows": ["-Wno-macro-redefined"],
"//conditions:default": ["-fPIC"],
}),
defines = [
"CR_LIBCXX_REVISION=7ab65651aed6802d2599dcb7a73b1f82d5179d05",
"LIBCXX_BUILDING_LIBCXXABI",
"LIBC_NAMESPACE=__llvm_libc_cr",
"_LIBCPP_BUILDING_LIBRARY",
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
"_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
] + select({
"@llvm//platforms/config:musl": [
# Chromium's checked-in __config_site uses this switch to enable
# libc++'s musl-specific configuration.
"ANDROID_HOST_MUSL",
],
"//conditions:default": [],
}) + select({
":is_windows": [
"NTDDI_VERSION=NTDDI_WIN7",
"WINVER=_WIN32_WINNT_WIN7",
"_WIN32_WINNT=_WIN32_WINNT_WIN7",
],
"//conditions:default": [],
}),
includes = ["src"],
implementation_deps = [
":headers",
":internal_headers",
"@rusty_v8_libcxxabi//:headers",
"@rusty_v8_llvm_libc//:headers",
] + select({
":is_linux": [
"@@llvm++kernel_headers+kernel_headers//:kernel_headers",
],
"//conditions:default": [],
}) + select({
"@llvm//platforms/config:gnu": [
"@@llvm++glibc+glibc//:gnu_libc_headers",
],
"@llvm//platforms/config:musl": [
"@@llvm++musl+musl_libc//:musl_libc_headers",
],
"//conditions:default": [],
}),
)
+12
View File
@@ -0,0 +1,12 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "headers",
hdrs = [
"__assertion_handler",
"__config_site",
],
includes = ["."],
)
+27
View File
@@ -0,0 +1,27 @@
// -*- C++ -*-
#ifndef _LIBCPP___ASSERTION_HANDLER
#define _LIBCPP___ASSERTION_HANDLER
#include <__config>
#include <__verbose_abort>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#if defined(OFFICIAL_BUILD) && !defined(DCHECK_ALWAYS_ON)
[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __libcpp_hardening_failure() {
__builtin_trap();
}
#define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __libcpp_hardening_failure())
#else
#define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)
#endif
#endif // _LIBCPP___ASSERTION_HANDLER
+55
View File
@@ -0,0 +1,55 @@
#ifndef _LIBCPP_CONFIG_SITE
#define _LIBCPP_CONFIG_SITE
#define _LIBCPP_ABI_NAMESPACE __Cr
#define _LIBCPP_ABI_VERSION 2
#define _LIBCPP_ABI_FORCE_ITANIUM 0
#define _LIBCPP_ABI_FORCE_MICROSOFT 0
#define _LIBCPP_HAS_THREADS 1
#define _LIBCPP_HAS_MONOTONIC_CLOCK 1
#define _LIBCPP_HAS_TERMINAL 1
#ifdef ANDROID_HOST_MUSL
#define _LIBCPP_HAS_MUSL_LIBC 1
#else
#define _LIBCPP_HAS_MUSL_LIBC 0
#endif
#ifdef _WIN32
#define _LIBCPP_HAS_THREAD_API_PTHREAD 0
#define _LIBCPP_HAS_THREAD_API_EXTERNAL 0
#define _LIBCPP_HAS_THREAD_API_WIN32 1
#else
#define _LIBCPP_HAS_THREAD_API_PTHREAD 1
#define _LIBCPP_HAS_THREAD_API_EXTERNAL 0
#define _LIBCPP_HAS_THREAD_API_WIN32 0
#endif
#define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0
#define _LIBCPP_HAS_FILESYSTEM 1
#define _LIBCPP_HAS_RANDOM_DEVICE 1
#define _LIBCPP_HAS_LOCALIZATION 1
#define _LIBCPP_HAS_UNICODE 1
#define _LIBCPP_HAS_WIDE_CHARACTERS 1
#define _LIBCPP_HAS_TIME_ZONE_DATABASE 1
#if defined(__APPLE__)
#define _LIBCPP_PSTL_BACKEND_LIBDISPATCH
#else
#define _LIBCPP_PSTL_BACKEND_STD_THREAD
#endif
#define _LIBCPP_ASSERTION_SEMANTIC_DEFAULT \
_LIBCPP_ASSERTION_SEMANTIC_HARDENING_DEPENDENT
#define _LIBCPP_LIBC_PICOLIBC 0
#define _LIBCPP_LIBC_NEWLIB 0
#define _LIBCPP_NO_AUTO_LINK
#define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
#define _LIBCPP_NO_ABI_TAG
#define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)
#define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
#endif // _LIBCPP_CONFIG_SITE
+98
View File
@@ -0,0 +1,98 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@llvm//toolchain/runtimes:cc_runtime_library.bzl", "cc_runtime_stage0_library")
package(default_visibility = ["//visibility:public"])
config_setting(
name = "is_linux",
constraint_values = ["@platforms//os:linux"],
)
config_setting(
name = "is_windows",
constraint_values = ["@platforms//os:windows"],
)
cc_library(
name = "headers",
hdrs = glob(["include/**"]),
includes = ["include"],
)
cc_runtime_stage0_library(
name = "libcxxabi",
srcs = [
"src/abort_message.cpp",
"src/cxa_aux_runtime.cpp",
"src/cxa_default_handlers.cpp",
"src/cxa_demangle.cpp",
"src/cxa_exception.cpp",
"src/cxa_exception_storage.cpp",
"src/cxa_guard.cpp",
"src/cxa_handlers.cpp",
"src/cxa_personality.cpp",
"src/cxa_vector.cpp",
"src/cxa_virtual.cpp",
"src/fallback_malloc.cpp",
"src/private_typeinfo.cpp",
"src/stdlib_exception.cpp",
"src/stdlib_stdexcept.cpp",
"src/stdlib_typeinfo.cpp",
] + select({
":is_linux": ["src/cxa_thread_atexit.cpp"],
"//conditions:default": [],
}),
textual_hdrs = glob([
"src/**/*.def",
"src/**/*.h",
"src/**/*.inc",
]),
copts = [
"-fexceptions",
"-frtti",
"-fstrict-aliasing",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-nostdinc++",
"-std=c++23",
"-Wno-nullability-completeness",
"-Wno-unused-parameter",
"-Wundef",
] + select({
":is_windows": ["-Wno-macro-redefined"],
"//conditions:default": ["-fPIC"],
}),
defines = [
"LIBCXXABI_SILENT_TERMINATE",
"_LIBCPP_BUILDING_LIBRARY",
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
"_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
] + select({
"@llvm//platforms/config:musl": [
"ANDROID_HOST_MUSL",
],
"//conditions:default": [],
}),
includes = ["src"],
implementation_deps = [
":headers",
"@rusty_v8_libcxx//:headers",
"@rusty_v8_libcxx//:internal_headers",
"@//third_party/v8/libcxx_config:headers",
] + select({
":is_linux": [
"@@llvm++kernel_headers+kernel_headers//:kernel_headers",
],
"//conditions:default": [],
}) + select({
"@llvm//platforms/config:gnu": [
"@@llvm++glibc+glibc//:gnu_libc_headers",
],
"@llvm//platforms/config:musl": [
"@@llvm++musl+musl_libc//:musl_libc_headers",
],
"//conditions:default": [],
}),
)
+10
View File
@@ -0,0 +1,10 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "headers",
hdrs = glob(["**/*.h"]),
defines = ["LIBC_NAMESPACE=__llvm_libc_cr"],
includes = ["."],
)