Skip to content

Commit 4399da8

Browse files
authored
Revert "Migrate to zlib-ng, part 3: Remove zlib and zlib-intel source code an…" (#105284)
This reverts commit 4d2d3d3.
1 parent ea2ffbd commit 4399da8

Some content is hidden

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

80 files changed

+53338
-6
lines changed

THIRD-PARTY-NOTICES.TXT

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,38 @@ shall not be used in advertising or otherwise to promote the sale,
6666
use or other dealings in these Data Files or Software without prior
6767
written authorization of the copyright holder.
6868

69+
License notice for Zlib
70+
-----------------------
71+
72+
https://github.com/madler/zlib
73+
https://zlib.net/zlib_license.html
74+
75+
/* zlib.h -- interface of the 'zlib' general purpose compression library
76+
version 1.3.1, January 22nd, 2024
77+
78+
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
79+
80+
This software is provided 'as-is', without any express or implied
81+
warranty. In no event will the authors be held liable for any damages
82+
arising from the use of this software.
83+
84+
Permission is granted to anyone to use this software for any purpose,
85+
including commercial applications, and to alter it and redistribute it
86+
freely, subject to the following restrictions:
87+
88+
1. The origin of this software must not be misrepresented; you must not
89+
claim that you wrote the original software. If you use this software
90+
in a product, an acknowledgment in the product documentation would be
91+
appreciated but is not required.
92+
2. Altered source versions must be plainly marked as such, and must not be
93+
misrepresented as being the original software.
94+
3. This notice may not be removed or altered from any source distribution.
95+
96+
Jean-loup Gailly Mark Adler
97+
98+
99+
*/
100+
69101
License notice for zlib-ng
70102
-----------------------
71103

docs/workflow/requirements/linux-requirements.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ Install the following packages for the toolchain:
4747
* liblttng-ust-dev
4848
* libssl-dev
4949
* libkrb5-dev
50+
* zlib1g-dev
5051
* ninja-build (optional, enables building native code with ninja instead of make)
5152

5253
**NOTE**: If you have an Ubuntu version older than 22.04 LTS, or Debian version older than 12, don't install `cmake` using `apt` directly. Follow the note written down below.
5354

5455
```bash
5556
sudo apt install -y cmake llvm lld clang build-essential \
56-
python-is-python3 curl git lldb libicu-dev liblttng-ust-dev \
57-
libssl-dev libkrb5-dev ninja-build
57+
python-is-python3 curl git lldb libicu-dev liblttng-ust-dev \
58+
libssl-dev libkrb5-dev zlib1g-dev ninja-build
5859
```
5960

6061
**NOTE**: As of now, Ubuntu's `apt` only has until CMake version 3.16.3 if you're using Ubuntu 20.04 LTS (less in older Ubuntu versions), and version 3.18.4 in Debian 11 (less in older Debian versions). This is lower than the required 3.20, which in turn makes it incompatible with the repo. For this case, we can use the `snap` package manager or the _Kitware APT feed_ to get a new enough version of CMake.
@@ -97,12 +98,13 @@ Install the following packages for the toolchain:
9798
* libicu-devel
9899
* openssl-devel
99100
* krb5-devel
101+
* zlib-devel
100102
* lttng-ust-devel
101103
* ninja-build (optional, enables building native code with ninja instead of make)
102104

103105
```bash
104106
sudo dnf install -y cmake llvm lld lldb clang python curl git libicu-devel openssl-devel \
105-
krb5-devel lttng-ust-devel ninja-build
107+
krb5-devel zlib-devel lttng-ust-devel ninja-build
106108
```
107109

108110
### Gentoo

eng/install-native-dependencies.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ case "$os" in
2424
apt update
2525

2626
apt install -y build-essential gettext locales cmake llvm clang lldb liblldb-dev libunwind8-dev libicu-dev liblttng-ust-dev \
27-
libssl-dev libkrb5-dev
27+
libssl-dev libkrb5-dev zlib1g-dev
2828

2929
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
3030
elif [ "$ID" = "fedora" ]; then
31-
dnf install -y cmake llvm lld lldb clang python curl libicu-devel openssl-devel krb5-devel lttng-ust-devel
31+
dnf install -y cmake llvm lld lldb clang python curl libicu-devel openssl-devel krb5-devel zlib-devel lttng-ust-devel
3232
elif [ "$ID" = "alpine" ]; then
33-
apk add build-base cmake bash curl clang llvm-dev krb5-dev lttng-ust-dev icu-dev openssl-dev
33+
apk add build-base cmake bash curl clang llvm-dev krb5-dev lttng-ust-dev icu-dev zlib-dev openssl-dev
3434
else
3535
echo "Unsupported distro. distro: $ID"
3636
exit 1

src/installer/pkg/THIRD-PARTY-NOTICES.TXT

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,38 @@ shall not be used in advertising or otherwise to promote the sale,
6565
use or other dealings in these Data Files or Software without prior
6666
written authorization of the copyright holder.
6767

68+
License notice for Zlib
69+
-----------------------
70+
71+
https://github.com/madler/zlib
72+
https://zlib.net/zlib_license.html
73+
74+
/* zlib.h -- interface of the 'zlib' general purpose compression library
75+
version 1.2.13, October 13th, 2022
76+
77+
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
78+
79+
This software is provided 'as-is', without any express or implied
80+
warranty. In no event will the authors be held liable for any damages
81+
arising from the use of this software.
82+
83+
Permission is granted to anyone to use this software for any purpose,
84+
including commercial applications, and to alter it and redistribute it
85+
freely, subject to the following restrictions:
86+
87+
1. The origin of this software must not be misrepresented; you must not
88+
claim that you wrote the original software. If you use this software
89+
in a product, an acknowledgment in the product documentation would be
90+
appreciated but is not required.
91+
2. Altered source versions must be plainly marked as such, and must not be
92+
misrepresented as being the original software.
93+
3. This notice may not be removed or altered from any source distribution.
94+
95+
Jean-loup Gailly Mark Adler
96+
97+
98+
*/
99+
68100
License notice for Mono
69101
-------------------------------
70102

src/native/external/cgmanifest.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@
4141
},
4242
"DevelopmentDependency": false
4343
},
44+
{
45+
"Component": {
46+
"Type": "git",
47+
"Git": {
48+
"RepositoryUrl": "https://github.com/madler/zlib",
49+
"CommitHash": "51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf"
50+
}
51+
},
52+
"DevelopmentDependency": false
53+
},
54+
{
55+
"Component": {
56+
"Type": "git",
57+
"Git": {
58+
"RepositoryUrl": "https://github.com/intel/zlib",
59+
"CommitHash": "6160a8f20c3626aec2f8b0fda5bf2e65bfe31781"
60+
}
61+
},
62+
"DevelopmentDependency": false
63+
},
4464
{
4565
"Component": {
4666
"Type": "git",
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
From edabaf799fd071a328e0adb743a98628df6649f0 Mon Sep 17 00:00:00 2001
2+
From: Levi Broderick <[email protected]>
3+
Date: Mon, 28 Aug 2023 15:26:38 -0700
4+
Subject: [PATCH] Make zlib-intel compile clean against C4244 clang equivalent
5+
is "implicit-int-conversion" warning
6+
7+
The change to deflate.c is legal because 'len' has an upper bound of
8+
MAX_STORED, which means it fits cleanly into a 16-bit integer. So
9+
writing out 2x 8-bit values will not result in data loss.
10+
11+
The change to trees.c is legal because within this loop, 'count' is
12+
intended to have an upper bound of 138, with the target assignment
13+
only executing if 'count' is bounded by 4. Neither the 'count' local
14+
in isolation nor the addition that's part of the target line is
15+
expected to result in integer overflow. But even if it did, that's a
16+
matter for a different warning code and doesn't impact the correctness
17+
of the narrowing cast being considered here.
18+
19+
The change to slide_sse.c is legal because 'w_size' is limited to
20+
1 << 15 (see deflateInit2_ in deflate.c), so this fits cleanly into
21+
a 16-bit value.
22+
---
23+
src/native/external/zlib-intel/deflate.c | 8 ++++----
24+
src/native/external/zlib-intel/slide_sse.c | 2 +-
25+
src/native/external/zlib-intel/trees.c | 2 +-
26+
3 files changed, 6 insertions(+), 6 deletions(-)
27+
28+
diff --git a/src/native/external/zlib-intel/deflate.c b/src/native/external/zlib-intel/deflate.c
29+
index bd5e95774a6..108b1a187af 100644
30+
--- a/src/native/external/zlib-intel/deflate.c
31+
+++ b/src/native/external/zlib-intel/deflate.c
32+
@@ -1553,10 +1553,10 @@ local block_state deflate_stored(s, flush)
33+
_tr_stored_block(s, (char *)0, 0L, last);
34+
35+
/* Replace the lengths in the dummy stored block with len. */
36+
- s->pending_buf[s->pending - 4] = len;
37+
- s->pending_buf[s->pending - 3] = len >> 8;
38+
- s->pending_buf[s->pending - 2] = ~len;
39+
- s->pending_buf[s->pending - 1] = ~len >> 8;
40+
+ s->pending_buf[s->pending - 4] = (Bytef)len;
41+
+ s->pending_buf[s->pending - 3] = (Bytef)(len >> 8);
42+
+ s->pending_buf[s->pending - 2] = (Bytef)~len;
43+
+ s->pending_buf[s->pending - 1] = (Bytef)(~len >> 8);
44+
45+
/* Write the stored block header bytes. */
46+
flush_pending(s->strm);
47+
diff --git a/src/native/external/zlib-intel/slide_sse.c b/src/native/external/zlib-intel/slide_sse.c
48+
index 342fd562dd1..eb74202c5a0 100644
49+
--- a/src/native/external/zlib-intel/slide_sse.c
50+
+++ b/src/native/external/zlib-intel/slide_sse.c
51+
@@ -18,7 +18,7 @@ void slide_hash_sse(deflate_state *s)
52+
unsigned n;
53+
Posf *p;
54+
uInt wsize = s->w_size;
55+
- z_const __m128i xmm_wsize = _mm_set1_epi16(s->w_size);
56+
+ z_const __m128i xmm_wsize = _mm_set1_epi16((short)s->w_size);
57+
58+
n = s->hash_size;
59+
p = &s->head[n] - 8;
60+
diff --git a/src/native/external/zlib-intel/trees.c b/src/native/external/zlib-intel/trees.c
61+
index 35462a1313a..f78b7d8c63e 100644
62+
--- a/src/native/external/zlib-intel/trees.c
63+
+++ b/src/native/external/zlib-intel/trees.c
64+
@@ -717,7 +717,7 @@ local void scan_tree(s, tree, max_code)
65+
if (++count < max_count && curlen == nextlen) {
66+
continue;
67+
} else if (count < min_count) {
68+
- s->bl_tree[curlen].Freq += count;
69+
+ s->bl_tree[curlen].Freq += (ush)count;
70+
} else if (curlen != 0) {
71+
if (curlen != prevlen) s->bl_tree[curlen].Freq++;
72+
s->bl_tree[REP_3_6].Freq++;
73+
--
74+
2.42.0.windows.1
75+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 86d96652ddd60f61dc7b0c94b601f6d156d34632 Mon Sep 17 00:00:00 2001
2+
From: Levi Broderick <[email protected]>
3+
Date: Mon, 28 Aug 2023 15:26:38 -0700
4+
Subject: [PATCH] Make zlib compile clean against C4244 clang equivalent is
5+
"implicit-int-conversion" warning
6+
7+
The change to deflate.c is legal because 'len' has an upper bound of
8+
MAX_STORED, which means it fits cleanly into a 16-bit integer. So
9+
writing out 2x 8-bit values will not result in data loss.
10+
11+
The change to trees.c is legal because within this loop, 'count' is
12+
intended to have an upper bound of 138, with the target assignment
13+
only executing if 'count' is bounded by 4. Neither the 'count' local
14+
in isolation nor the addition that's part of the target line is
15+
expected to result in integer overflow. But even if it did, that's a
16+
matter for a different warning code and doesn't impact the correctness
17+
of the narrowing cast being considered here.
18+
---
19+
src/native/external/zlib/deflate.c | 8 ++++----
20+
src/native/external/zlib/trees.c | 2 +-
21+
2 files changed, 5 insertions(+), 5 deletions(-)
22+
23+
diff --git a/src/native/external/zlib/deflate.c b/src/native/external/zlib/deflate.c
24+
index d2e1106ef5d..b7636639754 100644
25+
--- a/src/native/external/zlib/deflate.c
26+
+++ b/src/native/external/zlib/deflate.c
27+
@@ -1738,10 +1738,10 @@ local block_state deflate_stored(s, flush)
28+
_tr_stored_block(s, (char *)0, 0L, last);
29+
30+
/* Replace the lengths in the dummy stored block with len. */
31+
- s->pending_buf[s->pending - 4] = len;
32+
- s->pending_buf[s->pending - 3] = len >> 8;
33+
- s->pending_buf[s->pending - 2] = ~len;
34+
- s->pending_buf[s->pending - 1] = ~len >> 8;
35+
+ s->pending_buf[s->pending - 4] = (Bytef)len;
36+
+ s->pending_buf[s->pending - 3] = (Bytef)(len >> 8);
37+
+ s->pending_buf[s->pending - 2] = (Bytef)~len;
38+
+ s->pending_buf[s->pending - 1] = (Bytef)(~len >> 8);
39+
40+
/* Write the stored block header bytes. */
41+
flush_pending(s->strm);
42+
diff --git a/src/native/external/zlib/trees.c b/src/native/external/zlib/trees.c
43+
index 5f305c47221..8a3eec559e5 100644
44+
--- a/src/native/external/zlib/trees.c
45+
+++ b/src/native/external/zlib/trees.c
46+
@@ -721,7 +721,7 @@ local void scan_tree(s, tree, max_code)
47+
if (++count < max_count && curlen == nextlen) {
48+
continue;
49+
} else if (count < min_count) {
50+
- s->bl_tree[curlen].Freq += count;
51+
+ s->bl_tree[curlen].Freq += (ush)count;
52+
} else if (curlen != 0) {
53+
if (curlen != prevlen) s->bl_tree[curlen].Freq++;
54+
s->bl_tree[REP_3_6].Freq++;
55+
--
56+
2.42.0.windows.1
57+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
v1.2.13_jtk
2+
(6160a8f20c3626aec2f8b0fda5bf2e65bfe31781)
3+
4+
https://github.com/intel/zlib/releases/tag/v1.2.13_jtk
5+
6+
Note: This library does not use a standard release lifecycle.
7+
We're pointing to the latest available tagged version as of this writing.
8+
9+
We do not pull in every file from the intel/zlib repo. Instead, some years ago,
10+
somebody determined what they believed was the minimum set that needed to be
11+
copied into our repo in order to build. Since then, we've just updated only
12+
those files in-place, ignoring other files in the intel/zlib repo. If new files
13+
are introduced which are necessary for building the product, feel free to bring
14+
those down as well.
15+
16+
We have also applied the custom patches under the patches/zlib-intel folder.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Zlib-Intel is an optimized version of Zlib developed by Intel to take advantage of modern CPU features.
2+
3+
Brief Listing of Changes:
4+
New deflate_medium() strategy for compression levels 4-6
5+
Improved hashing using the SSE4.2 CRC32 instruction
6+
SSE Saturated Subtractions for hash table shifting
7+
Faster CRC32 calculations using SSE4.2 PCLMULQDQ instruction
8+
Reduced loop unrolling
9+
10+
Detailed explanations of these optimizations available in the official whitepaper: http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/zlib-compression-whitepaper-copy.pdf
11+

0 commit comments

Comments
 (0)