From 8ebe149b0534b7ad592091b4e148134a45cb51bf Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 11 Sep 2026 15:40:54 -0500 Subject: [PATCH] deps: V8: cherry-pick cd89fe6f7acb Original commit message: build: Fix Temporal compilation with system or no ICU - remove reference to internal udatamem.h header file See: https://unicode-org.atlassian.net/browse/ICU-23400 See: Node: https://github.com/nodejs/node/issues/62676 See: V8: https://chromium-review.googlesource.com/c/v8/v8/+/8281487 Bug: 8281487 Refs: https://github.com/srl295/v8/commit/cd89fe6f7acb6f5d069f6cc741fa68303214e98f --- common.gypi | 2 +- deps/v8/src/objects/js-temporal-zoneinfo64.cc | 48 ++++++++++++++----- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/common.gypi b/common.gypi index e6a17d3505a5..563259e21ea7 100644 --- a/common.gypi +++ b/common.gypi @@ -43,7 +43,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.32', + 'v8_embedder_string': '-node.33', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/objects/js-temporal-zoneinfo64.cc b/deps/v8/src/objects/js-temporal-zoneinfo64.cc index 99dd3a84c1e5..b4669b1217c3 100644 --- a/deps/v8/src/objects/js-temporal-zoneinfo64.cc +++ b/deps/v8/src/objects/js-temporal-zoneinfo64.cc @@ -11,7 +11,30 @@ #include "temporal_rs/TimeZone.hpp" #ifdef V8_INTL_SUPPORT -#include "udatamem.h" +/** + * Shadow definition of UDataMemory + * This is functionally identical to the definition in udatamem.h + * Irrelevant fields are marked 'ignored' and should not be used. + * + * This definition is copied here so that the result of udata_open() + * can be used and length-checked without needing to resort to + * calling internal ICU functions. + * + * Note, there is an ICU ticket, + * https://unicode-org.atlassian.net/browse/ICU-23400 + * to consider whether the API surface should be changed + * here. If and when this is done, such an API could be used. + */ +struct UDataMemoryShadow { + const void* ignored1; + const void* data; //< pointer to header of data object + const void* ignored2; + UBool ignored3; + void* ignored4; + void* ignored5; + int32_t + length; //< length of entire region pointed to by data if known, else -1 +}; #else // Defined in builtins-temporal-zoneinfo64-data.cc, generated by // include-file-as-bytes.py @@ -30,26 +53,29 @@ ZoneInfo64Provider::ZoneInfo64Provider() { provider = temporal_rs::Provider::empty(); return; } - // NOT udata_getLength: this ignores the header, - // and we're parsing resb files with the header - auto length = memory->length; - const void* data = udata_getRawMemory(memory); - DCHECK_WITH_MSG(length % 4 == 0, "ICU4C should align udata to uint32_t"); - if (length % 4 != 0) { - // This really shouldn't happen: ICU4C aligns these files - // to 4 when baking them in + // reinterpret with a local struct + const UDataMemoryShadow* shadowMemory = + reinterpret_cast(memory); + // just need the length and data + auto length = shadowMemory->length; + // This really shouldn't happen: ICU4C pads these files + // to 4 when baking them in + DCHECK_WITH_MSG(length % 4 == 0, "ICU4C should pad udata to uint32_t"); + // Length may not be known. If we're not OK with that, don't proceed. + DCHECK_WITH_MSG(length != -1, "ICU4C usually knows the length"); + if (length % 4 != 0 || length == -1) { provider = temporal_rs::Provider::empty(); return; } + auto data = shadowMemory->data; + DCHECK_WITH_MSG(data != nullptr, "ICU4C returned nullptr"); const uint32_t* data_32 = static_cast(data); std::span data_span(data_32, length / 4); - #else std::span data_span(zoneinfo64_static_data, zoneinfo64_static_data_len); #endif - auto result = temporal_rs::Provider::new_zoneinfo64(data_span); DCHECK_WITH_MSG(result.is_ok(), "Baked-in zoneinfo64 file must parse"); if (result.is_ok()) {