From 5b72626551347adffa2de47859d758f03d991782 Mon Sep 17 00:00:00 2001 From: Tmalone1250 Date: Wed, 15 Apr 2026 21:07:53 -0500 Subject: [PATCH] build, v8: fix Temporal compilation with system or no ICU --- deps/v8/BUILD.gn | 37 +++++++++++-------- deps/v8/gni/v8.gni | 7 ++++ deps/v8/src/objects/js-temporal-zoneinfo64.cc | 10 +++-- deps/v8/src/objects/js-temporal-zoneinfo64.h | 4 +- tools/v8_gypfiles/v8.gyp | 37 +++++++++++++++++++ 5 files changed, 74 insertions(+), 21 deletions(-) diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index 6432f7342e26a5..efea2cad991716 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -1260,6 +1260,9 @@ config("features") { if (v8_enable_temporal_support) { defines += [ "V8_TEMPORAL_SUPPORT" ] } + if (v8_enable_temporal_support && v8_use_icu_zoneinfo64) { + defines += [ "V8_USE_ICU_ZONEINFO64" ] + } if (v8_enable_local_handle_zapping) { defines += [ "ENABLE_LOCAL_HANDLE_ZAPPING" ] } @@ -3410,19 +3413,22 @@ v8_header_set("v8_flags") { } if (v8_enable_temporal_support) { - # In cases where we aren't using ICU4C (e.g. v8_enable_i18n_support=false), + # When not using ICU4C for zoneinfo (either because i18n is disabled or + # because the embedder opted out via v8_use_icu_zoneinfo64=false), # we "bake" in a zoneinfo64.res binary for Temporal - action("make_temporal_zoneinfo_cpp") { - script = "tools/include-file-as-bytes.py" - inputs = [ get_label_info("//third_party/icu/", "dir") + - "/tzres/zoneinfo64.res" ] - outputs = - [ "$target_gen_dir/src/builtins/builtins-temporal-zoneinfo64-data.cc" ] - args = [ - rebase_path(inputs[0], root_build_dir), - rebase_path(outputs[0], root_build_dir), - "zoneinfo64_static_data", - ] + if (!v8_use_icu_zoneinfo64) { + action("make_temporal_zoneinfo_cpp") { + script = "tools/include-file-as-bytes.py" + inputs = [ get_label_info("//third_party/icu/", "dir") + + "/tzres/zoneinfo64.res" ] + outputs = + [ "$target_gen_dir/src/builtins/builtins-temporal-zoneinfo64-data.cc" ] + args = [ + rebase_path(inputs[0], root_build_dir), + rebase_path(outputs[0], root_build_dir), + "zoneinfo64_static_data", + ] + } } } @@ -6535,9 +6541,10 @@ v8_source_set("v8_base_without_compiler") { ] } - # In i18n mode, we can use ICU4C to load ICU4C's builtin zoneinfo64.res data - # In non-i18n mode, we need to copy that into the binary - if (v8_enable_temporal_support && !v8_enable_i18n_support) { + # In i18n mode with v8_use_icu_zoneinfo64, we load zoneinfo64 via ICU4C at + # runtime. Otherwise (no-i18n builds, or embedders using system ICU without + # private ICU headers) we bake the data into the binary. + if (v8_enable_temporal_support && !v8_use_icu_zoneinfo64) { sources += [ "$target_gen_dir/src/builtins/builtins-temporal-zoneinfo64-data.cc" ] deps += [ ":make_temporal_zoneinfo_cpp" ] diff --git a/deps/v8/gni/v8.gni b/deps/v8/gni/v8.gni index d198859576a4bd..1d84a642cdca12 100644 --- a/deps/v8/gni/v8.gni +++ b/deps/v8/gni/v8.gni @@ -64,6 +64,13 @@ declare_args() { v8_enable_temporal_support = !(defined(build_with_node) && build_with_node) && target_cpu != "ppc64" && target_cpu != "s390x" + # When Temporal is enabled and ICU support is present, use ICU's raw zoneinfo64 + # memory (via UDataMemory) rather than bundling a static copy of the data. + # Embedders that use a system-provided ICU (e.g. Node.js with --with-intl=system-icu) + # may not have the ICU private header `udatamem.h` available and should set this + # to false to fall back to the baked-in static data. + v8_use_icu_zoneinfo64 = v8_enable_i18n_support + # Use static libraries instead of source_sets. v8_static_library = false diff --git a/deps/v8/src/objects/js-temporal-zoneinfo64.cc b/deps/v8/src/objects/js-temporal-zoneinfo64.cc index 99dd3a84c1e54f..5dc1a24432ef4d 100644 --- a/deps/v8/src/objects/js-temporal-zoneinfo64.cc +++ b/deps/v8/src/objects/js-temporal-zoneinfo64.cc @@ -10,9 +10,11 @@ #include "temporal_rs/Provider.hpp" #include "temporal_rs/TimeZone.hpp" -#ifdef V8_INTL_SUPPORT +#ifdef V8_USE_ICU_ZONEINFO64 #include "udatamem.h" -#else +#endif + +#ifndef V8_USE_ICU_ZONEINFO64 // Defined in builtins-temporal-zoneinfo64-data.cc, generated by // include-file-as-bytes.py extern "C" uint32_t zoneinfo64_static_data[]; @@ -22,7 +24,7 @@ extern "C" size_t zoneinfo64_static_data_len; namespace v8::internal { ZoneInfo64Provider::ZoneInfo64Provider() { -#ifdef V8_INTL_SUPPORT +#ifdef V8_USE_ICU_ZONEINFO64 UErrorCode status = U_ZERO_ERROR; memory = udata_open(0, "res", "zoneinfo64", &status); if (U_FAILURE(status)) { @@ -74,7 +76,7 @@ ZoneInfo64Provider::~ZoneInfo64Provider() { // Then clean up memory // This ideally is a no-op when using static data -#ifdef V8_INTL_SUPPORT +#ifdef V8_USE_ICU_ZONEINFO64 if (memory) { udata_close(memory); } diff --git a/deps/v8/src/objects/js-temporal-zoneinfo64.h b/deps/v8/src/objects/js-temporal-zoneinfo64.h index 723f2162a82d09..930e9724a8c52c 100644 --- a/deps/v8/src/objects/js-temporal-zoneinfo64.h +++ b/deps/v8/src/objects/js-temporal-zoneinfo64.h @@ -7,7 +7,7 @@ #include "temporal_rs/Provider.d.hpp" -#ifdef V8_INTL_SUPPORT +#ifdef V8_USE_ICU_ZONEINFO64 #include "unicode/udata.h" #else #include @@ -37,7 +37,7 @@ class ZoneInfo64Provider { ZoneInfo64Provider(); ~ZoneInfo64Provider(); std::unique_ptr provider; -#ifdef V8_INTL_SUPPORT +#ifdef V8_USE_ICU_ZONEINFO64 UDataMemory* memory; #endif }; diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index e09fcc1ce8c59f..2f0fd30771881b 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -1379,6 +1379,9 @@ '