From 842448b1ee8c0a7b428c4550b2e9eac6f8659944 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 4 Jan 2026 19:00:14 +0100 Subject: [PATCH] build: add `--shared-hdr-histogram` configure flag PR-URL: https://github.com/nodejs/node/pull/61280 Reviewed-By: Colin Ihrig Reviewed-By: Marco Ippolito --- .github/workflows/test-shared.yml | 2 ++ Makefile | 1 + configure.py | 23 ++++++++++++++ node.gyp | 52 ++++++++++++++++++++++++------- tools/nix/sharedLibDeps.nix | 1 + 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index e8796501ccbb0d..9ac028af6e6fa2 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -19,6 +19,7 @@ on: - deps/crates/** - deps/corepack/** - deps/googletest/** + - deps/histogram/** - deps/icu-small/** - deps/icu-tmp/** - deps/llhttp/** @@ -66,6 +67,7 @@ on: - deps/crates/** - deps/corepack/** - deps/googletest/** + - deps/histogram/** - deps/icu-small/** - deps/icu-tmp/** - deps/llhttp/** diff --git a/Makefile b/Makefile index 0b9ccf58a57e64..5afee2318c9bca 100644 --- a/Makefile +++ b/Makefile @@ -1238,6 +1238,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1) $(RM) -r $(TARNAME)/deps/cares $(RM) -r $(TARNAME)/deps/crates $(RM) -r $(TARNAME)/deps/googletest + $(RM) -r $(TARNAME)/deps/histogram $(RM) -r $(TARNAME)/deps/icu-small $(RM) -r $(TARNAME)/deps/icu-tmp $(RM) -r $(TARNAME)/deps/llhttp diff --git a/configure.py b/configure.py index d767a0118e86ff..c83a7ec8c18207 100755 --- a/configure.py +++ b/configure.py @@ -285,6 +285,28 @@ dest='shared_gtest_libpath', help='a directory to search for the shared googletest DLL') +shared_optgroup.add_argument('--shared-hdr-histogram', + action='store_true', + dest='shared_hdr_histogram', + default=None, + help='link to a shared HdrHistogram DLL instead of static linking') + +shared_optgroup.add_argument('--shared-hdr-histogram-includes', + action='store', + dest='shared_hdr_histogram_includes', + help='directory containing HdrHistogram header files') + +shared_optgroup.add_argument('--shared-hdr-histogram-libname', + action='store', + dest='shared_hdr_histogram_libname', + default='hdr_histogram', + help='alternative lib name to link to [default: %(default)s]') + +shared_optgroup.add_argument('--shared-hdr-histogram-libpath', + action='store', + dest='shared_hdr_histogram_libpath', + help='a directory to search for the shared HdrHistogram DLL') + parser.add_argument('--experimental-http-parser', action='store_true', dest='experimental_http_parser', @@ -2432,6 +2454,7 @@ def make_bin_override(): configure_library('brotli', output, pkgname=['libbrotlidec', 'libbrotlienc']) configure_library('cares', output, pkgname='libcares') configure_library('gtest', output) +configure_library('hdr_histogram', output) configure_library('nghttp2', output, pkgname='libnghttp2') configure_library('nghttp3', output, pkgname='libnghttp3') configure_library('ngtcp2', output, pkgname='libngtcp2') diff --git a/node.gyp b/node.gyp index babaf33c59f637..df8d67d39db212 100644 --- a/node.gyp +++ b/node.gyp @@ -15,6 +15,7 @@ 'node_shared_brotli%': 'false', 'node_shared_cares%': 'false', 'node_shared_gtest%': 'false', + 'node_shared_hdr_histogram%': 'false', 'node_shared_http_parser%': 'false', 'node_shared_libuv%': 'false', 'node_shared_nghttp2%': 'false', @@ -572,10 +573,6 @@ 'src/node_main.cc' ], - 'dependencies': [ - 'deps/histogram/histogram.gyp:histogram', - ], - 'msvs_settings': { 'VCLinkerTool': { 'GenerateMapFile': 'true', # /MAP @@ -597,6 +594,11 @@ 'msvs_disabled_warnings!': [4244], 'conditions': [ + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], [ 'error_on_warn=="true"', { 'cflags': ['-Werror'], 'xcode_settings': { @@ -866,7 +868,6 @@ '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h ], 'dependencies': [ - 'deps/histogram/histogram.gyp:histogram', 'deps/nbytes/nbytes.gyp:nbytes', 'tools/v8_gypfiles/abseil.gyp:abseil', 'node_js2c#host', @@ -934,6 +935,11 @@ 'deps/googletest/googletest.gyp:gtest_prod', ], }], + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], [ 'node_use_sqlite=="true"', { 'sources': [ '<@(node_sqlite_sources)', @@ -1071,7 +1077,6 @@ 'type': 'executable', 'dependencies': [ '<(node_lib_target_name)', - 'deps/histogram/histogram.gyp:histogram', ], 'includes': [ @@ -1096,6 +1101,11 @@ 'test/fuzzers/fuzz_env.cc', ], 'conditions': [ + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], ['OS=="linux" or OS=="openharmony"', { 'ldflags': [ '-fsanitize=fuzzer' ] }], @@ -1114,7 +1124,6 @@ 'type': 'executable', 'dependencies': [ '<(node_lib_target_name)', - 'deps/histogram/histogram.gyp:histogram', ], 'includes': [ 'node.gypi' @@ -1137,6 +1146,11 @@ 'test/fuzzers/fuzz_ClientHelloParser.cc', ], 'conditions': [ + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], [ 'node_shared_uvwasi=="false"', { 'dependencies': [ 'deps/uvwasi/uvwasi.gyp:uvwasi' ], 'include_dirs': [ 'deps/uvwasi/include' ], @@ -1159,7 +1173,6 @@ 'type': 'executable', 'dependencies': [ '<(node_lib_target_name)', - 'deps/histogram/histogram.gyp:histogram', 'deps/nbytes/nbytes.gyp:nbytes', ], 'includes': [ @@ -1188,6 +1201,11 @@ 'deps/googletest/googletest.gyp:gtest_prod', ], }], + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], [ 'node_shared_uvwasi=="false"', { 'dependencies': [ 'deps/uvwasi/uvwasi.gyp:uvwasi' ], 'include_dirs': [ 'deps/uvwasi/include' ], @@ -1211,7 +1229,6 @@ 'dependencies': [ '<(node_lib_target_name)', - 'deps/histogram/histogram.gyp:histogram', 'deps/nbytes/nbytes.gyp:nbytes', 'tools/v8_gypfiles/abseil.gyp:abseil', ], @@ -1247,6 +1264,11 @@ [ 'node_shared_gtest=="true"', { 'libraries': [ '-lgtest_main' ], }], + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], [ 'node_use_openssl=="true"', { 'defines': [ 'HAVE_OPENSSL=1', @@ -1307,7 +1329,6 @@ 'dependencies': [ '<(node_lib_target_name)', - 'deps/histogram/histogram.gyp:histogram', 'deps/nbytes/nbytes.gyp:nbytes', ], @@ -1343,6 +1364,11 @@ 'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ], }, }], + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], ['OS=="win"', { 'libraries': [ 'Dbghelp.lib', @@ -1429,7 +1455,6 @@ 'dependencies': [ '<(node_lib_target_name)', - 'deps/histogram/histogram.gyp:histogram', 'deps/nbytes/nbytes.gyp:nbytes', ], @@ -1462,6 +1487,11 @@ ['node_write_snapshot_as_array_literals=="true"', { 'defines': [ 'NODE_MKSNAPSHOT_USE_ARRAY_LITERALS=1' ], }], + [ 'node_shared_hdr_histogram=="false"', { + 'dependencies': [ + 'deps/histogram/histogram.gyp:histogram', + ], + }], [ 'node_use_openssl=="true"', { 'dependencies': [ 'deps/ncrypto/ncrypto.gyp:ncrypto', diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index b1003d3f82e7d3..3e0b25f25250df 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -19,6 +19,7 @@ zlib zstd ; + hdr-histogram = pkgs.hdrhistogram_c; http-parser = pkgs.llhttp; nghttp2 = pkgs.nghttp2.overrideAttrs { patches = [