From 01cee9dcefc958168d4823dcdf44cbaada55f33e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 28 Aug 2026 19:37:37 +0200 Subject: [PATCH] build: do not use bundled simdutf when built with `--shared-simdutf` Signed-off-by: Antoine du Hamel PR-URL: https://github.com/nodejs/node/pull/65891 Reviewed-By: Xuguang Mei --- .github/workflows/test-shared.yml | 2 ++ Makefile | 1 + deps/ada/ada.gyp | 3 +-- node.gyp | 2 +- node.gypi | 2 +- shell.nix | 2 ++ tools/nix/sharedLibDeps.nix | 5 ++++- tools/nix/v8.nix | 7 ++++++- tools/v8_gypfiles/simdutf.gyp | 22 ++++++++++++++++++++++ tools/v8_gypfiles/v8.gyp | 20 ++++---------------- 10 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 tools/v8_gypfiles/simdutf.gyp diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index ae6a6619f47..9f4d2e031f5 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 8dec67750f0..c9f3ad5f05e 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/deps/ada/ada.gyp b/deps/ada/ada.gyp index 30054e63e56..855261f9eca 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/node.gyp b/node.gyp index 1374033c910..2cf1e62b569 100644 --- a/node.gyp +++ b/node.gyp @@ -1654,7 +1654,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 bfe2d00ad92..b382784e610 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 6f50142046e..4e9f5e66456 100644 --- a/shell.nix +++ b/shell.nix @@ -68,6 +68,7 @@ let ++ 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 (builtins.hasAttr "simdutf" sharedLibDeps) sharedLibDeps.simdutf ++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi; # Put here only the configure flags that affect the V8 build @@ -83,6 +84,7 @@ let ++ 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 (builtins.hasAttr "simdutf" sharedLibDeps) "--shared-simdutf" ++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi" ++ pkgs.lib.optional withPerfetto "--with-perfetto"; in diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index 585ceae637e..ae418f30574 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -17,7 +17,6 @@ merve nbytes simdjson - simdutf uvwasi zlib zstd @@ -34,6 +33,10 @@ hash = "sha256-PxhfWxw+d4heuc8/LE2ksan3OiS/WVe4KRg60Tf4Lcg="; }; }; + 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 3c3c3ab4734..81617fff809 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 00000000000..b5dc014bbe9 --- /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 819dffb8898..093be6e5395 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 ], }