Skip to content

Commit

Permalink
deps: update zlib to upstream 8cd0fc1
Browse files Browse the repository at this point in the history
Updated as described in doc/guides/maintaining-zlib.md.
  • Loading branch information
Trott committed Oct 17, 2020
1 parent 8e12cb1 commit 9795eae
Show file tree
Hide file tree
Showing 49 changed files with 2,872 additions and 500 deletions.
196 changes: 132 additions & 64 deletions deps/zlib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

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

if (build_with_chromium) {
import("//testing/test.gni")
}

if (current_cpu == "arm" || current_cpu == "arm64") {
import("//build/config/arm.gni")
}
Expand All @@ -14,10 +18,36 @@ config("zlib_config") {

config("zlib_internal_config") {
defines = [ "ZLIB_IMPLEMENTATION" ]

if (!is_debug) {
# Build code using -O3, see: crbug.com/1084371.
configs = [ "//build/config/compiler:optimize_speed" ]
}
if (is_debug || use_libfuzzer) {
# Enable zlib's asserts in debug and fuzzer builds.
defines += [ "ZLIB_DEBUG" ]
}
}

source_set("zlib_common_headers") {
sources = [
"chromeconf.h",
"deflate.h",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.h",
"zconf.h",
"zlib.h",
"zutil.h",
]
}

use_arm_neon_optimizations = false
if (current_cpu == "arm" || current_cpu == "arm64") {
if ((current_cpu == "arm" || current_cpu == "arm64") &&
!(is_win && !is_clang)) {
# TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
# Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
if (arm_use_neon) {
use_arm_neon_optimizations = true
}
Expand All @@ -29,6 +59,11 @@ use_x86_x64_optimizations =
config("zlib_adler32_simd_config") {
if (use_x86_x64_optimizations) {
defines = [ "ADLER32_SIMD_SSSE3" ]
if (is_win) {
defines += [ "X86_WINDOWS" ]
} else {
defines += [ "X86_NOT_WINDOWS" ]
}
}

if (use_arm_neon_optimizations) {
Expand All @@ -55,16 +90,13 @@ source_set("zlib_adler32_simd") {
"adler32_simd.c",
"adler32_simd.h",
]
if (!is_debug) {
# Use optimize_speed (-O3) to output the _smallest_ code.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}
}

configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_adler32_simd_config" ]

public_deps = [ ":zlib_common_headers" ]
}

if (use_arm_neon_optimizations) {
Expand All @@ -78,6 +110,8 @@ if (use_arm_neon_optimizations) {
defines += [ "ARMV8_OS_ANDROID" ]
} else if (is_linux || is_chromeos) {
defines += [ "ARMV8_OS_LINUX" ]
} else if (is_mac) {
defines += [ "ARMV8_OS_MACOS" ]
} else if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
} else if (is_win) {
Expand All @@ -94,37 +128,23 @@ if (use_arm_neon_optimizations) {
if (!is_ios) {
include_dirs = [ "." ]

if (is_android) {
import("//build/config/android/config.gni")
if (defined(android_ndk_root) && android_ndk_root != "") {
deps = [
"//third_party/android_ndk:cpu_features",
]
} else {
assert(false, "CPU detection requires the Android NDK")
}
} else if (!is_win && !is_clang) {
if (!is_win && !is_clang) {
assert(!use_thin_lto,
"ThinLTO fails mixing different module-level targets")
cflags_c = [ "-march=armv8-a+crc" ]
}

sources = [
"arm_features.c",
"arm_features.h",
"crc32_simd.c",
"crc32_simd.h",
]

if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}
}

configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_arm_crc32_config" ]

public_deps = [ ":zlib_common_headers" ]
}
}

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

if (use_arm_neon_optimizations) {
defines = [ "INFLATE_CHUNK_SIMD_NEON" ]

if (current_cpu == "arm64") {
defines += [ "INFLATE_CHUNK_READ_64LE" ]
}
Expand All @@ -157,22 +178,18 @@ source_set("zlib_inflate_chunk_simd") {
"contrib/optimizations/inffast_chunk.h",
"contrib/optimizations/inflate.c",
]

if (use_arm_neon_optimizations && !is_debug) {
# Here we trade better performance on newer/bigger ARMv8 cores
# for less perf on ARMv7, per crbug.com/772870#c40
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}
}

configs += [ ":zlib_internal_config" ]

# Needed for MSVC, which is still supported by V8 and PDFium. zlib uses K&R C
# style function declarations, which triggers warning C4131.
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":zlib_internal_config",
"//build/config/compiler:no_chromium_code",
]
configs += [ "//build/config/compiler:no_chromium_code" ]

public_configs = [ ":zlib_inflate_chunk_simd_config" ]

public_deps = [ ":zlib_common_headers" ]
}

config("zlib_crc32_simd_config") {
Expand Down Expand Up @@ -201,6 +218,16 @@ source_set("zlib_crc32_simd") {
configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_crc32_simd_config" ]
public_deps = [ ":zlib_common_headers" ]
}

config("zlib_x86_simd_config") {
if (use_x86_x64_optimizations) {
defines = [
"CRC32_SIMD_SSE42_PCLMUL",
"DEFLATE_FILL_WINDOW_SSE2",
]
}
}

source_set("zlib_x86_simd") {
Expand All @@ -218,17 +245,13 @@ source_set("zlib_x86_simd") {
"-mpclmul",
]
}
} else {
sources = [
"simd_stub.c",
]
}

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":zlib_internal_config",
"//build/config/compiler:no_chromium_code",
]
configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_x86_simd_config" ]

public_deps = [ ":zlib_common_headers" ]
}

