Skip to content

Commit

Permalink
deps: delete deps/v8/third_party/zlib [1/3]
Browse files Browse the repository at this point in the history
This is the first of a series of patches. This patch is contains changes
to the existing zlib.gyp file to allow it to be used by our v8.gyp.

---

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.

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: nodejs#47145
Refs: nodejs#47157
  • Loading branch information
kvakil committed Jun 22, 2023
1 parent 3ce303c commit 6ef6e8f
Showing 1 changed file with 41 additions and 14 deletions.
55 changes: 41 additions & 14 deletions deps/zlib/zlib.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,32 @@
{
'variables': {
'ZLIB_ROOT': '.',
'use_system_zlib%': 0,
'arm_fpu%': '',
'llvm_version%': '0.0',
},
'targets': [
{
'target_name': 'zlib_google',
'toolsets': ['host', 'target'],
'type': 'static_library',
'sources': [
'<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/google/BUILD.gn" "\\"compression_utils_portable\\".*?sources = ")',
],
'conditions': [
['node_shared_zlib=="false"', {
'include_dirs': [ '<(ZLIB_ROOT)' ] }],
],
},
],
'conditions': [
['use_system_zlib==0', {
['node_shared_zlib=="false"', {
'targets': [
{
'target_name': 'zlib_adler32_simd',
'toolsets': ['host', 'target'],
'type': 'static_library',
'conditions': [
['target_arch in "ia32 x64" and OS!="ios"', {
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
'defines': [ 'ADLER32_SIMD_SSSE3' ],
'conditions': [
['OS=="win"', {
Expand All @@ -32,14 +46,14 @@
}],
],
}],
['arm_fpu=="neon"', {
['_toolset=="target" and arm_fpu=="neon"', {
'defines': [ 'ADLER32_SIMD_NEON' ],
}],
],
'include_dirs': [ '<(ZLIB_ROOT)' ],
'direct_dependent_settings': {
'conditions': [
['target_arch in "ia32 x64" and OS!="ios"', {
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
'defines': [ 'ADLER32_SIMD_SSSE3' ],
'conditions': [
['OS=="win"', {
Expand All @@ -49,7 +63,7 @@
}],
],
}],
['arm_fpu=="neon"', {
['_toolset=="target" and arm_fpu=="neon"', {
'defines': [ 'ADLER32_SIMD_NEON' ],
}],
],
Expand All @@ -61,6 +75,7 @@
}, # zlib_adler32_simd
{
'target_name': 'zlib_arm_crc32',
'toolsets': ['host', 'target'],
'type': 'static_library',
'conditions': [
['OS!="ios"', {
Expand Down Expand Up @@ -109,6 +124,7 @@
}, # zlib_arm_crc32
{
'target_name': 'zlib_crc32_simd',
'toolsets': ['host', 'target'],
'type': 'static_library',
'conditions': [
['OS!="win" or llvm_version!="0.0"', {
Expand Down Expand Up @@ -136,17 +152,18 @@
}, # zlib_crc32_simd
{
'target_name': 'zlib_inflate_chunk_simd',
'toolsets': ['host', 'target'],
'type': 'static_library',
'conditions': [
['target_arch in "ia32 x64" and OS!="ios"', {
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ],
'conditions': [
['target_arch=="x64"', {
'defines': [ 'INFLATE_CHUNK_READ_64LE' ],
}],
],
}],
['arm_fpu=="neon"', {
['_toolset=="target" and arm_fpu=="neon"', {
'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ],
'conditions': [
['target_arch=="arm64"', {
Expand All @@ -158,10 +175,10 @@
'include_dirs': [ '<(ZLIB_ROOT)' ],
'direct_dependent_settings': {
'conditions': [
['target_arch in "ia32 x64" and OS!="ios"', {
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ],
}],
['arm_fpu=="neon"', {
['_toolset=="target" and arm_fpu=="neon"', {
'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ],
}],
],
Expand All @@ -173,13 +190,18 @@
}, # zlib_inflate_chunk_simd
{
'target_name': 'zlib',
'toolsets': ['host', 'target'],
'type': 'static_library',
'dependencies': [ 'zlib_google' ],
'sources': [
'<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib\\".*?sources = ")',
],
'include_dirs': [ '<(ZLIB_ROOT)' ],
'direct_dependent_settings': {
'include_dirs': [ '<(ZLIB_ROOT)' ],
'include_dirs': [
'<(ZLIB_ROOT)',
'<(ZLIB_ROOT)/google',
],
},
'conditions': [
['OS!="win"', {
Expand All @@ -198,14 +220,14 @@
],
}],
# Incorporate optimizations where possible.
['(target_arch in "ia32 x64" and OS!="ios") or arm_fpu=="neon"', {
['_toolset=="target" and ((target_arch in "ia32 x64" and OS!="ios") or arm_fpu=="neon")', {
'dependencies': [ 'zlib_inflate_chunk_simd' ],
'sources': [ '<(ZLIB_ROOT)/slide_hash_simd.h' ]
}, {
'defines': [ 'CPU_NO_SIMD' ],
'sources': [ '<(ZLIB_ROOT)/inflate.c' ],
}],
['target_arch in "ia32 x64" and OS!="ios"', {
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
'dependencies': [
'zlib_adler32_simd',
'zlib_crc32_simd',
Expand All @@ -217,7 +239,7 @@
}],
],
}],
['arm_fpu=="neon"', {
['_toolset=="target" and arm_fpu=="neon"', {
'defines': [
'__ARM_NEON__',
'DEFLATE_SLIDE_HASH_NEON',
Expand Down Expand Up @@ -247,11 +269,16 @@
'targets': [
{
'target_name': 'zlib',
'toolsets': ['host', 'target'],
'type': 'static_library',
'dependencies': [ 'zlib_google' ],
'direct_dependent_settings': {
'defines': [
'USE_SYSTEM_ZLIB',
],
'include_dirs': [
'<(ZLIB_ROOT)/google',
],
},
'defines': [
'USE_SYSTEM_ZLIB',
Expand Down

0 comments on commit 6ef6e8f

Please sign in to comment.