Skip to content

Commit 9795eae

Browse files
committed
deps: update zlib to upstream 8cd0fc1
Updated as described in doc/guides/maintaining-zlib.md.
1 parent 8e12cb1 commit 9795eae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2872
-500
lines changed

deps/zlib/BUILD.gn

+132-64
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
import("//build/config/compiler/compiler.gni")
66

7+
if (build_with_chromium) {
8+
import("//testing/test.gni")
9+
}
10+
711
if (current_cpu == "arm" || current_cpu == "arm64") {
812
import("//build/config/arm.gni")
913
}
@@ -14,10 +18,36 @@ config("zlib_config") {
1418

1519
config("zlib_internal_config") {
1620
defines = [ "ZLIB_IMPLEMENTATION" ]
21+
22+
if (!is_debug) {
23+
# Build code using -O3, see: crbug.com/1084371.
24+
configs = [ "//build/config/compiler:optimize_speed" ]
25+
}
26+
if (is_debug || use_libfuzzer) {
27+
# Enable zlib's asserts in debug and fuzzer builds.
28+
defines += [ "ZLIB_DEBUG" ]
29+
}
30+
}
31+
32+
source_set("zlib_common_headers") {
33+
sources = [
34+
"chromeconf.h",
35+
"deflate.h",
36+
"inffast.h",
37+
"inffixed.h",
38+
"inflate.h",
39+
"inftrees.h",
40+
"zconf.h",
41+
"zlib.h",
42+
"zutil.h",
43+
]
1744
}
1845

1946
use_arm_neon_optimizations = false
20-
if (current_cpu == "arm" || current_cpu == "arm64") {
47+
if ((current_cpu == "arm" || current_cpu == "arm64") &&
48+
!(is_win && !is_clang)) {
49+
# TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
50+
# Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
2151
if (arm_use_neon) {
2252
use_arm_neon_optimizations = true
2353
}
@@ -29,6 +59,11 @@ use_x86_x64_optimizations =
2959
config("zlib_adler32_simd_config") {
3060
if (use_x86_x64_optimizations) {
3161
defines = [ "ADLER32_SIMD_SSSE3" ]
62+
if (is_win) {
63+
defines += [ "X86_WINDOWS" ]
64+
} else {
65+
defines += [ "X86_NOT_WINDOWS" ]
66+
}
3267
}
3368

3469
if (use_arm_neon_optimizations) {
@@ -55,16 +90,13 @@ source_set("zlib_adler32_simd") {
5590
"adler32_simd.c",
5691
"adler32_simd.h",
5792
]
58-
if (!is_debug) {
59-
# Use optimize_speed (-O3) to output the _smallest_ code.
60-
configs -= [ "//build/config/compiler:default_optimization" ]
61-
configs += [ "//build/config/compiler:optimize_speed" ]
62-
}
6393
}
6494

6595
configs += [ ":zlib_internal_config" ]
6696

6797
public_configs = [ ":zlib_adler32_simd_config" ]
98+
99+
public_deps = [ ":zlib_common_headers" ]
68100
}
69101

70102
if (use_arm_neon_optimizations) {
@@ -78,6 +110,8 @@ if (use_arm_neon_optimizations) {
78110
defines += [ "ARMV8_OS_ANDROID" ]
79111
} else if (is_linux || is_chromeos) {
80112
defines += [ "ARMV8_OS_LINUX" ]
113+
} else if (is_mac) {
114+
defines += [ "ARMV8_OS_MACOS" ]
81115
} else if (is_fuchsia) {
82116
defines += [ "ARMV8_OS_FUCHSIA" ]
83117
} else if (is_win) {
@@ -94,37 +128,23 @@ if (use_arm_neon_optimizations) {
94128
if (!is_ios) {
95129
include_dirs = [ "." ]
96130

97-
if (is_android) {
98-
import("//build/config/android/config.gni")
99-
if (defined(android_ndk_root) && android_ndk_root != "") {
100-
deps = [
101-
"//third_party/android_ndk:cpu_features",
102-
]
103-
} else {
104-
assert(false, "CPU detection requires the Android NDK")
105-
}
106-
} else if (!is_win && !is_clang) {
131+
if (!is_win && !is_clang) {
107132
assert(!use_thin_lto,
108133
"ThinLTO fails mixing different module-level targets")
109134
cflags_c = [ "-march=armv8-a+crc" ]
110135
}
111136

112137
sources = [
113-
"arm_features.c",
114-
"arm_features.h",
115138
"crc32_simd.c",
116139
"crc32_simd.h",
117140
]
118-
119-
if (!is_debug) {
120-
configs -= [ "//build/config/compiler:default_optimization" ]
121-
configs += [ "//build/config/compiler:optimize_speed" ]
122-
}
123141
}
124142

125143
configs += [ ":zlib_internal_config" ]
126144

127145
public_configs = [ ":zlib_arm_crc32_config" ]
146+
147+
public_deps = [ ":zlib_common_headers" ]
128148
}
129149
}
130150

@@ -139,6 +159,7 @@ config("zlib_inflate_chunk_simd_config") {
139159

140160
if (use_arm_neon_optimizations) {
141161
defines = [ "INFLATE_CHUNK_SIMD_NEON" ]
162+
142163
if (current_cpu == "arm64") {
143164
defines += [ "INFLATE_CHUNK_READ_64LE" ]
144165
}
@@ -157,22 +178,18 @@ source_set("zlib_inflate_chunk_simd") {
157178
"contrib/optimizations/inffast_chunk.h",
158179
"contrib/optimizations/inflate.c",
159180
]
160-
161-
if (use_arm_neon_optimizations && !is_debug) {
162-
# Here we trade better performance on newer/bigger ARMv8 cores
163-
# for less perf on ARMv7, per crbug.com/772870#c40
164-
configs -= [ "//build/config/compiler:default_optimization" ]
165-
configs += [ "//build/config/compiler:optimize_speed" ]
166-
}
167181
}
168182

183+
configs += [ ":zlib_internal_config" ]
184+
185+
# Needed for MSVC, which is still supported by V8 and PDFium. zlib uses K&R C
186+
# style function declarations, which triggers warning C4131.
169187
configs -= [ "//build/config/compiler:chromium_code" ]
170-
configs += [
171-
":zlib_internal_config",
172-
"//build/config/compiler:no_chromium_code",
173-
]
188+
configs += [ "//build/config/compiler:no_chromium_code" ]
174189

175190
public_configs = [ ":zlib_inflate_chunk_simd_config" ]
191+
192+
public_deps = [ ":zlib_common_headers" ]
176193
}
177194

178195
config("zlib_crc32_simd_config") {
@@ -201,6 +218,16 @@ source_set("zlib_crc32_simd") {
201218
configs += [ ":zlib_internal_config" ]
202219

203220
public_configs = [ ":zlib_crc32_simd_config" ]
221+
public_deps = [ ":zlib_common_headers" ]
222+
}
223+
224+
config("zlib_x86_simd_config") {
225+
if (use_x86_x64_optimizations) {
226+
defines = [
227+
"CRC32_SIMD_SSE42_PCLMUL",
228+
"DEFLATE_FILL_WINDOW_SSE2",
229+
]
230+
}
204231
}
205232

206233
source_set("zlib_x86_simd") {
@@ -218,17 +245,13 @@ source_set("zlib_x86_simd") {
218245
"-mpclmul",
219246
]
220247
}
221-
} else {
222-
sources = [
223-
"simd_stub.c",
224-
]
225248
}
226249

227-
configs -= [ "//build/config/compiler:chromium_code" ]
228-
configs += [
229-
":zlib_internal_config",
230-
"//build/config/compiler:no_chromium_code",
231-
]
250+
configs += [ ":zlib_internal_config" ]
251+
252+
public_configs = [ ":zlib_x86_simd_config" ]
253+
254+
public_deps = [ ":zlib_common_headers" ]
232255
}
233256

234257
config("zlib_warnings") {
@@ -248,6 +271,8 @@ component("zlib") {
248271
"chromeconf.h",
249272
"compress.c",
250273
"contrib/optimizations/insert_string.h",
274+
"cpu_features.c",
275+
"cpu_features.h",
251276
"crc32.c",
252277
"crc32.h",
253278
"deflate.c",
@@ -267,7 +292,6 @@ component("zlib") {
267292
"trees.c",
268293
"trees.h",
269294
"uncompr.c",
270-
"x86.h",
271295
"zconf.h",
272296
"zlib.h",
273297
"zutil.c",
@@ -277,14 +301,27 @@ component("zlib") {
277301
defines = []
278302
deps = []
279303

304+
if (!use_x86_x64_optimizations && !use_arm_neon_optimizations) {
305+
# Apparently android_cronet bot builds with NEON disabled and
306+
# we also should disable optimizations for iOS@x86 (a.k.a. simulator).
307+
defines += [ "CPU_NO_SIMD" ]
308+
}
309+
310+
if (is_ios) {
311+
# iOS@ARM is a special case where we always have NEON but don't check
312+
# for crypto extensions.
313+
# TODO(cavalcantii): verify what is the current state of CPU features
314+
# shipped on latest iOS devices.
315+
defines += [ "ARM_OS_IOS" ]
316+
}
317+
280318
if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
281319
deps += [
282320
":zlib_adler32_simd",
283321
":zlib_inflate_chunk_simd",
284322
]
285323

286324
if (use_x86_x64_optimizations) {
287-
sources += [ "x86.c" ]
288325
deps += [ ":zlib_crc32_simd" ]
289326
} else if (use_arm_neon_optimizations) {
290327
sources += [ "contrib/optimizations/slide_hash_neon.h" ]
@@ -294,18 +331,29 @@ component("zlib") {
294331
sources += [ "inflate.c" ]
295332
}
296333

334+
deps += [ ":zlib_x86_simd" ]
335+
336+
if (is_android) {
337+
import("//build/config/android/config.gni")
338+
if (defined(android_ndk_root) && android_ndk_root != "") {
339+
deps += [ "//third_party/android_ndk:cpu_features" ]
340+
} else {
341+
assert(false, "CPU detection requires the Android NDK")
342+
}
343+
}
344+
297345
configs -= [ "//build/config/compiler:chromium_code" ]
346+
configs += [ "//build/config/compiler:no_chromium_code" ]
347+
348+
public_configs = [ ":zlib_config" ]
349+
298350
configs += [
299351
":zlib_internal_config",
300-
"//build/config/compiler:no_chromium_code",
301352

302353
# Must be after no_chromium_code for warning flags to be ordered correctly.
303354
":zlib_warnings",
304355
]
305356

306-
public_configs = [ ":zlib_config" ]
307-
308-
deps += [ ":zlib_x86_simd" ]
309357
allow_circular_includes_from = deps
310358
}
311359

@@ -337,43 +385,63 @@ static_library("minizip") {
337385
]
338386
}
339387

340-
if (is_mac || is_ios || is_android || is_nacl) {
388+
if (is_apple || is_android || is_nacl) {
341389
# Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
342390
# use fopen, ftell, and fseek instead on these systems.
343391
defines = [ "USE_FILE32API" ]
344392
}
345393

346-
deps = [
347-
":zlib",
348-
]
394+
deps = [ ":zlib" ]
349395

350396
configs -= [ "//build/config/compiler:chromium_code" ]
351-
configs += [
352-
"//build/config/compiler:no_chromium_code",
397+
configs += [ "//build/config/compiler:no_chromium_code" ]
353398

399+
public_configs = [ ":zlib_config" ]
400+
401+
configs += [
354402
# Must be after no_chromium_code for warning flags to be ordered correctly.
355403
":minizip_warnings",
356404
]
357-
358-
public_configs = [ ":zlib_config" ]
359405
}
360406

361407
executable("zlib_bench") {
362408
include_dirs = [ "." ]
363409

364-
sources = [
365-
"contrib/bench/zlib_bench.cc",
366-
]
367-
410+
sources = [ "contrib/bench/zlib_bench.cc" ]
368411
if (!is_debug) {
369412
configs -= [ "//build/config/compiler:default_optimization" ]
370413
configs += [ "//build/config/compiler:optimize_speed" ]
371414
}
372415

416+
deps = [ ":zlib" ]
417+
373418
configs -= [ "//build/config/compiler:chromium_code" ]
374419
configs += [ "//build/config/compiler:no_chromium_code" ]
420+
}
375421

376-
deps = [
377-
":zlib",
378-
]
422+
if (build_with_chromium) {
423+
test("zlib_unittests") {
424+
testonly = true
425+
426+
sources = [
427+
"contrib/tests/infcover.cc",
428+
"contrib/tests/infcover.h",
429+
"contrib/tests/run_all_unittests.cc",
430+
"contrib/tests/utils_unittest.cc",
431+
"google/compression_utils_portable.cc",
432+
"google/compression_utils_portable.h",
433+
]
434+
435+
deps = [
436+
":zlib",
437+
"//base/test:test_support",
438+
"//testing/gtest",
439+
]
440+
441+
include_dirs = [
442+
"//third_party/googletest/src/googletest/include/gtest",
443+
".",
444+
"google",
445+
]
446+
}
379447
}

deps/zlib/OWNERS

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
agl@chromium.org
22
cavalcantii@chromium.org
33
cblume@chromium.org
4-
mtklein@chromium.org
5-
scroggo@chromium.org
4+
mtklein@google.com
5+
scroggo@google.com
66

77
# COMPONENT: Internals

deps/zlib/README.chromium

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Name: zlib
22
Short Name: zlib
33
URL: http://zlib.net/
44
Version: 1.2.11
5+
CPEPrefix: cpe:/a:zlib:zlib:1.2.11
56
Security Critical: yes
67
License: Custom license
78
License File: LICENSE

0 commit comments

Comments
 (0)