Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions deps/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
Expand Down Expand Up @@ -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",
]
}
}
}

Expand Down Expand Up @@ -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" ]
Expand Down
7 changes: 7 additions & 0 deletions deps/v8/gni/v8.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions deps/v8/src/objects/js-temporal-zoneinfo64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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)) {
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/objects/js-temporal-zoneinfo64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vector>
Expand Down Expand Up @@ -37,7 +37,7 @@ class ZoneInfo64Provider {
ZoneInfo64Provider();
~ZoneInfo64Provider();
std::unique_ptr<temporal_rs::Provider> provider;
#ifdef V8_INTL_SUPPORT
#ifdef V8_USE_ICU_ZONEINFO64
UDataMemory* memory;
#endif
};
Expand Down
37 changes: 37 additions & 0 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,9 @@
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_enable_i18n_support.*?sources -= ")',
],
}],
['v8_enable_temporal_support==1', {
'dependencies': ['make_temporal_zoneinfo_cpp'],
}],
['v8_postmortem_support', {
'dependencies': ['postmortem-metadata#target'],
}],
Expand Down Expand Up @@ -1955,6 +1958,40 @@
"<(V8_ROOT)/src/regexp/special-case.h",
],
}, # gen-regexp-special-case
{
'target_name': 'make_temporal_zoneinfo_cpp',
'type': 'none',
'toolsets': ['host', 'target'],
'conditions': [
['v8_enable_temporal_support==1', {
'actions': [
{
'action_name': 'make_temporal_zoneinfo_cpp_action',
'inputs': [
'<(V8_ROOT)/tools/include-file-as-bytes.py',
'<(V8_ROOT)/../crates/vendor/zoneinfo64/src/data/zoneinfo64.res',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/src/builtins/builtins-temporal-zoneinfo64-data.cc',
],
'action': [
'<(python)',
'<(V8_ROOT)/tools/include-file-as-bytes.py',
'<(V8_ROOT)/../crates/vendor/zoneinfo64/src/data/zoneinfo64.res',
'<@(_outputs)',
'zoneinfo64_static_data',
],
'message': 'Generating temporal zoneinfo static data',
},
],
}],
],
'direct_dependent_settings': {
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/src/builtins/builtins-temporal-zoneinfo64-data.cc',
],
},
},
{
'target_name': 'run_gen-regexp-special-case',
'type': 'none',
Expand Down