From f52c03db4e8f3d89b812f572efd18968f2a19c32 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 6 Aug 2023 00:23:29 +0000 Subject: [PATCH] deps: update zlib to 1.2.13.1-motley-526382e PR-URL: https://github.com/nodejs/node/pull/49033 Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh --- deps/zlib/BUILD.gn | 5 ++ deps/zlib/CMakeLists.txt | 14 +++ deps/zlib/adler32.c | 4 +- deps/zlib/contrib/minizip/README.chromium | 1 + deps/zlib/contrib/minizip/ioapi.h | 2 +- deps/zlib/contrib/minizip/mztools.c | 2 +- deps/zlib/contrib/minizip/mztools.h | 2 +- deps/zlib/contrib/minizip/unzip.c | 2 +- deps/zlib/contrib/minizip/unzip.h | 2 +- deps/zlib/contrib/minizip/zip.c | 2 +- deps/zlib/contrib/minizip/zip.h | 2 +- deps/zlib/patches/0000-build.patch | 87 ------------------- .../0013-cpu-feature-detection-for-arm.patch | 30 +++++++ .../maintaining/maintaining-dependencies.md | 6 +- 14 files changed, 62 insertions(+), 99 deletions(-) create mode 100644 deps/zlib/patches/0013-cpu-feature-detection-for-arm.patch diff --git a/deps/zlib/BUILD.gn b/deps/zlib/BUILD.gn index 074c2720fa460d..ecf2a095bcb9b1 100644 --- a/deps/zlib/BUILD.gn +++ b/deps/zlib/BUILD.gn @@ -385,6 +385,11 @@ config("minizip_warnings") { } static_library("minizip") { + include_dirs = [ + ".", + "//third_party/zlib", + ] + sources = [ "contrib/minizip/ioapi.c", "contrib/minizip/ioapi.h", diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt index 378a3792f4ba8f..471a3a46a09dd6 100644 --- a/deps/zlib/CMakeLists.txt +++ b/deps/zlib/CMakeLists.txt @@ -23,6 +23,11 @@ check_include_file(stddef.h HAVE_STDDEF_H) option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF) option(ENABLE_SIMD_AVX512 "Enable SIMD AXV512 optimizations" OFF) +option(USE_ZLIB_RABIN_KARP_HASH "Enable bitstream compatibility with canonical zlib" OFF) + +if (USE_ZLIB_RABIN_KARP_HASH) + add_definitions(-DUSE_ZLIB_RABIN_KARP_ROLLING_HASH) +endif() # TODO(cavalcantii): add support for other OSes (e.g. Android, fuchsia, osx) # and architectures (e.g. Arm). @@ -238,3 +243,12 @@ enable_language(CXX) set(CMAKE_CXX_STANDARD 14) # workaround for older compilers (e.g. g++ 5.4). add_executable(zlib_bench contrib/bench/zlib_bench.cc) target_link_libraries(zlib_bench zlib) + +#============================================================================ +# Minigzip tool +#============================================================================ +add_executable(minizip_bin contrib/minizip/minizip.c contrib/minizip/ioapi.c +contrib/minizip/ioapi.h contrib/minizip/unzip.c +contrib/minizip/unzip.h contrib/minizip/zip.c contrib/minizip/zip.h +) +target_link_libraries(minizip_bin zlib) diff --git a/deps/zlib/adler32.c b/deps/zlib/adler32.c index 81c584f68e2331..99a294496f7eb5 100644 --- a/deps/zlib/adler32.c +++ b/deps/zlib/adler32.c @@ -90,9 +90,9 @@ uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { return adler | (sum2 << 16); } -#if defined(ADLER32_SIMD_SSSE3) +#if defined(ADLER32_SIMD_SSSE3) || defined(ADLER32_SIMD_NEON) /* - * Use SSSE3 to compute the adler32. Since this routine can be + * Use SIMD to compute the adler32. Since this function can be * freely used, check CPU features here. zlib convention is to * call adler32(0, NULL, 0), before making calls to adler32(). * So this is a good early (and infrequent) place to cache CPU diff --git a/deps/zlib/contrib/minizip/README.chromium b/deps/zlib/contrib/minizip/README.chromium index 5eac425720797f..eefad4397604a5 100644 --- a/deps/zlib/contrib/minizip/README.chromium +++ b/deps/zlib/contrib/minizip/README.chromium @@ -3,6 +3,7 @@ Short Name: minizip URL: https://github.com/madler/zlib/tree/master/contrib/minizip Version: 1.2.12 License: Zlib +License File: //third_party/zlib/LICENSE Security Critical: yes Shipped: yes diff --git a/deps/zlib/contrib/minizip/ioapi.h b/deps/zlib/contrib/minizip/ioapi.h index c1b7a54847f552..8dcbdb06e35ad5 100644 --- a/deps/zlib/contrib/minizip/ioapi.h +++ b/deps/zlib/contrib/minizip/ioapi.h @@ -43,7 +43,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" #if defined(USE_FILE32API) #define fopen64 fopen diff --git a/deps/zlib/contrib/minizip/mztools.c b/deps/zlib/contrib/minizip/mztools.c index 8bf9cca326338a..96891c2e0b71ef 100644 --- a/deps/zlib/contrib/minizip/mztools.c +++ b/deps/zlib/contrib/minizip/mztools.c @@ -8,7 +8,7 @@ #include #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" #include "unzip.h" #define READ_8(adr) ((unsigned char)*(adr)) diff --git a/deps/zlib/contrib/minizip/mztools.h b/deps/zlib/contrib/minizip/mztools.h index f295ffeda6afcf..a49a426ec2fcb2 100644 --- a/deps/zlib/contrib/minizip/mztools.h +++ b/deps/zlib/contrib/minizip/mztools.h @@ -12,7 +12,7 @@ extern "C" { #endif #ifndef _ZLIB_H -#include "third_party/zlib/zlib.h" +#include "zlib.h" #endif #include "unzip.h" diff --git a/deps/zlib/contrib/minizip/unzip.c b/deps/zlib/contrib/minizip/unzip.c index 0a1d8b4fe2cf78..4973a4eea97b99 100644 --- a/deps/zlib/contrib/minizip/unzip.c +++ b/deps/zlib/contrib/minizip/unzip.c @@ -68,7 +68,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" #include "unzip.h" #ifdef STDC diff --git a/deps/zlib/contrib/minizip/unzip.h b/deps/zlib/contrib/minizip/unzip.h index 3c0143529b9144..2104e39150749b 100644 --- a/deps/zlib/contrib/minizip/unzip.h +++ b/deps/zlib/contrib/minizip/unzip.h @@ -48,7 +48,7 @@ extern "C" { #endif #ifndef _ZLIB_H -#include "third_party/zlib/zlib.h" +#include "zlib.h" #endif #ifndef _ZLIBIOAPI_H diff --git a/deps/zlib/contrib/minizip/zip.c b/deps/zlib/contrib/minizip/zip.c index 65c0c7251843c0..44e88a9cb9898d 100644 --- a/deps/zlib/contrib/minizip/zip.c +++ b/deps/zlib/contrib/minizip/zip.c @@ -26,7 +26,7 @@ #include #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" #include "zip.h" #ifdef STDC diff --git a/deps/zlib/contrib/minizip/zip.h b/deps/zlib/contrib/minizip/zip.h index 8c06c0aa7bb08b..8aaebb623430fc 100644 --- a/deps/zlib/contrib/minizip/zip.h +++ b/deps/zlib/contrib/minizip/zip.h @@ -47,7 +47,7 @@ extern "C" { //#define HAVE_BZIP2 #ifndef _ZLIB_H -#include "third_party/zlib/zlib.h" +#include "zlib.h" #endif #ifndef _ZLIBIOAPI_H diff --git a/deps/zlib/patches/0000-build.patch b/deps/zlib/patches/0000-build.patch index b7c59964822096..6119f09c05b73c 100644 --- a/deps/zlib/patches/0000-build.patch +++ b/deps/zlib/patches/0000-build.patch @@ -1,16 +1,3 @@ -diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h -index 8dcbdb06e35a..c1b7a54847f5 100644 ---- a/contrib/minizip/ioapi.h -+++ b/contrib/minizip/ioapi.h -@@ -43,7 +43,7 @@ - - #include - #include --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - - #if defined(USE_FILE32API) - #define fopen64 fopen diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c index 274f39eb1dd2..246ceb91a139 100644 --- a/contrib/minizip/iowin32.c @@ -35,45 +22,10 @@ index 274f39eb1dd2..246ceb91a139 100644 voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c -index 96891c2e0b71..8bf9cca32633 100644 ---- a/contrib/minizip/mztools.c -+++ b/contrib/minizip/mztools.c -@@ -8,7 +8,7 @@ - #include - #include - #include --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - #include "unzip.h" - - #define READ_8(adr) ((unsigned char)*(adr)) -diff --git a/contrib/minizip/mztools.h b/contrib/minizip/mztools.h -index a49a426ec2fc..f295ffeda6af 100644 ---- a/contrib/minizip/mztools.h -+++ b/contrib/minizip/mztools.h -@@ -12,7 +12,7 @@ extern "C" { - #endif - - #ifndef _ZLIB_H --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - #endif - - #include "unzip.h" diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index bcfb9416ec35..199b4723fcfc 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c -@@ -72,7 +72,7 @@ - #define NOUNCRYPT - #endif - --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - #include "unzip.h" - - #ifdef STDC @@ -1705,11 +1705,6 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) pfile_in_zip_read_info->stream.avail_out = (uInt)len; @@ -86,45 +38,6 @@ index bcfb9416ec35..199b4723fcfc 100644 if ((len>pfile_in_zip_read_info->rest_read_compressed+ pfile_in_zip_read_info->stream.avail_in) && (pfile_in_zip_read_info->raw)) -diff --git a/contrib/minizip/unzip.h b/contrib/minizip/unzip.h -index 2104e3915074..3c0143529b91 100644 ---- a/contrib/minizip/unzip.h -+++ b/contrib/minizip/unzip.h -@@ -48,7 +48,7 @@ extern "C" { - #endif - - #ifndef _ZLIB_H --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - #endif - - #ifndef _ZLIBIOAPI_H -diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c -index 44e88a9cb989..65c0c7251843 100644 ---- a/contrib/minizip/zip.c -+++ b/contrib/minizip/zip.c -@@ -26,7 +26,7 @@ - #include - #include - #include --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - #include "zip.h" - - #ifdef STDC -diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h -index 8aaebb623430..8c06c0aa7bb0 100644 ---- a/contrib/minizip/zip.h -+++ b/contrib/minizip/zip.h -@@ -47,7 +47,7 @@ extern "C" { - //#define HAVE_BZIP2 - - #ifndef _ZLIB_H --#include "zlib.h" -+#include "third_party/zlib/zlib.h" - #endif - - #ifndef _ZLIBIOAPI_H diff --git a/gzread.c b/gzread.c index 956b91ea7d9e..832d3ef98c59 100644 --- a/gzread.c diff --git a/deps/zlib/patches/0013-cpu-feature-detection-for-arm.patch b/deps/zlib/patches/0013-cpu-feature-detection-for-arm.patch new file mode 100644 index 00000000000000..0547851fe5d99d --- /dev/null +++ b/deps/zlib/patches/0013-cpu-feature-detection-for-arm.patch @@ -0,0 +1,30 @@ +From c43ba7a55f091c0dcbfd8d89f7a5121269ce1b81 Mon Sep 17 00:00:00 2001 +From: Ho Cheung +Date: Thu, 27 Jul 2023 09:47:52 +0800 +Subject: [PATCH] [zlib] Perform CPU feature detection for ARM inside adler32() + +Perform CPU feature detection for ARM within adler32() to have the same +behavior as x86. + +--- + third_party/zlib/adler32.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/third_party/zlib/adler32.c b/third_party/zlib/adler32.c +index 81c584f68e233..99a294496f7eb 100644 +--- a/third_party/zlib/adler32.c ++++ b/third_party/zlib/adler32.c +@@ -90,9 +90,9 @@ uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { + return adler | (sum2 << 16); + } + +-#if defined(ADLER32_SIMD_SSSE3) ++#if defined(ADLER32_SIMD_SSSE3) || defined(ADLER32_SIMD_NEON) + /* +- * Use SSSE3 to compute the adler32. Since this routine can be ++ * Use SIMD to compute the adler32. Since this function can be + * freely used, check CPU features here. zlib convention is to + * call adler32(0, NULL, 0), before making calls to adler32(). + * So this is a good early (and infrequent) place to cache CPU +-- +2.41.0.windows.3 diff --git a/doc/contributing/maintaining/maintaining-dependencies.md b/doc/contributing/maintaining/maintaining-dependencies.md index 795f18d3599263..f9d8f2e5d1b9a4 100644 --- a/doc/contributing/maintaining/maintaining-dependencies.md +++ b/doc/contributing/maintaining/maintaining-dependencies.md @@ -31,7 +31,7 @@ This a list of all the dependencies: * [undici 5.23.0][] * [uvwasi 0.0.16][] * [V8 11.3.244.8][] -* [zlib 1.2.13.1-motley-61dc0bd][] +* [zlib 1.2.13.1-motley-526382e][] Any code which meets one or more of these conditions should be managed as a dependency: @@ -311,7 +311,7 @@ See [maintaining-web-assembly][] for more informations. high-performance JavaScript and WebAssembly engine, written in C++. See [maintaining-V8][] for more informations. -### zlib 1.2.13.1-motley-61dc0bd +### zlib 1.2.13.1-motley-526382e The [zlib](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/zlib) dependency lossless data-compression library, @@ -349,4 +349,4 @@ performance improvements not currently available in standard zlib. [update-openssl-action]: ../../../.github/workflows/update-openssl.yml [uvwasi 0.0.16]: #uvwasi-0016 [v8 11.3.244.8]: #v8-1132448 -[zlib 1.2.13.1-motley-61dc0bd]: #zlib-12131-motley-61dc0bd +[zlib 1.2.13.1-motley-526382e]: #zlib-12131-motley-526382e