mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## Why V8 source and release artifacts require different ABI and C++ runtime settings. Selecting a named artifact should also select its required settings, without callers coordinating separate sandbox, pointer compression, libc++, and CPU flags. ## What changed - Add Bazel transitions for `source`, `release`, and `sandbox_release` profiles. Source builds use the sandbox ABI and workspace runtime; release pairs use Chromium's pinned runtime with their respective ABI. - Select the V8 CPU from the artifact target and enforce matching target platform constraints. - Make the underlying V8 settings unavailable as CLI flags and remove redundant configuration from release tooling and workflows. - Select Darwin/Linux prebuilts solely through `rusty_v8_from_source`, keeping source archives and bindings paired when enabled. GitOrigin-RevId: f72fc06b6f74b79ab2ab8ca697e4f2006076a833
212 lines
7.7 KiB
Diff
212 lines
7.7 KiB
Diff
# What: adapt the pinned V8 rule helpers to Codex's engine configuration.
|
|
# Scope: bazel/defs.bzl and bazel/config/v8-target-cpu.bzl; the engine graph
|
|
# and dependency choices live in third_party/v8/engine.BUILD.bazel. ABI,
|
|
# runtime and CPU settings are internal outputs of artifact_profile.bzl.
|
|
# Preserve Chromium libc++ headers/runtime, Clang Windows driver flags, and
|
|
# the Windows target-ABI snapshot tool. The optional
|
|
# Linux backtrace link flag is omitted because that feature is fixed off.
|
|
# On a V8 pin change, review these hunks and build the native canary matrix.
|
|
|
|
diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bzl
|
|
--- a/orig/v8-15.2.124.1/bazel/defs.bzl
|
|
+++ b/mod/v8-15.2.124.1/bazel/defs.bzl
|
|
@@ -18,16 +18,16 @@
|
|
return FlagInfo(value = ctx.build_setting_value)
|
|
|
|
_create_option_flag = rule(
|
|
implementation = _options_impl,
|
|
- build_setting = config.bool(flag = True),
|
|
+ build_setting = config.bool(flag = False),
|
|
attrs = {
|
|
"scope": attr.string(),
|
|
},
|
|
)
|
|
|
|
_create_option_string = rule(
|
|
implementation = _options_impl,
|
|
- build_setting = config.string(flag = True),
|
|
+ build_setting = config.string(flag = False),
|
|
attrs = {
|
|
"scope": attr.string(),
|
|
},
|
|
@@ -42,12 +42,30 @@
|
|
)
|
|
|
|
def v8_flag(name, default = False):
|
|
- _create_option_flag(name = name, build_setting_default = default, scope = "universal")
|
|
- native.config_setting(name = "is_" + name, flag_values = {name: "True"})
|
|
- native.config_setting(name = "is_not_" + name, flag_values = {name: "False"})
|
|
-
|
|
-def v8_string(name, default = ""):
|
|
- _create_option_string(name = name, build_setting_default = default, scope = "universal")
|
|
+ _create_option_flag(
|
|
+ name = name,
|
|
+ build_setting_default = default,
|
|
+ scope = "universal",
|
|
+ visibility = ["//visibility:public"],
|
|
+ )
|
|
+ native.config_setting(
|
|
+ name = "is_" + name,
|
|
+ flag_values = {name: "True"},
|
|
+ visibility = ["//visibility:public"],
|
|
+ )
|
|
+ native.config_setting(
|
|
+ name = "is_not_" + name,
|
|
+ flag_values = {name: "False"},
|
|
+ visibility = ["//visibility:public"],
|
|
+ )
|
|
+
|
|
+def v8_string(name, default = "", visibility = None):
|
|
+ _create_option_string(
|
|
+ name = name,
|
|
+ build_setting_default = default,
|
|
+ scope = "universal",
|
|
+ visibility = visibility,
|
|
+ )
|
|
|
|
def v8_int(name, default = 0):
|
|
_create_option_int(name = name, build_setting_default = default, scope = "universal")
|
|
@@ -106,7 +124,13 @@
|
|
|
|
def _default_args():
|
|
return struct(
|
|
- deps = [":define_flags", "@libcxx//:libc++"],
|
|
+ deps = [":define_flags"] + select({
|
|
+ "@v8//:is_v8_use_rusty_v8_custom_libcxx": [
|
|
+ "@@//third_party/v8:rusty_v8_custom_libcxx_headers",
|
|
+ "@@//third_party/v8:rusty_v8_custom_libcxx_runtime",
|
|
+ ],
|
|
+ "//conditions:default": [],
|
|
+ }),
|
|
defines = select({
|
|
"@v8//bazel/config:is_windows": [
|
|
"UNICODE",
|
|
@@ -136,12 +160,15 @@
|
|
],
|
|
"//conditions:default": [],
|
|
}) + select({
|
|
- "@v8//bazel/config:is_clang": [
|
|
- "-Wno-invalid-offsetof",
|
|
- "-Wno-deprecated-this-capture",
|
|
- "-Wno-deprecated-declarations",
|
|
- "-std=c++20",
|
|
- ],
|
|
+ "@v8//:is_v8_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": [],
|
|
+ }) + select({
|
|
"@v8//bazel/config:is_gcc": [
|
|
"-Wno-extra",
|
|
"-Wno-array-bounds",
|
|
@@ -161,9 +188,17 @@
|
|
"-std=gnu++2a",
|
|
],
|
|
"@v8//bazel/config:is_windows": [
|
|
- "/std:c++20",
|
|
- ],
|
|
- "//conditions:default": [],
|
|
+ "-Wno-invalid-offsetof",
|
|
+ "-Wno-deprecated-this-capture",
|
|
+ "-Wno-deprecated-declarations",
|
|
+ "-std=c++20",
|
|
+ ],
|
|
+ "//conditions:default": [
|
|
+ "-Wno-invalid-offsetof",
|
|
+ "-Wno-deprecated-this-capture",
|
|
+ "-Wno-deprecated-declarations",
|
|
+ "-std=c++20",
|
|
+ ],
|
|
}) + select({
|
|
"@v8//bazel/config:is_gcc_fastbuild": [
|
|
# Non-debug builds without optimizations fail because
|
|
@@ -187,15 +222,12 @@
|
|
includes = ["include"],
|
|
linkopts = select({
|
|
"@v8//bazel/config:is_windows": [
|
|
- "Winmm.lib",
|
|
- "DbgHelp.lib",
|
|
- "Advapi32.lib",
|
|
+ "-lwinmm",
|
|
+ "-ldbghelp",
|
|
+ "-ladvapi32",
|
|
],
|
|
"@v8//bazel/config:is_macos": ["-pthread"],
|
|
- "//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"],
|
|
- }) + select({
|
|
- ":should_add_rdynamic": ["-rdynamic"],
|
|
- "//conditions:default": [],
|
|
+ "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
|
|
}),
|
|
)
|
|
|
|
@@ -466,6 +498,12 @@
|
|
def _mksnapshot(ctx):
|
|
prefix = ctx.attr.prefix
|
|
suffix = ctx.attr.suffix
|
|
+
|
|
+ # Windows cross-builds use Linux for the exec configuration, but the
|
|
+ # snapshot generator must match the target ABI and run on the Windows
|
|
+ # runner. Action strategies only choose where an action runs; they cannot
|
|
+ # change this executable from the exec to the target configuration.
|
|
+ tool = ctx.executable.target_tool if ctx.attr.target_os == "win" else ctx.executable.tool
|
|
outs = [
|
|
ctx.actions.declare_file(prefix + "/snapshot" + suffix + ".cc"),
|
|
ctx.actions.declare_file(prefix + "/embedded" + suffix + ".S"),
|
|
@@ -483,7 +521,7 @@
|
|
"--embedded_src",
|
|
outs[1].path,
|
|
] + ctx.attr.args,
|
|
- executable = ctx.executable.tool,
|
|
+ executable = tool,
|
|
progress_message = "Running mksnapshot",
|
|
)
|
|
return [DefaultInfo(files = depset(outs))]
|
|
@@ -498,6 +536,12 @@
|
|
executable = True,
|
|
cfg = "exec",
|
|
),
|
|
+ "target_tool": attr.label(
|
|
+ mandatory = True,
|
|
+ allow_files = True,
|
|
+ executable = True,
|
|
+ cfg = "target",
|
|
+ ),
|
|
"target_os": attr.string(mandatory = True),
|
|
"prefix": attr.string(mandatory = True),
|
|
"suffix": attr.string(mandatory = True),
|
|
@@ -511,6 +555,7 @@
|
|
args = args,
|
|
prefix = "noicu",
|
|
tool = ":noicu/mksnapshot" + suffix,
|
|
+ target_tool = ":noicu/mksnapshot" + suffix,
|
|
suffix = suffix,
|
|
target_os = select({
|
|
"@v8//bazel/config:is_macos": "mac",
|
|
@@ -523,6 +568,7 @@
|
|
args = args,
|
|
prefix = "icu",
|
|
tool = ":icu/mksnapshot" + suffix,
|
|
+ target_tool = ":icu/mksnapshot" + suffix,
|
|
suffix = suffix,
|
|
target_os = select({
|
|
"@v8//bazel/config:is_macos": "mac",
|
|
diff --git a/orig/v8-15.2.124.1/bazel/config/v8-target-cpu.bzl b/mod/v8-15.2.124.1/bazel/config/v8-target-cpu.bzl
|
|
--- a/orig/v8-15.2.124.1/bazel/config/v8-target-cpu.bzl
|
|
+++ b/mod/v8-15.2.124.1/bazel/config/v8-target-cpu.bzl
|
|
@@ -24,8 +24,8 @@
|
|
|
|
v8_target_cpu = rule(
|
|
implementation = _host_target_cpu_impl,
|
|
- build_setting = config.string(flag = True),
|
|
- doc = "CPU that V8 will generate code for.",
|
|
+ build_setting = config.string(flag = False),
|
|
+ doc = "Internal CPU that V8 generates code for; set by the artifact transition.",
|
|
attrs = {
|
|
"scope": attr.string(),
|
|
},
|