mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
V8 Bazel Build (#15021)
Alternative approach, we use rusty_v8 for all platforms that its predefined, but lets build from source a musl v8 version with bazel for x86 and aarch64 only. We would need to release this on github and then use the release.
This commit is contained in:
241
third_party/v8/BUILD.bazel
vendored
Normal file
241
third_party/v8/BUILD.bazel
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
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")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
V8_COPTS = ["-std=c++20"]
|
||||
|
||||
V8_STATIC_LIBRARY_FEATURES = [
|
||||
"-symbol_check",
|
||||
"-validate-static-library",
|
||||
]
|
||||
|
||||
genrule(
|
||||
name = "binding_cc",
|
||||
srcs = ["@v8_crate_146_4_0//:binding_cc"],
|
||||
outs = ["binding.cc"],
|
||||
cmd = """
|
||||
sed \
|
||||
-e '/#include "v8\\/src\\/flags\\/flags.h"/d' \
|
||||
-e 's|"v8/src/libplatform/default-platform.h"|"src/libplatform/default-platform.h"|' \
|
||||
-e 's| namespace i = v8::internal;| (void)usage;|' \
|
||||
-e '/using HelpOptions = i::FlagList::HelpOptions;/d' \
|
||||
-e '/HelpOptions help_options = HelpOptions(HelpOptions::kExit, usage);/d' \
|
||||
-e 's| i::FlagList::SetFlagsFromCommandLine(argc, argv, true, help_options);| v8::V8::SetFlagsFromCommandLine(argc, argv, true);|' \
|
||||
$(location @v8_crate_146_4_0//:binding_cc) > "$@"
|
||||
""",
|
||||
)
|
||||
|
||||
copy_file(
|
||||
name = "support_h",
|
||||
src = "@v8_crate_146_4_0//:support_h",
|
||||
out = "support.h",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "v8_146_4_0_binding",
|
||||
srcs = [":binding_cc"],
|
||||
hdrs = [":support_h"],
|
||||
copts = V8_COPTS,
|
||||
deps = [
|
||||
"@v8//:core_lib_icu",
|
||||
"@v8//:rusty_v8_internal_headers",
|
||||
],
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_x86_64_apple_darwin",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_aarch64_apple_darwin",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_aarch64_unknown_linux_gnu",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_x86_64_unknown_linux_gnu",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_aarch64_unknown_linux_musl_base",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "v8_146_4_0_aarch64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":v8_146_4_0_aarch64_unknown_linux_musl_base",
|
||||
"@llvm//runtimes/compiler-rt:clang_rt.builtins.static",
|
||||
],
|
||||
tools = [
|
||||
"@llvm//tools:llvm-ar",
|
||||
"@llvm//tools:llvm-ranlib",
|
||||
],
|
||||
outs = ["libv8_146_4_0_aarch64_unknown_linux_musl.a"],
|
||||
cmd = """
|
||||
cat > "$(@D)/merge.mri" <<'EOF'
|
||||
create $@
|
||||
addlib $(location :v8_146_4_0_aarch64_unknown_linux_musl_base)
|
||||
addlib $(location @llvm//runtimes/compiler-rt:clang_rt.builtins.static)
|
||||
save
|
||||
end
|
||||
EOF
|
||||
$(location @llvm//tools:llvm-ar) -M < "$(@D)/merge.mri"
|
||||
$(location @llvm//tools:llvm-ranlib) "$@"
|
||||
""",
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_x86_64_unknown_linux_musl",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_aarch64_pc_windows_msvc",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
cc_static_library(
|
||||
name = "v8_146_4_0_x86_64_pc_windows_msvc",
|
||||
deps = [":v8_146_4_0_binding"],
|
||||
features = V8_STATIC_LIBRARY_FEATURES,
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "v8_146_4_0_aarch64_pc_windows_gnullvm",
|
||||
actual = ":v8_146_4_0_aarch64_pc_windows_msvc",
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "v8_146_4_0_x86_64_pc_windows_gnullvm",
|
||||
actual = ":v8_146_4_0_x86_64_pc_windows_msvc",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_apple_darwin",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_x86_64_apple_darwin"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_apple_darwin",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_aarch64_apple_darwin"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_unknown_linux_gnu",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_aarch64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_unknown_linux_gnu",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_x86_64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_unknown_linux_musl",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_aarch64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_unknown_linux_musl",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_x86_64_unknown_linux_gnu"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_x86_64_pc_windows_msvc",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_x86_64_pc_windows_msvc"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_pc_windows_msvc",
|
||||
srcs = ["@v8_crate_146_4_0//:src_binding_release_aarch64_pc_windows_msvc"],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "src_binding_release_x86_64_pc_windows_gnullvm",
|
||||
actual = ":src_binding_release_x86_64_pc_windows_msvc",
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "src_binding_release_aarch64_pc_windows_gnullvm",
|
||||
actual = ":src_binding_release_aarch64_pc_windows_msvc",
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_aarch64_apple_darwin",
|
||||
srcs = [
|
||||
":v8_146_4_0_aarch64_apple_darwin",
|
||||
":src_binding_release_aarch64_apple_darwin",
|
||||
],
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_x86_64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":v8_146_4_0_x86_64_unknown_linux_musl",
|
||||
":src_binding_release_x86_64_unknown_linux_musl",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_aarch64_unknown_linux_musl",
|
||||
srcs = [
|
||||
":v8_146_4_0_aarch64_unknown_linux_musl",
|
||||
":src_binding_release_aarch64_unknown_linux_musl",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_x86_64_pc_windows_msvc",
|
||||
srcs = [
|
||||
":v8_146_4_0_x86_64_pc_windows_msvc",
|
||||
":src_binding_release_x86_64_pc_windows_msvc",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "rusty_v8_release_pair_aarch64_pc_windows_msvc",
|
||||
srcs = [
|
||||
":v8_146_4_0_aarch64_pc_windows_msvc",
|
||||
":src_binding_release_aarch64_pc_windows_msvc",
|
||||
],
|
||||
)
|
||||
45
third_party/v8/README.md
vendored
Normal file
45
third_party/v8/README.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# `rusty_v8` Release Artifacts
|
||||
|
||||
This directory contains the Bazel packaging used to build and stage
|
||||
target-specific `rusty_v8` release artifacts for Bazel-managed consumers.
|
||||
|
||||
Current pinned versions:
|
||||
|
||||
- Rust crate: `v8 = =146.4.0`
|
||||
- Embedded upstream V8 source: `14.6.202.9`
|
||||
|
||||
The generated release pairs include:
|
||||
|
||||
- `//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`
|
||||
- `//third_party/v8:rusty_v8_release_pair_x86_64_pc_windows_msvc`
|
||||
- `//third_party/v8:rusty_v8_release_pair_aarch64_pc_windows_msvc`
|
||||
|
||||
Each release pair contains:
|
||||
|
||||
- a static library built from source
|
||||
- a Rust binding file copied from the exact same `v8` crate version for that
|
||||
target
|
||||
|
||||
Do not mix artifacts across crate versions. The archive and binding must match
|
||||
the exact pinned `v8` crate version used by this repo.
|
||||
|
||||
The dedicated publishing workflow is:
|
||||
|
||||
- `.github/workflows/rusty-v8-release.yml`
|
||||
|
||||
That workflow currently stages musl artifacts:
|
||||
|
||||
- `librusty_v8_release_x86_64-unknown-linux-musl.a.gz`
|
||||
- `librusty_v8_release_aarch64-unknown-linux-musl.a.gz`
|
||||
- `src_binding_release_x86_64-unknown-linux-musl.rs`
|
||||
- `src_binding_release_aarch64-unknown-linux-musl.rs`
|
||||
|
||||
During musl staging, the produced static archive is merged with the target's
|
||||
LLVM `libc++` and `libc++abi` static runtime archives. Rust's musl toolchain
|
||||
already provides the matching `libunwind`, so staging does not bundle a second
|
||||
copy.
|
||||
41
third_party/v8/v8_crate.BUILD.bazel
vendored
Normal file
41
third_party/v8/v8_crate.BUILD.bazel
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "binding_cc",
|
||||
srcs = ["src/binding.cc"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "support_h",
|
||||
srcs = ["src/support.h"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_aarch64_apple_darwin",
|
||||
srcs = ["gen/src_binding_release_aarch64-apple-darwin.rs"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src_binding_release_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