|
4 | 4 |
|
5 | 5 | {
|
6 | 6 | 'variables': {
|
| 7 | + 'ZLIB_ROOT': '.', |
7 | 8 | 'use_system_zlib%': 0,
|
8 | 9 | 'arm_fpu%': '',
|
9 | 10 | 'llvm_version%': '0.0',
|
|
12 | 13 | ['use_system_zlib==0', {
|
13 | 14 | 'targets': [
|
14 | 15 | {
|
15 |
| - 'target_name': 'zlib', |
| 16 | + 'target_name': 'zlib_adler32_simd', |
| 17 | + 'type': 'static_library', |
| 18 | + 'conditions': [ |
| 19 | + ['(target_arch in "ia32 x64 x32" and OS!="ios") or arm_fpu=="neon"', { |
| 20 | + 'defines': [ 'ADLER32_SIMD_SSSE3' ], |
| 21 | + 'conditions': [ |
| 22 | + ['OS=="win"', { |
| 23 | + 'defines': [ 'X86_WINDOWS' ], |
| 24 | + },{ |
| 25 | + 'defines': [ 'X86_NOT_WINDOWS' ], |
| 26 | + }], |
| 27 | + ['OS!="win" or llvm_version!="0.0"', { |
| 28 | + 'cflags': [ '-mssse3' ], |
| 29 | + }], |
| 30 | + ], |
| 31 | + }], |
| 32 | + ['arm_fpu=="neon"', { |
| 33 | + 'defines': [ 'ADLER32_SIMD_NEON' ], |
| 34 | + }], |
| 35 | + ], |
| 36 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 37 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
| 38 | + 'direct_dependent_settings': { |
| 39 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 40 | + }, |
| 41 | + 'sources': [ |
| 42 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_adler32_simd\\".*?sources = ")', |
| 43 | + ], |
| 44 | + }, # zlib_adler32_simd |
| 45 | + { |
| 46 | + 'target_name': 'zlib_arm_crc32', |
| 47 | + 'type': 'static_library', |
| 48 | + 'conditions': [ |
| 49 | + ['OS!="ios"', { |
| 50 | + 'conditions': [ |
| 51 | + ['OS!="win" and llvm_version!="0.0"', { |
| 52 | + 'cflags': [ '-march=armv8-a+crc' ], |
| 53 | + }], |
| 54 | + ['OS=="android"', { |
| 55 | + 'defines': [ 'ARMV8_OS_ANDROID' ], |
| 56 | + }], |
| 57 | + ['OS=="linux"', { |
| 58 | + 'defines': [ 'ARMV8_OS_LINUX' ], |
| 59 | + }], |
| 60 | + ['OS=="win"', { |
| 61 | + 'defines': [ 'ARMV8_OS_WINDOWS' ], |
| 62 | + }], |
| 63 | + ], |
| 64 | + 'defines': [ 'CRC32_ARMV8_CRC32' ], |
| 65 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 66 | + 'direct_dependent_settings': { |
| 67 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 68 | + }, |
| 69 | + 'sources': [ |
| 70 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_arm_crc32\\".*?sources = ")', |
| 71 | + ], |
| 72 | + }], |
| 73 | + ], |
| 74 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
| 75 | + }, # zlib_arm_crc32 |
| 76 | + { |
| 77 | + 'target_name': 'zlib_inflate_chunk_simd', |
| 78 | + 'type': 'static_library', |
| 79 | + 'conditions': [ |
| 80 | + ['(target_arch in "ia32 x64 x32" and OS!="ios")', { |
| 81 | + 'defines': [ 'INFLATE_CHUNK_SIMD_SSE2' ], |
| 82 | + 'conditions': [ |
| 83 | + ['target_arch=="x64"', { |
| 84 | + 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
| 85 | + }], |
| 86 | + ], |
| 87 | + }], |
| 88 | + ['arm_fpu=="neon"', { |
| 89 | + 'defines': [ 'INFLATE_CHUNK_SIMD_NEON' ], |
| 90 | + 'conditions': [ |
| 91 | + ['target_arch=="arm64"', { |
| 92 | + 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
| 93 | + }], |
| 94 | + ], |
| 95 | + }] |
| 96 | + ], |
| 97 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 98 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
| 99 | + 'direct_dependent_settings': { |
| 100 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 101 | + }, |
| 102 | + 'sources': [ |
| 103 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_inflate_chunk_simd\\".*?sources = ")', |
| 104 | + ], |
| 105 | + }, # zlib_inflate_chunk_simd |
| 106 | + { |
| 107 | + 'target_name': 'zlib_crc32_simd', |
16 | 108 | 'type': 'static_library',
|
| 109 | + 'conditions': [ |
| 110 | + ['OS!="win" or llvm_version!="0.0"', { |
| 111 | + 'cflags': [ |
| 112 | + '-msse4.2', |
| 113 | + '-mpclmul', |
| 114 | + ], |
| 115 | + }] |
| 116 | + ], |
| 117 | + 'defines': [ |
| 118 | + 'CRC32_SIMD_SSE42_PCLMUL', |
| 119 | + 'ZLIB_IMPLEMENTATION', |
| 120 | + ], |
| 121 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 122 | + 'direct_dependent_settings': { |
| 123 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 124 | + }, |
17 | 125 | 'sources': [
|
18 |
| - 'adler32.c', |
19 |
| - 'compress.c', |
20 |
| - 'contrib/optimizations/insert_string.h', |
21 |
| - 'crc32.c', |
22 |
| - 'crc32.h', |
23 |
| - 'deflate.c', |
24 |
| - 'deflate.h', |
25 |
| - 'gzclose.c', |
26 |
| - 'gzguts.h', |
27 |
| - 'gzlib.c', |
28 |
| - 'gzread.c', |
29 |
| - 'gzwrite.c', |
30 |
| - 'infback.c', |
31 |
| - 'inffast.c', |
32 |
| - 'inffast.h', |
33 |
| - 'inffixed.h', |
34 |
| - 'inflate.h', |
35 |
| - 'inftrees.c', |
36 |
| - 'inftrees.h', |
37 |
| - 'trees.c', |
38 |
| - 'trees.h', |
39 |
| - 'uncompr.c', |
40 |
| - 'x86.h', |
41 |
| - 'zconf.h', |
42 |
| - 'zlib.h', |
43 |
| - 'zutil.c', |
44 |
| - 'zutil.h', |
| 126 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_crc32_simd\\".*?sources = ")', |
45 | 127 | ],
|
46 |
| - 'include_dirs': [ |
47 |
| - '.', |
| 128 | + }, # zlib_crc32_simd |
| 129 | + { |
| 130 | + 'target_name': 'zlib_x86_simd', |
| 131 | + 'type': 'static_library', |
| 132 | + 'conditions': [ |
| 133 | + ['OS!="win" or llvm_version!="0.0"', { |
| 134 | + 'cflags': [ |
| 135 | + '-msse4.2', |
| 136 | + '-mpclmul', |
| 137 | + ], |
| 138 | + }] |
48 | 139 | ],
|
| 140 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 141 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
49 | 142 | 'direct_dependent_settings': {
|
50 |
| - 'include_dirs': [ |
51 |
| - '.', |
52 |
| - ], |
| 143 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 144 | + }, |
| 145 | + 'sources': [ |
| 146 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib_x86_simd\\".*?sources = ")', |
| 147 | + ], |
| 148 | + }, # zlib_x86_simd |
| 149 | + { |
| 150 | + 'target_name': 'zlib', |
| 151 | + 'type': 'static_library', |
| 152 | + 'sources': [ |
| 153 | + '<!@pymod_do_main(GN-scraper "<(ZLIB_ROOT)/BUILD.gn" "\\"zlib\\".*?sources = ")', |
| 154 | + ], |
| 155 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
| 156 | + 'direct_dependent_settings': { |
| 157 | + 'include_dirs': [ '<(ZLIB_ROOT)' ], |
53 | 158 | },
|
54 | 159 | 'conditions': [
|
55 | 160 | ['OS!="win"', {
|
|
64 | 169 | 'USE_FILE32API'
|
65 | 170 | ],
|
66 | 171 | }],
|
67 |
| - ['(target_arch in "ia32 x64 x32" and OS!="ios") or arm_fpu=="neon"', { |
68 |
| - 'sources': [ |
69 |
| - 'adler32_simd.c', |
70 |
| - 'adler32_simd.h', |
71 |
| - 'contrib/optimizations/chunkcopy.h', |
72 |
| - 'contrib/optimizations/inffast_chunk.c', |
73 |
| - 'contrib/optimizations/inffast_chunk.h', |
74 |
| - 'contrib/optimizations/inflate.c', |
| 172 | + # Incorporate optimizations where possible. |
| 173 | + # Optimizations not enabled for x86 as problems were reported, |
| 174 | + # https://github.com/nodejs/node/issues/33019. |
| 175 | + ['(target_arch in "x64 x32" and OS!="ios") or arm_fpu=="neon"', { |
| 176 | + 'dependencies': [ |
| 177 | + 'zlib_adler32_simd', |
| 178 | + 'zlib_inflate_chunk_simd', |
75 | 179 | ],
|
76 | 180 | }, {
|
77 |
| - 'sources': [ 'inflate.c', ], |
| 181 | + 'defines': [ 'CPU_NO_SIMD' ], |
| 182 | + 'sources': [ '<(ZLIB_ROOT)/inflate.c', ], |
78 | 183 | }],
|
79 |
| - # Incorporate optimizations where possible |
80 | 184 | ['target_arch in "ia32 x64 x32" and OS!="ios"', {
|
81 |
| - 'defines': [ |
82 |
| - 'ADLER32_SIMD_SSSE3', |
83 |
| - 'INFLATE_CHUNK_SIMD_SSE2', |
84 |
| - 'CRC32_SIMD_SSE42_PCLMUL', |
| 185 | + 'dependencies': [ |
| 186 | + 'zlib_crc32_simd', |
| 187 | + 'zlib_x86_simd', |
85 | 188 | ],
|
86 | 189 | 'sources': [
|
87 |
| - 'crc32_simd.c', |
88 |
| - 'crc32_simd.h', |
89 |
| - 'crc_folding.c', |
90 |
| - 'fill_window_sse.c', |
91 |
| - 'x86.c', |
92 |
| - ], |
93 |
| - 'conditions': [ |
94 |
| - ['target_arch=="x64"', { |
95 |
| - 'defines': [ 'INFLATE_CHUNK_READ_64LE' ], |
96 |
| - }], |
| 190 | + '<(ZLIB_ROOT)/x86.c', |
97 | 191 | ],
|
98 |
| - }, { |
99 |
| - 'sources': [ 'simd_stub.c', ], |
| 192 | + },{ |
| 193 | + 'sources': [ '<(ZLIB_ROOT)/simd_stub.c' ], |
100 | 194 | }],
|
101 | 195 | ['arm_fpu=="neon"', {
|
102 |
| - 'defines': [ |
103 |
| - 'ADLER32_SIMD_NEON', |
104 |
| - 'INFLATE_CHUNK_SIMD_NEON', |
105 |
| - ], |
| 196 | + 'dependencies': [ 'zlib_arm_crc32' ], |
106 | 197 | 'sources': [
|
107 | 198 | 'contrib/optimizations/slide_hash_neon.h',
|
108 | 199 | ],
|
|
138 | 229 | ],
|
139 | 230 | }],
|
140 | 231 | ],
|
| 232 | + 'defines': [ 'ZLIB_IMPLEMENTATION' ], |
141 | 233 | },
|
142 | 234 | ],
|
143 | 235 | }, {
|
|
0 commit comments