config("zlib_warnings") {
Expand All @@ -248,6 +271,8 @@ component("zlib") {
"chromeconf.h",
"compress.c",
"contrib/optimizations/insert_string.h",
"cpu_features.c",
"cpu_features.h",
"crc32.c",
"crc32.h",
"deflate.c",
Expand All @@ -267,7 +292,6 @@ component("zlib") {
"trees.c",
"trees.h",
"uncompr.c",
"x86.h",
"zconf.h",
"zlib.h",
"zutil.c",
Expand All @@ -277,14 +301,27 @@ component("zlib") {
defines = []
deps = []

if (!use_x86_x64_optimizations && !use_arm_neon_optimizations) {
# Apparently android_cronet bot builds with NEON disabled and
# we also should disable optimizations for iOS@x86 (a.k.a. simulator).
defines += [ "CPU_NO_SIMD" ]
}

if (is_ios) {
# iOS@ARM is a special case where we always have NEON but don't check
# for crypto extensions.
# TODO(cavalcantii): verify what is the current state of CPU features
# shipped on latest iOS devices.
defines += [ "ARM_OS_IOS" ]
}

if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
deps += [
":zlib_adler32_simd",
":zlib_inflate_chunk_simd",
]

if (use_x86_x64_optimizations) {
sources += [ "x86.c" ]
deps += [ ":zlib_crc32_simd" ]
} else if (use_arm_neon_optimizations) {
sources += [ "contrib/optimizations/slide_hash_neon.h" ]
Expand All @@ -294,18 +331,29 @@ component("zlib") {
sources += [ "inflate.c" ]
}

deps += [ ":zlib_x86_simd" ]

if (is_android) {
import("//build/config/android/config.gni")
if (defined(android_ndk_root) && android_ndk_root != "") {
deps += [ "//third_party/android_ndk:cpu_features" ]
} else {
assert(false, "CPU detection requires the Android NDK")
}
}

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

public_configs = [ ":zlib_config" ]

configs += [
":zlib_internal_config",
"//build/config/compiler:no_chromium_code",

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

public_configs = [ ":zlib_config" ]

deps += [ ":zlib_x86_simd" ]
allow_circular_includes_from = deps
}

Expand Down Expand Up @@ -337,43 +385,63 @@ static_library("minizip") {
]
}

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

deps = [
":zlib",
]
deps = [ ":zlib" ]

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
configs += [ "//build/config/compiler:no_chromium_code" ]

public_configs = [ ":zlib_config" ]

configs += [
# Must be after no_chromium_code for warning flags to be ordered correctly.
":minizip_warnings",
]

public_configs = [ ":zlib_config" ]
}

executable("zlib_bench") {
include_dirs = [ "." ]

sources = [
"contrib/bench/zlib_bench.cc",
]

sources = [ "contrib/bench/zlib_bench.cc" ]
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}

deps = [ ":zlib" ]

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}

deps = [
":zlib",
]
if (build_with_chromium) {
test("zlib_unittests") {
testonly = true

sources = [
"contrib/tests/infcover.cc",
"contrib/tests/infcover.h",
"contrib/tests/run_all_unittests.cc",
"contrib/tests/utils_unittest.cc",
"google/compression_utils_portable.cc",
"google/compression_utils_portable.h",
]

deps = [
":zlib",
"//base/test:test_support",
"//testing/gtest",
]

include_dirs = [
"//third_party/googletest/src/googletest/include/gtest",
".",
"google",
]
}
}
4 changes: 2 additions & 2 deletions deps/zlib/OWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
agl@chromium.org
cavalcantii@chromium.org
cblume@chromium.org
mtklein@chromium.org
scroggo@chromium.org
mtklein@google.com
scroggo@google.com

# COMPONENT: Internals
1 change: 1 addition & 0 deletions deps/zlib/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Name: zlib
Short Name: zlib
URL: http://zlib.net/
Version: 1.2.11
CPEPrefix: cpe:/a:zlib:zlib:1.2.11
Security Critical: yes
License: Custom license
License File: LICENSE
Expand Down
Loading

0 comments on commit 9795eae

Please sign in to comment.