Move V8's ICU Bazel rules into the workspace (#54710)

## 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
This commit is contained in:
Sean Huang
2026-10-16 21:30:24 +00:00
committed by copyberry
parent b9775a0d57
commit 3076caafdf
4 changed files with 117 additions and 103 deletions
+1 -102
View File
@@ -1,6 +1,6 @@
# What: adapt upstream V8 Bazel rules to this workspace's hermetic toolchains
# and externally provided dependencies.
# Scope: Bazel BUILD/defs/BUILD.icu integration only, including dependency
# 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
@@ -409,104 +409,3 @@ diff --git a/orig/v8-15.2.124.1/BUILD.bazel b/mod/v8-15.2.124.1/BUILD.bazel
}),
noicu_deps = [":v8_libshared_noicu"],
noicu_srcs = [
diff --git a/orig/v8-15.2.124.1/bazel/BUILD.icu b/mod/v8-15.2.124.1/bazel/BUILD.icu
--- a/orig/v8-15.2.124.1/bazel/BUILD.icu
+++ b/mod/v8-15.2.124.1/bazel/BUILD.icu
@@ -1,3 +1,24 @@
+load("@rules_cc//cc:defs.bzl", "cc_library")
+
+CUSTOM_LIBCXX_COPTS = select({
+ "@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": [],
+})
+
+CUSTOM_LIBCXX_DEPS = 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": [],
+})
+
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -16,15 +37,12 @@
]),
copts = select({
"@platforms//os:windows": [
- "/wd4005", # Macro redefinition.
- "/wd4068", # Unknown pragmas.
- "/wd4267", # Conversion from size_t on 64-bits.
- "/utf-8", # ICU source files are in UTF-8.
+ "-Wno-deprecated-declarations",
],
"//conditions:default": [
"-Wno-deprecated-declarations",
],
- }),
+ }) + CUSTOM_LIBCXX_COPTS,
data = [":icudata"],
defines = [
"HAVE_DLOPEN=0",
@@ -54,6 +72,7 @@
"U_ICUDATAENTRY_IN_COMMON",
],
tags = ["requires-rtti"],
+ deps = CUSTOM_LIBCXX_DEPS,
alwayslink = 1,
)
@@ -65,19 +84,16 @@
]),
copts = select({
"@platforms//os:windows": [
- "/wd4005", # Macro redefinition.
- "/wd4068", # Unknown pragmas.
- "/wd4267", # Conversion from size_t on 64-bits.
- "/utf-8", # ICU source files are in UTF-8.
+ "-Wno-deprecated-declarations",
],
"//conditions:default": [
"-Wno-deprecated-declarations",
],
- }),
+ }) + CUSTOM_LIBCXX_COPTS,
local_defines = [
"U_I18N_IMPLEMENTATION",
],
- deps = [":icuuc"],
+ deps = [":icuuc"] + CUSTOM_LIBCXX_DEPS,
alwayslink = 1,
)
@@ -93,13 +109,10 @@
]),
copts = select({
"@platforms//os:windows": [
- "/wd4005", # Macro redefinition.
- "/wd4068", # Unknown pragmas.
- "/wd4267", # Conversion from size_t on 64-bits.
- "/utf-8", # ICU source files are in UTF-8.
+ "-Wno-deprecated-declarations",
],
"//conditions:default": [],
- }),
+ }) + CUSTOM_LIBCXX_COPTS,
include_prefix = "third_party/icu",
local_defines = [
"U_COMMON_IMPLEMENTATION",
@@ -108,6 +121,6 @@
deps = [
":icui18n",
":icuuc",
- ],
+ ] + CUSTOM_LIBCXX_DEPS,
alwayslink = 1,
)
+1 -1
View File
@@ -27,7 +27,7 @@ diff --git a/orig/v8-15.2.124.1/MODULE.bazel b/mod/v8-15.2.124.1/MODULE.bazel
+
+git_repository(
+ name = "icu",
+ build_file = "@v8//:bazel/BUILD.icu",
+ build_file = "@@//third_party/v8:icu.BUILD.bazel",
+ commit = "d578f2e8b7bd5938e21cfb6bf15c079e0aa5b738",
+ patch_cmds = ["find source -name BUILD.bazel | xargs rm"],
+ patch_cmds_win = ["Get-ChildItem -Path source -File -Include BUILD.bazel -Recurse | Remove-Item"],
+2
View File
@@ -4,6 +4,8 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
exports_files(["icu.BUILD.bazel"])
config_setting(
name = "platform_aarch64_unknown_linux_musl",
constraint_values = [
+113
View File
@@ -0,0 +1,113 @@
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("@rules_cc//cc:defs.bzl", "cc_library")
# ICU must use the same C++ runtime as the V8 artifact and its host generators.
_ICU_V8_COPTS = select({
"@@//third_party/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": [],
})
_ICU_V8_RUNTIME_DEPS = select({
"@@//third_party/v8:use_rusty_v8_custom_libcxx": [
"@@//third_party/v8:rusty_v8_custom_libcxx_headers",
"@@//third_party/v8:rusty_v8_custom_libcxx_runtime",
],
"//conditions:default": [],
})
filegroup(
name = "icudata",
srcs = ["common/icudtl.dat"],
visibility = ["//visibility:public"],
)
cc_library(
name = "icuuc",
srcs = glob([
"source/common/**/*.h",
"source/common/**/*.cpp",
]),
copts = ["-Wno-deprecated-declarations"] + _ICU_V8_COPTS,
data = [":icudata"],
defines = [
"HAVE_DLOPEN=0",
"UCONFIG_ONLY_HTML_CONVERSION=1",
"U_CHARSET_IS_UTF8=1",
"U_USING_ICU_NAMESPACE=0",
"U_ENABLE_DYLOAD=0",
"USE_CHROMIUM_ICU=1",
"U_ENABLE_TRACING=1",
"U_ENABLE_RESOURCE_TRACING=0",
"UNISTR_FROM_STRING_EXPLICIT=",
"UNISTR_FROM_CHAR_EXPLICIT=",
] + select({
"@platforms//os:windows": [
"U_STATIC_IMPLEMENTATION",
"UNICODE",
"_UNICODE",
],
"//conditions:default": [],
}),
includes = [
"source/common",
"source/i18n",
],
local_defines = [
"U_COMMON_IMPLEMENTATION",
"U_ICUDATAENTRY_IN_COMMON",
],
tags = ["requires-rtti"],
deps = _ICU_V8_RUNTIME_DEPS,
alwayslink = 1,
)
cc_library(
name = "icui18n",
srcs = glob([
"source/i18n/**/*.h",
"source/i18n/**/*.cpp",
]),
copts = ["-Wno-deprecated-declarations"] + _ICU_V8_COPTS,
local_defines = [
"U_I18N_IMPLEMENTATION",
],
deps = [":icuuc"] + _ICU_V8_RUNTIME_DEPS,
alwayslink = 1,
)
cc_library(
name = "icu",
srcs = [
"source/stubdata/stubdata.cpp",
"source/stubdata/stubdata.h",
],
hdrs = glob([
"source/common/unicode/*.h",
"source/i18n/unicode/*.h",
]),
copts = select({
"@platforms//os:windows": [
"-Wno-deprecated-declarations",
],
"//conditions:default": [],
}) + _ICU_V8_COPTS,
include_prefix = "third_party/icu",
local_defines = [
"U_COMMON_IMPLEMENTATION",
],
visibility = ["//visibility:public"],
deps = [
":icui18n",
":icuuc",
] + _ICU_V8_RUNTIME_DEPS,
alwayslink = 1,
)