From 120929a1b379428338698588ea7ea0334fdc3f33 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 29 Aug 2026 13:03:38 +0200 Subject: [PATCH] build: add `--shared-highway` configure flag Signed-off-by: Antoine du Hamel PR-URL: https://github.com/nodejs/node/pull/65686 Reviewed-By: Chengzhong Wu Reviewed-By: Filip Skokan --- .github/workflows/test-shared.yml | 2 + Makefile | 1 + configure.py | 23 +++++++++++ node.gyp | 1 + shell.nix | 3 ++ tools/nix/sharedLibDeps.nix | 1 + tools/nix/v8.nix | 3 ++ tools/v8_gypfiles/highway.gyp | 58 ++++++++++++++++++++++++++ tools/v8_gypfiles/v8.gyp | 67 ++++--------------------------- 9 files changed, 100 insertions(+), 59 deletions(-) create mode 100644 tools/v8_gypfiles/highway.gyp diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index 92f5d4f5d48..96e862c3591 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -34,6 +34,7 @@ on: - deps/uv/** - deps/uvwasi/** - deps/v8/third_party/abseil-cpp/** + - deps/v8/third_party/highway/** - deps/zlib/** - deps/zstd/** - doc/** @@ -88,6 +89,7 @@ on: - deps/uv/** - deps/uvwasi/** - deps/v8/third_party/abseil-cpp/** + - deps/v8/third_party/highway/** - deps/zlib/** - deps/zstd/** - doc/** diff --git a/Makefile b/Makefile index 2edfc771c7b..a354f55ab28 100644 --- a/Makefile +++ b/Makefile @@ -1324,6 +1324,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1) $(RM) -r $(TARNAME)/deps/uv $(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/zlib $(RM) -r $(TARNAME)/deps/zstd else diff --git a/configure.py b/configure.py index 5c2a398989a..99ce9326dc9 100755 --- a/configure.py +++ b/configure.py @@ -348,6 +348,28 @@ shared_optgroup.add_argument('--shared-hdr-histogram-libpath', dest='shared_hdr_histogram_libpath', help='a directory to search for the shared HdrHistogram DLL') +shared_optgroup.add_argument('--shared-highway', + action='store_true', + dest='shared_highway', + default=None, + help='link to a shared Highway (hwy) DLL instead of static linking') + +shared_optgroup.add_argument('--shared-highway-includes', + action='store', + dest='shared_highway_includes', + help='directory containing Highway header files') + +shared_optgroup.add_argument('--shared-highway-libname', + action='store', + dest='shared_highway_libname', + default='hwy', + help='alternative lib name to link to [default: %(default)s]') + +shared_optgroup.add_argument('--shared-highway-libpath', + action='store', + dest='shared_highway_libpath', + help='a directory to search for the shared Highway DLL') + shared_optgroup.add_argument('--shared-http-parser', action='store_true', dest='shared_http_parser', @@ -2908,6 +2930,7 @@ configure_library('brotli', output, pkgname=['libbrotlidec', 'libbrotlienc']) configure_library('cares', output, pkgname='libcares') configure_library('gtest', output) configure_library('hdr_histogram', output) +configure_library('highway', output, pkgname='libhwy') configure_library('merve', output) configure_library('nbytes', output) configure_library('nghttp2', output, pkgname='libnghttp2') diff --git a/node.gyp b/node.gyp index 8777cdc17d0..7e1e4f212ca 100644 --- a/node.gyp +++ b/node.gyp @@ -20,6 +20,7 @@ 'node_shared_cares%': 'false', 'node_shared_gtest%': 'false', 'node_shared_hdr_histogram%': 'false', + 'node_shared_highway%': 'false', 'node_shared_http_parser%': 'false', 'node_shared_libuv%': 'false', 'node_shared_lief%': 'false', diff --git a/shell.nix b/shell.nix index 2d2db130d4d..53abe6859d4 100644 --- a/shell.nix +++ b/shell.nix @@ -64,6 +64,7 @@ let 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 (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi; # Put here only the configure flags that affect the V8 build @@ -77,6 +78,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 (withTemporal && useSharedTemporal) "--shared-temporal_capi" ++ pkgs.lib.optional withPerfetto "--with-perfetto"; in @@ -135,6 +137,7 @@ pkgs.mkShell { if (useSeparateDerivationForV8 != false) then builtins.removeAttrs sharedLibDeps [ "abseil" + "highway" "simdutf" "temporal_capi" ] diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index 1d5d14c285a..464b56a63ac 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -24,6 +24,7 @@ abseil = pkgs.abseil-cpp; cares = pkgs.c-ares; hdr-histogram = pkgs.hdrhistogram_c; + highway = pkgs.libhwy; http-parser = pkgs.llhttp; nghttp2 = pkgs.nghttp2.overrideAttrs { version = "1.69.0"; diff --git a/tools/nix/v8.nix b/tools/nix/v8.nix index 0338bff5ddb..98df8b769c2 100644 --- a/tools/nix/v8.nix +++ b/tools/nix/v8.nix @@ -24,6 +24,7 @@ let useSharedAbseil = builtins.elem "--shared-abseil" configureFlags; + useSharedHighway = builtins.elem "--shared-highway" configureFlags; src = let inherit (lib) fileset; @@ -45,6 +46,7 @@ let ../../tools/v8_gypfiles/v8.gyp ] ++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp + ++ lib.optional (!useSharedHighway) ../../tools/v8_gypfiles/highway.gyp ++ lib.optionals (builtins.elem "--with-perfetto" configureFlags) [ ../../deps/perfetto ] @@ -72,6 +74,7 @@ let ../../deps/v8/third_party/ittapi ] ++ lib.optional useSharedAbseil ../../deps/v8/third_party/abseil-cpp + ++ lib.optional useSharedHighway ../../deps/v8/third_party/highway )); trackedFiles = ({ diff --git a/tools/v8_gypfiles/highway.gyp b/tools/v8_gypfiles/highway.gyp new file mode 100644 index 00000000000..c7f915b76e2 --- /dev/null +++ b/tools/v8_gypfiles/highway.gyp @@ -0,0 +1,58 @@ +{ + 'includes': ['toolchain.gypi'], + 'targets': [ + { + 'target_name': 'highway', + 'type': 'static_library', + 'toolsets': ['host', 'target'], + 'variables': { + 'HIGHWAY_ROOT': '../../deps/v8/third_party/highway', + }, + 'all_dependent_settings': { + 'include_dirs': [ + '<(HIGHWAY_ROOT)/src', + ], + 'conditions': [ + ['v8_target_arch=="ia32"', { + 'defines': ['HWY_BROKEN_TARGETS=(HWY_AVX2|HWY_AVX3)',], + }], + ['v8_target_arch=="arm64"', { + 'defines': ['HWY_BROKEN_TARGETS=HWY_ALL_SVE',], + }], + ['v8_target_arch=="ppc64" or v8_target_arch=="s390x"', { + 'defines': ['TOOLCHAIN_MISS_ASM_HWCAP_H',], + }], + ['v8_target_arch=="s390x"', { + 'defines': ['HWY_BROKEN_EMU128=0',], + }], + ['OS in "aix os400"', { + 'defines': ['HWY_BROKEN_EMU128=0',], + }], + ['v8_target_arch=="arm" and arm_version==7', { + 'defines': ['HWY_BROKEN_EMU128=0',], + }], + ], + }, + 'include_dirs': [ + '<(HIGHWAY_ROOT)/src', + ], + 'conditions': [ + ['v8_target_arch=="ia32"', { + 'defines': ['HWY_BROKEN_TARGETS=(HWY_AVX2|HWY_AVX3)',], + }], + ['v8_target_arch=="arm64"', { + 'defines': ['HWY_BROKEN_TARGETS=HWY_ALL_SVE',], + }], + ['v8_target_arch=="ppc64" or v8_target_arch=="s390x"', { + 'defines': ['TOOLCHAIN_MISS_ASM_HWCAP_H',], + }], + ['v8_target_arch=="riscv64"', { + 'defines': ['HWY_BROKEN_TARGETS=HWY_RVV',], + }], + ], + 'sources': [ + '