From f4637a7bc4848b382e51f95820e275615970ee99 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Mon, 10 Apr 2023 01:19:41 +0000 Subject: [PATCH] deps: delete deps/v8/third_party/zlib We currently have two copies of Chromium's zlib: one in deps/zlib and another in deps/v8/third_party/zlib. This has a couple of disadvantages: 1. There is an additional cost to keeping both dependencies up-to-date, and in fact they were already out-of-sync (see the refs). 2. People who compile with --shared-zlib (i.e. distro maintainers) will probably not be thrilled to learn that there is still a copy of zlib inside. 3. It's aesthetically unpleasing. This diff (per discussion in the refs) centralizes on deps/zlib and deletes deps/v8/third_party/zlib. That requires changing the include headers in two files in deps/v8/src, which was pretty straightforward. When the user requests compiling with a shared zlib build, we still need to compile the contents of deps/zlib/google. This is not ideal but it's also not a change in behavior: prior to this diff those files were being compiled in the deps/v8/third_party/zlib version. I tested this on Linux with the default build and a --shared-zlib build. I checked that the shared-zlib build dynamically linked zlib according to ldd, and that the regular build did not. I would appreciate if the reviewers could suggest some other build configurations to try. Refs: https://github.com/nodejs/node/pull/47145 Refs: https://github.com/nodejs/node/pull/47157 --- common.gypi | 2 +- deps/v8/src/deoptimizer/translation-array.cc | 2 +- deps/v8/src/snapshot/snapshot-utils.cc | 2 +- deps/zlib/zlib.gyp | 22 ++++++- tools/v8_gypfiles/v8.gyp | 65 +------------------- 5 files changed, 23 insertions(+), 70 deletions(-) diff --git a/common.gypi b/common.gypi index 0dcf428002c4c7..9b37dc9ff581a3 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,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.3', + 'v8_embedder_string': '-node.4', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/deoptimizer/translation-array.cc b/deps/v8/src/deoptimizer/translation-array.cc index 72f1004ddb65c7..fe06e9a5d4ae59 100644 --- a/deps/v8/src/deoptimizer/translation-array.cc +++ b/deps/v8/src/deoptimizer/translation-array.cc @@ -9,7 +9,7 @@ #include "src/objects/fixed-array-inl.h" #ifdef V8_USE_ZLIB -#include "third_party/zlib/google/compression_utils_portable.h" +#include "compression_utils_portable.h" #endif // V8_USE_ZLIB namespace v8 { diff --git a/deps/v8/src/snapshot/snapshot-utils.cc b/deps/v8/src/snapshot/snapshot-utils.cc index 834d003575764f..545993c80c5e0f 100644 --- a/deps/v8/src/snapshot/snapshot-utils.cc +++ b/deps/v8/src/snapshot/snapshot-utils.cc @@ -7,7 +7,7 @@ #include "src/base/sanitizer/msan.h" #ifdef V8_USE_ZLIB -#include "third_party/zlib/zlib.h" +#include "zlib.h" #endif namespace v8 { diff --git a/deps/zlib/zlib.gyp b/deps/zlib/zlib.gyp index 49de2a6c6de903..521e25ca5b5c7f 100644 --- a/deps/zlib/zlib.gyp +++ b/deps/zlib/zlib.gyp @@ -5,12 +5,20 @@ { 'variables': { 'ZLIB_ROOT': '.', - 'use_system_zlib%': 0, 'arm_fpu%': '', 'llvm_version%': '0.0', }, + 'targets': [ + { + 'target_name': 'zlib_google', + 'type': 'static_library', + 'sources': [ + '