Skip to content

Commit 6ef6e8f

Browse files
committed
deps: delete deps/v8/third_party/zlib [1/3]
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
1 parent 3ce303c commit 6ef6e8f

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

deps/zlib/zlib.gyp

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,32 @@
55
{
66
'variables': {
77
'ZLIB_ROOT': '.',
8-
'use_system_zlib%': 0,
98
'arm_fpu%': '',
109
'llvm_version%': '0.0',
1110
},
11+
'targets': [
12+
{
13+
'target_name': 'zlib_google',
14+
'toolsets': ['host', 'target'],
15+
'type': 'static_library',
16+
'sources': [
17+
'<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/google/BUILD.gn" "\\"compression_utils_portable\\".*?sources = ")',
18+
],
19+
'conditions': [
20+
['node_shared_zlib=="false"', {
21+
'include_dirs': [ '<(ZLIB_ROOT)' ] }],
22+
],
23+
},
24+
],
1225
'conditions': [
13-
['use_system_zlib==0', {
26+
['node_shared_zlib=="false"', {
1427
'targets': [
1528
{
1629
'target_name': 'zlib_adler32_simd',
30+
'toolsets': ['host', 'target'],
1731
'type': 'static_library',
1832
'conditions': [
19-
['target_arch in "ia32 x64" and OS!="ios"', {
33+
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
2034
'defines': [ 'ADLER32_SIMD_SSSE3' ],
2135
'conditions': [
2236
['OS=="win"', {
@@ -32,14 +46,14 @@
3246
}],
3347
],
3448
}],
35-
['arm_fpu=="neon"', {
49+
['_toolset=="target" and arm_fpu=="neon"', {
3650
'defines': [ 'ADLER32_SIMD_NEON' ],
3751
}],
3852
],
3953
'include_dirs': [ '<(ZLIB_ROOT)' ],
4054
'direct_dependent_settings': {
4155
'conditions': [
42-
['target_arch in "ia32 x64" and OS!="ios"', {
56+
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
4357
'defines': [ 'ADLER32_SIMD_SSSE3' ],
4458
'conditions': [
4559
['OS=="win"', {
@@ -49,7 +63,7 @@
4963
}],
5064
],
5165
}],
52-
['arm_fpu=="neon"', {
66+
['_toolset=="target" and arm_fpu=="neon"', {
5367
'defines': [ 'ADLER32_SIMD_NEON' ],
5468
}],
5569
],
@@ -61,6 +75,7 @@
6175
}, # zlib_adler32_simd
6276
{
6377
'target_name': 'zlib_arm_crc32',
78+
'toolsets': ['host', 'target'],
6479
'type': 'static_library',
6580
'conditions': [
6681
['OS!="ios"', {
@@ -109,6 +124,7 @@
109124
}, # zlib_arm_crc32
110125
{
111126
'target_name': 'zlib_crc32_simd',
127+
'toolsets': ['host', 'target'],
112128
'type': 'static_library',
113129
'conditions': [
114130
['OS!="win" or llvm_version!="0.0"', {
@@ -136,17 +152,18 @@
136152
}, # zlib_crc32_simd
137153
{
138154
'target_name': 'zlib_inflate_chunk_simd',
155+
'toolsets': ['host', 'target'],
139156
'type': 'static_library',
140157
'conditions': [
141-
['target_arch in "ia32 x64" and OS!="ios"', {
158+
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
142159
'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ],
143160
'conditions': [
144161
['target_arch=="x64"', {
145162
'defines': [ 'INFLATE_CHUNK_READ_64LE' ],
146163
}],
147164
],
148165
}],
149-
['arm_fpu=="neon"', {
166+
['_toolset=="target" and arm_fpu=="neon"', {
150167
'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ],
151168
'conditions': [
152169
['target_arch=="arm64"', {
@@ -158,10 +175,10 @@
158175
'include_dirs': [ '<(ZLIB_ROOT)' ],
159176
'direct_dependent_settings': {
160177
'conditions': [
161-
['target_arch in "ia32 x64" and OS!="ios"', {
178+
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
162179
'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ],
163180
}],
164-
['arm_fpu=="neon"', {
181+
['_toolset=="target" and arm_fpu=="neon"', {
165182
'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ],
166183
}],
167184
],
@@ -173,13 +190,18 @@
173190
}, # zlib_inflate_chunk_simd
174191
{
175192
'target_name': 'zlib',
193+
'toolsets': ['host', 'target'],
176194
'type': 'static_library',
195+
'dependencies': [ 'zlib_google' ],
177196
'sources': [
178197
'<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib\\".*?sources = ")',
179198
],
180199
'include_dirs': [ '<(ZLIB_ROOT)' ],
181200
'direct_dependent_settings': {
182-
'include_dirs': [ '<(ZLIB_ROOT)' ],
201+
'include_dirs': [
202+
'<(ZLIB_ROOT)',
203+
'<(ZLIB_ROOT)/google',
204+
],
183205
},
184206
'conditions': [
185207
['OS!="win"', {
@@ -198,14 +220,14 @@
198220
],
199221
}],
200222
# Incorporate optimizations where possible.
201-
['(target_arch in "ia32 x64" and OS!="ios") or arm_fpu=="neon"', {
223+
['_toolset=="target" and ((target_arch in "ia32 x64" and OS!="ios") or arm_fpu=="neon")', {
202224
'dependencies': [ 'zlib_inflate_chunk_simd' ],
203225
'sources': [ '<(ZLIB_ROOT)/slide_hash_simd.h' ]
204226
}, {
205227
'defines': [ 'CPU_NO_SIMD' ],
206228
'sources': [ '<(ZLIB_ROOT)/inflate.c' ],
207229
}],
208-
['target_arch in "ia32 x64" and OS!="ios"', {
230+
['_toolset=="target" and target_arch in "ia32 x64" and OS!="ios"', {
209231
'dependencies': [
210232
'zlib_adler32_simd',
211233
'zlib_crc32_simd',
@@ -217,7 +239,7 @@
217239
}],
218240
],
219241
}],
220-
['arm_fpu=="neon"', {
242+
['_toolset=="target" and arm_fpu=="neon"', {
221243
'defines': [
222244
'__ARM_NEON__',
223245
'DEFLATE_SLIDE_HASH_NEON',
@@ -247,11 +269,16 @@
247269
'targets': [
248270
{
249271
'target_name': 'zlib',
272+
'toolsets': ['host', 'target'],
250273
'type': 'static_library',
274+
'dependencies': [ 'zlib_google' ],
251275
'direct_dependent_settings': {
252276
'defines': [
253277
'USE_SYSTEM_ZLIB',
254278
],
279+
'include_dirs': [
280+
'<(ZLIB_ROOT)/google',
281+
],
255282
},
256283
'defines': [
257284
'USE_SYSTEM_ZLIB',

0 commit comments

Comments
 (0)