mirror of
https://github.com/openai/codex.git
synced 2026-10-19 16:17:49 +00:00
## What changed Add `third_party/v8/icu.BUILD.bazel` and wire V8's ICU repository to use it instead of patching upstream `bazel/BUILD.icu`. Select ICU's custom libc++ flags and runtime dependencies through `//third_party/v8:use_rusty_v8_custom_libcxx`, keeping ICU aligned with V8 and its host generators. GitOrigin-RevId: 92a1b883f5d42d9a3a464002e922295ab166f2bd
412 lines
14 KiB
Diff
412 lines
14 KiB
Diff
# What: adapt upstream V8 Bazel rules to this workspace's hermetic toolchains
|
|
# and externally provided dependencies.
|
|
# Scope: Bazel BUILD/defs integration only, including dependency
|
|
# wiring, generated sources, and visibility; no standalone V8 source patching.
|
|
|
|
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
|
|
@@ -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,12 +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"],
|
|
+ "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
|
|
}) + select({
|
|
":should_add_rdynamic": ["-rdynamic"],
|
|
"//conditions:default": [],
|
|
@@ -466,6 +501,11 @@
|
|
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 +523,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 +538,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 +557,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 +570,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/BUILD.bazel b/mod/v8-15.2.124.1/BUILD.bazel
|
|
--- a/orig/v8-15.2.124.1/BUILD.bazel
|
|
+++ b/mod/v8-15.2.124.1/BUILD.bazel
|
|
@@ -154,6 +154,10 @@
|
|
|
|
v8_flag(name = "v8_enable_v8_checks")
|
|
|
|
+v8_flag(name = "v8_enable_sandbox")
|
|
+
|
|
+v8_flag(name = "v8_use_rusty_v8_custom_libcxx")
|
|
+
|
|
v8_flag(name = "v8_enable_verify_csa")
|
|
|
|
v8_flag(name = "v8_enable_verify_heap")
|
|
@@ -319,7 +323,8 @@
|
|
# If no explicit value for v8_enable_pointer_compression, we set it to 'none'.
|
|
v8_string(
|
|
name = "v8_enable_pointer_compression",
|
|
- default = "none",
|
|
+ default = "False",
|
|
+ visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Default setting for v8_enable_pointer_compression.
|
|
@@ -520,6 +525,7 @@
|
|
"v8_enable_slow_dchecks": "ENABLE_SLOW_DCHECKS",
|
|
"v8_enable_runtime_call_stats": "V8_RUNTIME_CALL_STATS",
|
|
"v8_enable_snapshot_native_code_counters": "V8_SNAPSHOT_NATIVE_CODE_COUNTERS",
|
|
+ "v8_enable_sandbox": "V8_ENABLE_SANDBOX",
|
|
"v8_enable_trace_maps": "V8_TRACE_MAPS",
|
|
"v8_enable_turbofan": "V8_ENABLE_TURBOFAN",
|
|
"v8_enable_v8_checks": "V8_ENABLE_CHECKS",
|
|
@@ -4170,28 +4176,14 @@
|
|
}),
|
|
)
|
|
|
|
-v8_library(
|
|
- name = "lib_dragonbox",
|
|
- srcs = ["third_party/dragonbox/src/include/dragonbox/dragonbox.h"],
|
|
- hdrs = [
|
|
- "third_party/dragonbox/src/include/dragonbox/dragonbox.h",
|
|
- ],
|
|
- includes = [
|
|
- "third_party/dragonbox/src/include",
|
|
- ],
|
|
-)
|
|
-
|
|
-v8_library(
|
|
- name = "lib_fp16",
|
|
- srcs = ["third_party/fp16/src/include/fp16.h"],
|
|
- hdrs = [
|
|
- "third_party/fp16/src/include/fp16/fp16.h",
|
|
- "third_party/fp16/src/include/fp16/bitcasts.h",
|
|
- "third_party/fp16/src/include/fp16/macros.h",
|
|
- ],
|
|
- includes = [
|
|
- "third_party/fp16/src/include",
|
|
- ],
|
|
+alias(
|
|
+ name = "lib_dragonbox",
|
|
+ actual = "@dragonbox//:dragonbox",
|
|
+)
|
|
+
|
|
+alias(
|
|
+ name = "lib_fp16",
|
|
+ actual = "@fp16//:fp16",
|
|
)
|
|
|
|
filegroup(
|
|
@@ -4486,6 +4478,20 @@
|
|
srcs = [
|
|
"include/js_protocol.pdl",
|
|
"src/inspector/inspector_protocol_config.json",
|
|
+ "third_party/inspector_protocol/code_generator.py",
|
|
+ "third_party/inspector_protocol/pdl.py",
|
|
+ "third_party/inspector_protocol/lib/Forward_h.template",
|
|
+ "third_party/inspector_protocol/lib/Object_cpp.template",
|
|
+ "third_party/inspector_protocol/lib/Object_h.template",
|
|
+ "third_party/inspector_protocol/lib/Protocol_cpp.template",
|
|
+ "third_party/inspector_protocol/lib/ValueConversions_cpp.template",
|
|
+ "third_party/inspector_protocol/lib/ValueConversions_h.template",
|
|
+ "third_party/inspector_protocol/lib/Values_cpp.template",
|
|
+ "third_party/inspector_protocol/lib/Values_h.template",
|
|
+ "third_party/inspector_protocol/templates/Exported_h.template",
|
|
+ "third_party/inspector_protocol/templates/Imported_h.template",
|
|
+ "third_party/inspector_protocol/templates/TypeBuilder_cpp.template",
|
|
+ "third_party/inspector_protocol/templates/TypeBuilder_h.template",
|
|
],
|
|
outs = [
|
|
"include/inspector/Debugger.h",
|
|
@@ -4507,15 +4513,19 @@
|
|
"src/inspector/protocol/Schema.cpp",
|
|
"src/inspector/protocol/Schema.h",
|
|
],
|
|
- cmd = "$(location :code_generator) --jinja_dir . \
|
|
- --inspector_protocol_dir third_party/inspector_protocol \
|
|
+ cmd = "INSPECTOR_PROTOCOL_DIR=$$(dirname $(execpath third_party/inspector_protocol/code_generator.py)); \
|
|
+ PYTHONPATH=$$INSPECTOR_PROTOCOL_DIR:external/rules_python++pip+v8_python_deps_311_jinja2/site-packages:external/rules_python++pip+v8_python_deps_311_markupsafe/site-packages:$${PYTHONPATH-} \
|
|
+ $(execpath @rules_python//python/bin:python) $(execpath third_party/inspector_protocol/code_generator.py) --jinja_dir . \
|
|
+ --inspector_protocol_dir $$INSPECTOR_PROTOCOL_DIR \
|
|
--config $(location :src/inspector/inspector_protocol_config.json) \
|
|
--config_value protocol.path=$(location :include/js_protocol.pdl) \
|
|
+ --config_value crdtp.dir=third_party/inspector_protocol/crdtp \
|
|
--output_base $(@D)/src/inspector",
|
|
- local = 1,
|
|
message = "Generating inspector files",
|
|
tools = [
|
|
- ":code_generator",
|
|
+ "@rules_python//python/bin:python",
|
|
+ requirement("jinja2"),
|
|
+ requirement("markupsafe"),
|
|
],
|
|
)
|
|
|
|
@@ -4527,6 +4537,35 @@
|
|
":v8_libsampler_files",
|
|
":v8_shared_internal_headers",
|
|
],
|
|
+)
|
|
+
|
|
+cc_library(
|
|
+ name = "rusty_v8_internal_headers",
|
|
+ hdrs = [
|
|
+ "src/libplatform/default-platform.h",
|
|
+ ],
|
|
+ strip_include_prefix = "",
|
|
+ visibility = ["//visibility:public"],
|
|
+)
|
|
+
|
|
+cc_library(
|
|
+ name = "rusty_v8_crdtp_headers",
|
|
+ hdrs = [
|
|
+ "third_party/inspector_protocol/crdtp/cbor.h",
|
|
+ "third_party/inspector_protocol/crdtp/dispatch.h",
|
|
+ "third_party/inspector_protocol/crdtp/error_support.h",
|
|
+ "third_party/inspector_protocol/crdtp/export.h",
|
|
+ "third_party/inspector_protocol/crdtp/find_by_first.h",
|
|
+ "third_party/inspector_protocol/crdtp/frontend_channel.h",
|
|
+ "third_party/inspector_protocol/crdtp/json.h",
|
|
+ "third_party/inspector_protocol/crdtp/parser_handler.h",
|
|
+ "third_party/inspector_protocol/crdtp/protocol_core.h",
|
|
+ "third_party/inspector_protocol/crdtp/serializable.h",
|
|
+ "third_party/inspector_protocol/crdtp/span.h",
|
|
+ "third_party/inspector_protocol/crdtp/status.h",
|
|
+ ],
|
|
+ strip_include_prefix = "",
|
|
+ visibility = ["//visibility:public"],
|
|
)
|
|
|
|
filegroup(
|
|
@@ -4609,11 +4648,9 @@
|
|
strip_include_prefix = "noicu",
|
|
)
|
|
|
|
-cc_library(
|
|
+alias(
|
|
name = "llvm_libc_headers",
|
|
- hdrs = glob(["third_party/llvm-libc/src/shared/**/*.h"]),
|
|
- includes = ["third_party/llvm-libc/src"],
|
|
- defines = ["LIBC_NAMESPACE=__llvm_libc_cr"],
|
|
+ actual = "@@//third_party/v8:rusty_v8_llvm_libc_headers",
|
|
)
|
|
|
|
v8_library(
|
|
@@ -4660,16 +4697,9 @@
|
|
],
|
|
)
|
|
|
|
-cc_library(
|
|
- name = "simdutf",
|
|
- srcs = ["third_party/simdutf/simdutf.cpp"],
|
|
- hdrs = ["third_party/simdutf/simdutf.h"],
|
|
- copts = select({
|
|
- "@v8//bazel/config:is_clang": ["-std=c++20"],
|
|
- "@v8//bazel/config:is_gcc": ["-std=gnu++2a"],
|
|
- "@v8//bazel/config:is_windows": ["/std:c++20"],
|
|
- "//conditions:default": [],
|
|
- }),
|
|
+alias(
|
|
+ name = "simdutf",
|
|
+ actual = "@simdutf//:simdutf",
|
|
)
|
|
|
|
v8_library(
|
|
@@ -4686,7 +4716,7 @@
|
|
copts = ["-Wno-implicit-fallthrough"],
|
|
icu_deps = [
|
|
":icu/generated_torque_definitions_headers",
|
|
- "//external:icu",
|
|
+ "@icu//:icu",
|
|
],
|
|
icu_srcs = [
|
|
":generated_regexp_special_case",
|
|
@@ -4701,7 +4731,7 @@
|
|
],
|
|
deps = [
|
|
":lib_dragonbox",
|
|
- "//third_party/fast_float/src:fast_float",
|
|
+ "@fast_float//:fast_float",
|
|
":lib_fp16",
|
|
":simdutf",
|
|
":v8_libbase",
|
|
@@ -4757,6 +4787,7 @@
|
|
alias(
|
|
name = "core_lib_icu",
|
|
actual = "icu/v8",
|
|
+ visibility = ["//visibility:public"],
|
|
)
|
|
|
|
v8_library(
|
|
@@ -4808,7 +4839,7 @@
|
|
],
|
|
deps = [
|
|
":v8_libbase",
|
|
- "//external:icu",
|
|
+ "@icu//:icu",
|
|
],
|
|
)
|
|
|
|
@@ -4852,9 +4883,20 @@
|
|
":icu/generated_torque_initializers",
|
|
":icu/v8_initializers_files",
|
|
],
|
|
+ # Match GN's mksnapshot `disable_icf` config. If the linker folds distinct
|
|
+ # external-reference helpers together while producing the snapshot, the
|
|
+ # final embedder binary may not fold the same pair and startup
|
|
+ # deserialization will reject the snapshot.
|
|
+ # GN also increases the x64 Windows stack reserve because constructing the
|
|
+ # snapshot overflows the linker's 1 MiB default.
|
|
linkopts = select({
|
|
"@v8//bazel/config:is_android": ["-llog"],
|
|
- "//conditions:default": [],
|
|
+ "@v8//bazel/config:is_macos": ["-Wl,-no_deduplicate"],
|
|
+ "@v8//bazel/config:is_windows": [
|
|
+ "-Wl,/OPT:NOICF",
|
|
+ "-Wl,/STACK:2097152",
|
|
+ ],
|
|
+ "//conditions:default": ["-Wl,--icf=none"],
|
|
}),
|
|
noicu_deps = [":v8_libshared_noicu"],
|
|
noicu_srcs = [
|