Debian Codegraph @

ext/zlib-ng/README.md

raw symbols SCIP
1 ## zlib-ng
2 *zlib data compression library for the next generation systems*
3
4 Maintained by Hans Kristian Rosbach
5 aka Dead2 (zlib-ng àt circlestorm dót org)
6
7 |CI|Status|
8 |:-|-|
9 |GitHub Actions|[![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20CMake/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions) [![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20Configure/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions) [![Master Branch Status](https://github.com/zlib-ng/zlib-ng/workflows/CI%20NMake/badge.svg)](https://github.com/zlib-ng/zlib-ng/actions)|
10 |Buildkite|[![Build status](https://badge.buildkite.com/7bb1ef84356d3baee26202706cc053ee1de871c0c712b65d26.svg?branch=develop)](https://buildkite.com/circlestorm-productions/zlib-ng)|
11 |CodeFactor|[![CodeFactor](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/badge)](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng)|
12 |OSS-Fuzz|[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/zlib-ng.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng)
13 |Codecov|[![codecov.io](https://codecov.io/github/zlib-ng/zlib-ng/coverage.svg?branch=develop)](https://codecov.io/github/zlib-ng/zlib-ng/)|
14
15
16 Features
17 --------
18
19 * Zlib compatible API with support for dual-linking
20 * Modernized native API based on zlib API for ease of porting
21 * Modern C11 syntax and a clean code layout
22 * Deflate medium and quick algorithms based on Intel’s zlib fork
23 * Support for CPU intrinsics when available
24 * Adler32 implementation using SSSE3, AVX2, AVX512, AVX512-VNNI, Neon, VMX & VSX
25 * CRC32-B implementation using PCLMULQDQ, VPCLMULQDQ, ACLE, & IBM Z
26 * Hash table implementation using CRC32-C intrinsics on x86 and ARM
27 * Slide hash implementations using SSE2, AVX2, Neon, VMX & VSX
28 * Compare256 implementations using SSE2, AVX2, Neon, & POWER9
29 * Inflate chunk copying using SSE2, AVX, Neon & VSX
30 * Support for hardware-accelerated deflate using IBM Z DFLTCC
31 * Unaligned memory read/writes and large bit buffer improvements
32 * Includes improvements from Cloudflare and Intel forks
33 * Configure, CMake, and NMake build system support
34 * Comprehensive set of CMake unit tests
35 * Code sanitizers, fuzzing, and coverage
36 * GitHub Actions continuous integration on Windows, macOS, and Linux
37 * Emulated CI for ARM, AARCH64, PPC, PPC64, SPARC64, S390x using qemu
38
39
40 History
41 -------
42
43 The motivation for this fork came after seeing several 3rd party
44 contributions containing new optimizations not getting implemented
45 into the official zlib repository.
46
47 Mark Adler has been maintaining zlib for a very long time, and he has
48 done a great job and hopefully he will continue for a long time yet.
49 The idea of zlib-ng is not to replace zlib, but to co-exist as a
50 drop-in replacement with a lower threshold for code change.
51
52 zlib has a long history and is incredibly portable, even supporting
53 lots of systems that predate the Internet. This is great, but it does
54 complicate further development and maintainability.
55 The zlib code has numerous workarounds for old compilers that do not
56 understand ANSI-C or to accommodate systems with limitations such as
57 operating in a 16-bit environment.
58
59 Many of these workarounds are only maintenance burdens, some of them
60 are pretty huge code-wise. For example, the [v]s[n]printf workaround
61 code has a whopping 8 different implementations just to cater to
62 various old compilers. With this many workarounds cluttered throughout
63 the code, new programmers with an idea/interest for zlib will need
64 to take some time to figure out why all of these seemingly strange
65 things are used, and how to work within those confines.
66
67 So I decided to make a fork, merge all the Intel optimizations, merge
68 the Cloudflare optimizations that did not conflict, plus a couple
69 of other smaller patches. Then I started cleaning out workarounds,
70 various dead code, all contrib and example code as there is little
71 point in having those in this fork for various reasons.
72
73 A lot of improvements have gone into zlib-ng since its start, and
74 numerous people and companies have contributed both small and big
75 improvements, or valuable testing.
76
77 Please read LICENSE.md, it is very simple and very liberal.
78
79
80 Build
81 -----
82
83 There are two ways to build zlib-ng:
84
85 ### Cmake
86
87 To build zlib-ng using the cross-platform makefile generator cmake.
88
89 ```
90 cmake .
91 cmake --build . --config Release
92 ctest --verbose -C Release
93 ```
94
95 Alternatively, you can use the cmake configuration GUI tool ccmake:
96
97 ```
98 ccmake .
99 ```
100
101 ### Configure
102
103 To build zlib-ng using the bash configure script:
104
105 ```
106 ./configure
107 make
108 make test
109 ```
110
111 Build Options
112 -------------
113
114 | CMake | configure | Description | Default |
115 |:-------------------------|:-------------------------|:--------------------------------------------------------------------------------------|---------|
116 | ZLIB_COMPAT | --zlib-compat | Compile with zlib compatible API | OFF |
117 | ZLIB_ENABLE_TESTS | | Build test binaries | ON |
118 | WITH_GZFILEOP | --without-gzfileops | Compile with support for gzFile related functions | ON |
119 | WITH_OPTIM | --without-optimizations | Build with optimisations | ON |
120 | WITH_NEW_STRATEGIES | --without-new-strategies | Use new strategies | ON |
121 | WITH_NATIVE_INSTRUCTIONS | --native | Compiles with full instruction set supported on this host (gcc/clang -march=native) | OFF |
122 | WITH_SANITIZER | | Build with sanitizer (memory, address, undefined) | OFF |
123 | WITH_FUZZERS | | Build test/fuzz | OFF |
124 | WITH_BENCHMARKS | | Build test/benchmarks | OFF |
125 | WITH_MAINTAINER_WARNINGS | | Build with project maintainer warnings | OFF |
126 | WITH_CODE_COVERAGE | | Enable code coverage reporting | OFF |
127
128
129 Install
130 -------
131
132 WARNING: We do not recommend manually installing unless you really
133 know what you are doing, because this can potentially override the system
134 default zlib library, and any incompatibility or wrong configuration of
135 zlib-ng can make the whole system unusable, requiring recovery or reinstall.
136 If you still want a manual install, we recommend using the /opt/ path prefix.
137
138 For Linux distros, an alternative way to use zlib-ng (if compiled in
139 zlib-compat mode) instead of zlib, is through the use of the
140 _LD_PRELOAD_ environment variable. If the program is dynamically linked
141 with zlib, then zlib-ng will temporarily be used instead by the program,
142 without risking system-wide instability.
143
144 ```
145 LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.12.zlib-ng /usr/bin/program
146 ```
147
148 ### Cmake
149
150 To install zlib-ng system-wide using cmake:
151
152 ```
153 cmake --build . --target install
154 ```
155
156 ### Configure
157
158 To install zlib-ng system-wide using the configure script:
159
160 ```
161 make install
162 ```
163
164 ### Vcpkg
165
166 Alternatively, you can build and install zlib-ng using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
167
168 ```sh or powershell
169 git clone https://github.com/Microsoft/vcpkg.git
170 cd vcpkg
171 ./bootstrap-vcpkg.sh # "./bootstrap-vcpkg.bat" for powershell
172 ./vcpkg integrate install
173 ./vcpkg install zlib-ng
174 ```
175
176 The zlib-ng port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
177
178 Contributing
179 ------------
180
181 Zlib-ng is a aiming to be open to contributions, and we would be delighted to
182 receive pull requests on github.
183 Just remember that any code you submit must be your own and it must be zlib licensed.
184 Help with testing and reviewing of pull requests etc is also very much appreciated.
185
186 If you are interested in contributing, please consider joining our
187 IRC channel #zlib-ng on the Freenode IRC network.
188
189
190 Acknowledgments
191 ----------------
192
193 Thanks to Servebolt.com for sponsoring my maintainership of zlib-ng.
194
195 Thanks go out to all the people and companies who have taken the time to contribute
196 code reviews, testing and/or patches. Zlib-ng would not have been nearly as good without you.
197
198 The deflate format used by zlib was defined by Phil Katz.
199 The deflate and zlib specifications were written by L. Peter Deutsch.
200
201 zlib was originally created by Jean-loup Gailly (compression)
202 and Mark Adler (decompression).
203
204
205 Advanced Build Options
206 ----------------------
207
208 | CMake | configure | Description | Default |
209 |:--------------------------------|:----------------------|:--------------------------------------------------------------------|------------------------|
210 | FORCE_SSE2 | --force-sse2 | Skip runtime check for SSE2 instructions (Always on for x86_64) | OFF (x86) |
211 | FORCE_TZCNT | --force-tzcnt | Skip runtime check for TZCNT instructions | OFF |
212 | WITH_AVX2 | | Build with AVX2 intrinsics | ON |
213 | WITH_AVX512 | | Build with AVX512 intrinsics | ON |
214 | WITH_AVX512VNNI | | Build with AVX512VNNI intrinsics | ON |
215 | WITH_SSE2 | | Build with SSE2 intrinsics | ON |
216 | WITH_SSE41 | | Build with SSE41 intrinsics | ON |
217 | WITH_SSE42 | | Build with SSE42 intrinsics | ON |
218 | WITH_PCLMULQDQ | | Build with PCLMULQDQ intrinsics | ON |
219 | WITH_VPCLMULQDQ | --without-vpclmulqdq | Build with VPCLMULQDQ intrinsics | ON |
220 | WITH_ACLE | --without-acle | Build with ACLE intrinsics | ON |
221 | WITH_NEON | --without-neon | Build with NEON intrinsics | ON |
222 | WITH_ALTIVEC | --without-altivec | Build with AltiVec (VMX) intrinsics | ON |
223 | WITH_POWER8 | --without-power8 | Build with POWER8 optimisations | ON |
224 | WITH_CRC32_VX | --without-crc32-vx | Build with vectorized CRC32 on IBM Z | ON |
225 | WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Build with DFLTCC intrinsics for compression on IBM Z | OFF |
226 | WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Build with DFLTCC intrinsics for decompression on IBM Z | OFF |
227 | WITH_UNALIGNED | --without-unaligned | Allow optimizations that use unaligned reads if safe on current arch| ON |
228 | WITH_INFLATE_STRICT | | Build with strict inflate distance checking | OFF |
229 | WITH_INFLATE_ALLOW_INVALID_DIST | | Build with zero fill for inflate invalid distances | OFF |
230 | INSTALL_UTILS | | Copy minigzip and minideflate during install | OFF |
231
232
233 Related Projects
234 ----------------
235
236 * Fork of the popular minigzip https://github.com/zlib-ng/minizip-ng
237 * Python tool to benchmark minigzip/minideflate https://github.com/zlib-ng/deflatebench
238 * Python tool to benchmark pigz https://github.com/zlib-ng/pigzbench
239 * 3rd party patches for zlib-ng compatibility https://github.com/zlib-ng/patches