From 7b3eb311a73c1063ad48b01dae55d06ddfd61c6d Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Mon, 4 Dec 2023 17:30:58 +0000 Subject: [PATCH] src: fix dynamically linked zlib version Report the version of the dynamically linked zlib if built with `configure --shared-zlib` instead of the hardcoded version that corresponds to the bundled version of zlib in `deps`. PR-URL: https://github.com/nodejs/node/pull/51007 Refs: https://github.com/nodejs/node/pull/50910 Refs: https://github.com/nodejs/node/pull/50158 Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- node.gypi | 1 + src/node_metadata.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/node.gypi b/node.gypi index 9138317c62c7cd..95133818dff7c7 100644 --- a/node.gypi +++ b/node.gypi @@ -141,6 +141,7 @@ } ], [ 'node_shared_zlib=="false"', { 'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ], + 'defines': [ 'NODE_BUNDLED_ZLIB' ], 'conditions': [ [ 'force_load=="true"', { 'xcode_settings': { diff --git a/src/node_metadata.cc b/src/node_metadata.cc index ffd8d065073fee..14fb8ec9714001 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -15,7 +15,12 @@ #include "uv.h" #include "uvwasi.h" #include "v8.h" + +#ifdef NODE_BUNDLED_ZLIB #include "zlib_version.h" +#else +#include +#endif // NODE_BUNDLED_ZLIB #if HAVE_OPENSSL #include @@ -79,7 +84,11 @@ Metadata::Versions::Versions() { node = NODE_VERSION_STRING; v8 = v8::V8::GetVersion(); uv = uv_version_string(); +#ifdef NODE_BUNDLED_ZLIB zlib = ZLIB_VERSION; +#else + zlib = zlibVersion(); +#endif // NODE_BUNDLED_ZLIB ares = ARES_VERSION_STR; modules = NODE_STRINGIFY(NODE_MODULE_VERSION); nghttp2 = NGHTTP2_VERSION;