diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index f7483103016f..8fdd2f0bce41 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -36,6 +36,7 @@ on: - deps/uvwasi/** - deps/v8/third_party/abseil-cpp/** - deps/v8/third_party/highway/** + - deps/v8/third_party/simdutf/** - deps/zlib/** - deps/zstd/** - doc/** @@ -92,6 +93,7 @@ on: - deps/uvwasi/** - deps/v8/third_party/abseil-cpp/** - deps/v8/third_party/highway/** + - deps/v8/third_party/simdutf/** - deps/zlib/** - deps/zstd/** - doc/** diff --git a/Makefile b/Makefile index 8dec67750f0c..c9f3ad5f05e2 100644 --- a/Makefile +++ b/Makefile @@ -1326,6 +1326,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1) $(RM) -r $(TARNAME)/deps/uvwasi $(RM) -r $(TARNAME)/deps/v8/third_party/abseil-cpp $(RM) -r $(TARNAME)/deps/v8/third_party/highway + $(RM) -r $(TARNAME)/deps/v8/third_party/simdutf $(RM) -r $(TARNAME)/deps/zlib $(RM) -r $(TARNAME)/deps/zstd else diff --git a/common.gypi b/common.gypi index ce602beccf66..508d51a21cc6 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/ada/ada.gyp b/deps/ada/ada.gyp index 30054e63e567..855261f9ecaf 100644 --- a/deps/ada/ada.gyp +++ b/deps/ada/ada.gyp @@ -8,7 +8,6 @@ 'type': 'static_library', 'include_dirs': [ '.', - '<(DEPTH)/deps/v8/third_party/simdutf', ], 'direct_dependent_settings': { 'include_dirs': ['.'], @@ -17,7 +16,7 @@ 'ADA_USE_SIMDUTF=1', ], 'dependencies': [ - '../../tools/v8_gypfiles/v8.gyp:simdutf', + '../../tools/v8_gypfiles/simdutf.gyp:simdutf', ], 'sources': [ '<@(ada_sources)' ] }, diff --git a/deps/v8/BUILD.bazel b/deps/v8/BUILD.bazel index 53c06e3ceccf..0c6f27d82dd9 100644 --- a/deps/v8/BUILD.bazel +++ b/deps/v8/BUILD.bazel @@ -4584,6 +4584,7 @@ cc_library( name = "simdutf", srcs = ["third_party/simdutf/simdutf.cpp"], hdrs = ["third_party/simdutf/simdutf.h"], + strip_include_prefix = "third_party/simdutf", copts = select({ "@v8//bazel/config:is_clang": ["-std=c++20"], "@v8//bazel/config:is_gcc": ["-std=gnu++2a"], diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index ea335df90341..e0f2007bf530 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -2516,6 +2516,16 @@ group("v8_abseil") { ] } +group("v8_simdutf") { + public_deps = [ "//third_party/simdutf" ] + public_configs = [ ":simdutf_include_config" ] + + visibility = [ "./*" ] +} +config("simdutf_include_config") { + include_dirs = [ "//third_party/simdutf" ] +} + group("zoslib") { if (current_os == "zos") { deps = [ "//third_party/zoslib" ] @@ -5308,6 +5318,7 @@ v8_header_set("v8_internal_headers") { ":v8_headers", ":v8_maybe_icu", ":v8_shared_internal_headers", + ":v8_simdutf", "//third_party/fp16", ] @@ -5323,7 +5334,6 @@ v8_header_set("v8_internal_headers") { ":v8_heap_base_headers", ":v8_libbase", ":v8_maybe_temporal", - "//third_party/simdutf", ] if (v8_enable_experimental_tq_to_tsa) { deps += [ ":run_torque_to_tsa" ] @@ -6727,7 +6737,7 @@ v8_source_set("v8_base_without_compiler") { ":v8_headers", ":v8_internal_headers", ":v8_maybe_icu", - "//third_party/simdutf", + ":v8_simdutf", ] if (v8_enable_experimental_tq_to_tsa) { public_deps += [ ":run_torque_to_tsa" ] @@ -8287,9 +8297,9 @@ v8_executable("d8") { ":v8", ":v8_libbase", ":v8_libplatform", + ":v8_simdutf", ":v8_tracing", "//build/win:default_exe_manifest", - "//third_party/simdutf", ] if (is_posix || is_fuchsia) { diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 5dd3a777e4f3..8787d03124f2 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -557,10 +557,10 @@ include_rules = [ '+third_party/fp16/src/include', '+third_party/fuzztest', '+third_party/ittapi/include', - '+third_party/simdutf', '+third_party/v8/codegen', '+third_party/vtune', '+hwy/highway.h', + '+simdutf.h', # Abseil features are allow-listed. Please use your best judgement when adding # to this set -- if in doubt, email v8-dev@. For general guidance, refer to # the Chromium guidelines (though note that some requirements in V8 may be diff --git a/deps/v8/src/builtins/builtins-typed-array.cc b/deps/v8/src/builtins/builtins-typed-array.cc index 06849f391467..3ab036e76312 100644 --- a/deps/v8/src/builtins/builtins-typed-array.cc +++ b/deps/v8/src/builtins/builtins-typed-array.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "simdutf.h" #include "src/base/logging.h" #include "src/base/macros.h" #include "src/builtins/builtins-utils-inl.h" @@ -15,7 +16,6 @@ #include "src/objects/objects-inl.h" #include "src/objects/option-utils.h" #include "src/objects/simd.h" -#include "third_party/simdutf/simdutf.h" namespace v8::internal { diff --git a/deps/v8/src/objects/string-inl.h b/deps/v8/src/objects/string-inl.h index 1d414c3465e0..604b64dada3f 100644 --- a/deps/v8/src/objects/string-inl.h +++ b/deps/v8/src/objects/string-inl.h @@ -12,6 +12,7 @@ #include #include "absl/functional/overload.h" +#include "simdutf.h" #include "src/common/assert-scope.h" #include "src/common/globals.h" #include "src/execution/isolate-utils.h" @@ -38,7 +39,6 @@ #include "src/torque/runtime-macro-shims.h" #include "src/torque/runtime-support.h" #include "src/utils/utils.h" -#include "third_party/simdutf/simdutf.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/deps/v8/src/objects/string.h b/deps/v8/src/objects/string.h index c6003839758f..c8ef0434577d 100644 --- a/deps/v8/src/objects/string.h +++ b/deps/v8/src/objects/string.h @@ -8,6 +8,7 @@ #include #include +#include "simdutf.h" #include "src/base/bits.h" #include "src/base/export-template.h" #include "src/base/small-vector.h" @@ -21,7 +22,6 @@ #include "src/objects/tagged.h" #include "src/sandbox/external-pointer.h" #include "src/strings/unicode-decoder.h" -#include "third_party/simdutf/simdutf.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/deps/v8/src/strings/unicode-inl.h b/deps/v8/src/strings/unicode-inl.h index 25f3d0375e7f..3f1b5b33f343 100644 --- a/deps/v8/src/strings/unicode-inl.h +++ b/deps/v8/src/strings/unicode-inl.h @@ -8,9 +8,9 @@ #include "src/strings/unicode.h" // Include the non-inl header before the rest of the headers. +#include "simdutf.h" #include "src/base/logging.h" #include "src/utils/utils.h" -#include "third_party/simdutf/simdutf.h" namespace unibrow { diff --git a/deps/v8/src/strings/unicode.cc b/deps/v8/src/strings/unicode.cc index d213ea68e8ad..74687f7463e3 100644 --- a/deps/v8/src/strings/unicode.cc +++ b/deps/v8/src/strings/unicode.cc @@ -22,7 +22,7 @@ #endif #include "hwy/highway.h" -#include "third_party/simdutf/simdutf.h" +#include "simdutf.h" namespace unibrow { diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index 52faa5ccbcaf..10c6e1e91d50 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -14,8 +14,8 @@ v8_executable("cctest") { "../..:v8_for_testing", "../..:v8_libbase", "../..:v8_libplatform", + "../..:v8_simdutf", "../../tools/debug_helper:v8_debug_helper", - "//third_party/simdutf", ] data_deps = [ "../../tools:v8_testrunner" ] diff --git a/node.gyp b/node.gyp index 52f421f3181c..98e37c1087a1 100644 --- a/node.gyp +++ b/node.gyp @@ -1652,7 +1652,7 @@ 'libraries': [ '-framework CoreFoundation -framework Security' ], }], [ 'node_shared_simdutf=="false" and node_use_bundled_v8!="false"', { - 'dependencies': [ 'tools/v8_gypfiles/v8.gyp:simdutf#host' ], + 'dependencies': [ 'tools/v8_gypfiles/simdutf.gyp:simdutf#host' ], }], [ 'node_shared_libuv=="false"', { 'dependencies': [ 'deps/uv/uv.gyp:libuv#host' ], diff --git a/node.gypi b/node.gypi index bfe2d00ad929..b382784e6100 100644 --- a/node.gypi +++ b/node.gypi @@ -247,7 +247,7 @@ }], [ 'node_shared_simdutf=="false" and node_use_bundled_v8!="false"', { - 'dependencies': [ 'tools/v8_gypfiles/v8.gyp:simdutf' ], + 'dependencies': [ 'tools/v8_gypfiles/simdutf.gyp:simdutf' ], }], [ 'node_shared_brotli=="false"', { diff --git a/shell.nix b/shell.nix index 1829c1efd21b..6415a372ffab 100644 --- a/shell.nix +++ b/shell.nix @@ -48,14 +48,24 @@ benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; }, }: +assert pkgs.lib.assertMsg ( + withTemporal || !(builtins.hasAttr "temporal_capi" sharedLibDeps) +) "`sharedLibDeps` must not contain `temporal_capi` when `withTemporal` is false"; +assert pkgs.lib.assertMsg ( + withPerfetto || !(builtins.hasAttr "perfetto" sharedLibDeps) +) "`sharedLibDeps` must not contain `perfetto` when `withPerfetto` is false"; + let useSharedICU = if builtins.isString icu then icu == "system" else icu != null; - useSharedAda = builtins.hasAttr "ada" sharedLibDeps; - useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps; + needsRustCompiler = withTemporal && !(builtins.hasAttr "temporal_capi" sharedLibDeps); - useSharedPerfetto = builtins.hasAttr "perfetto" sharedLibDeps; - useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps; - needsRustCompiler = withTemporal && !useSharedTemporal; + sharedV8Deps = builtins.filter (depName: builtins.hasAttr depName sharedLibDeps) ([ + "abseil" + "highway" + "perfetto" + "simdutf" + "temporal_capi" + ]); nativeBuildInputs = pkgs.nodejs-slim_latest.nativeBuildInputs @@ -64,11 +74,7 @@ let pkgs.rustc ]; buildInputs = - pkgs.lib.optional useSharedICU icu - ++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil - ++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) sharedLibDeps.highway - ++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) sharedLibDeps.perfetto - ++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi; + pkgs.lib.optional useSharedICU icu ++ builtins.map (depName: sharedLibDeps.${depName}) sharedV8Deps; # Put here only the configure flags that affect the V8 build configureFlags = [ @@ -80,10 +86,7 @@ let ) "--v8-${if withTemporal then "enable" else "disable"}-temporal-support" ] - ++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil" - ++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) "--shared-highway" - ++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto" - ++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi" + ++ builtins.map (depName: "--shared-${depName}") sharedV8Deps ++ pkgs.lib.optional withPerfetto "--with-perfetto"; in pkgs.mkShell { @@ -129,26 +132,14 @@ pkgs.mkShell { ++ pkgs.lib.optional (!withSSL) "--without-ssl" ++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}" ++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8" - ++ - pkgs.lib.concatMap - (name: [ - "--shared-${name}" - "--shared-${name}-libpath=${pkgs.lib.getLib sharedLibDeps.${name}}/lib" - "--shared-${name}-include=${pkgs.lib.getInclude sharedLibDeps.${name}}/include" - ]) - ( - builtins.attrNames ( - if (useSeparateDerivationForV8 != false) then - builtins.removeAttrs sharedLibDeps [ - "abseil" - "highway" - "simdutf" - "temporal_capi" - ] - else - sharedLibDeps - ) - ) + ++ builtins.map (name: "--shared-${name}") ( + builtins.attrNames ( + if (useSeparateDerivationForV8 != false) then + builtins.removeAttrs sharedLibDeps sharedV8Deps + else + sharedLibDeps + ) + ) ); } // ( diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index d57ceb4918bb..0dab23c9c85c 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -18,7 +18,6 @@ nbytes nghttp2 simdjson - simdutf uvwasi zlib zstd @@ -28,6 +27,10 @@ hdr-histogram = pkgs.hdrhistogram_c; highway = pkgs.libhwy; http-parser = pkgs.llhttp; + simdutf = pkgs.simdutf.overrideAttrs (old: { + # TODO: remove this once the pin we use has picked up https://github.com/NixOS/nixpkgs/pull/557405 + cmakeFlags = old.cmakeFlags ++ [ (pkgs.lib.cmakeFeature "SIMDUTF_CXX_STANDARD" "20") ]; + }); } // (pkgs.lib.optionalAttrs withLief { inherit (pkgs) lief; diff --git a/tools/nix/v8.nix b/tools/nix/v8.nix index 3c3c3ab47347..81617fff8096 100644 --- a/tools/nix/v8.nix +++ b/tools/nix/v8.nix @@ -25,6 +25,7 @@ let useSharedAbseil = builtins.elem "--shared-abseil" configureFlags; useSharedHighway = builtins.elem "--shared-highway" configureFlags; + useSharedSimdutf = builtins.elem "--shared-simdutf" configureFlags; src = let inherit (lib) fileset; @@ -47,6 +48,7 @@ let ] ++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp ++ lib.optional (!useSharedHighway) ../../tools/v8_gypfiles/highway.gyp + ++ lib.optional (!useSharedSimdutf) ../../tools/v8_gypfiles/simdutf.gyp ++ lib.optional ( builtins.elem "--with-perfetto" configureFlags && !(builtins.elem "--shared-perfetto" configureFlags) @@ -76,6 +78,7 @@ let ] ++ lib.optional useSharedAbseil ../../deps/v8/third_party/abseil-cpp ++ lib.optional useSharedHighway ../../deps/v8/third_party/highway + ++ lib.optional useSharedSimdutf ../../deps/v8/third_party/simdutf )); trackedFiles = ({ @@ -201,7 +204,9 @@ stdenv.mkDerivation (finalAttrs: { '' } - install -Dm644 deps/v8/third_party/simdutf/simdutf.h -t $out/include + ${lib.optionalString ( + !useSharedSimdutf + ) "install -Dm644 deps/v8/third_party/simdutf/simdutf.h -t $out/include"} find deps/v8/include -name '*.h' -print0 | while read -r -d "" file; do install -Dm644 "$file" -T "$out/include/''${file#deps/v8/include/}" done diff --git a/tools/v8_gypfiles/simdutf.gyp b/tools/v8_gypfiles/simdutf.gyp new file mode 100644 index 000000000000..b5dc014bbe9f --- /dev/null +++ b/tools/v8_gypfiles/simdutf.gyp @@ -0,0 +1,22 @@ +{ + 'includes': ['toolchain.gypi'], + 'targets': [ + { + 'target_name': 'simdutf', + 'type': 'static_library', + 'toolsets': ['host', 'target'], + 'variables': { + 'SIMDUTF_ROOT': '../../deps/v8/third_party/simdutf', + }, + 'all_dependent_settings': { + 'include_dirs': [ + '<(SIMDUTF_ROOT)', + ], + }, + 'include_dirs': ['.'], + 'sources': [ + '<(SIMDUTF_ROOT)/simdutf.cpp', + ], + }, # simdutf + ], +} diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 819dffb88984..093be6e53956 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -650,7 +650,10 @@ }], ['node_shared_highway=="false"', { 'dependencies': ['highway.gyp:highway'], - }] + }], + ['node_shared_simdutf=="false"', { + 'dependencies': ['simdutf.gyp:simdutf'], + }], ], 'direct_dependent_settings': { 'sources': [ @@ -1118,7 +1121,6 @@ 'v8_maybe_icu', 'v8_zlib', 'v8_pch', - 'simdutf', ], 'includes': ['inspector.gypi'], 'direct_dependent_settings': { @@ -2479,19 +2481,5 @@ ], }, }, # fp16 - { - 'target_name': 'simdutf', - 'type': 'static_library', - 'toolsets': ['host', 'target'], - 'direct_dependent_settings': { - 'include_dirs': [ - '<(V8_ROOT)/third_party/simdutf', - ], - }, - 'include_dirs': ['.'], - 'sources': [ - '<(V8_ROOT)/third_party/simdutf/simdutf.cpp', - ], - }, # simdutf ], }