Skip to content

Commit f9cd37e

Browse files
authored
[ML] Upgrade to zlib 1.2.12 on Windows (#2253)
Version 1.2.12 has these key improvements over 1.2.11: - Fix a deflate bug when using the Z_FIXED strategy that can result in out-of-bound accesses. - Fix a deflate bug when the window is full in deflate_stored(). - Speed up CRC-32 computations by a factor of 1.5 to 3. - Use the hardware CRC-32 instruction on ARMv8 processors. - Speed up crc32_combine() with powers of x tables. - Add crc32_combine_gen() and crc32_combine_op() for fast combines. For Linux and macOS we use the zlib provided by the OS install. Users on Linux and macOS are advised to install the latest OS updates if they wish to take advantage of these improvements.
1 parent 9946924 commit f9cd37e

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

3rd_party/licenses/zlib-INFO.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name,version,revision,url,license,copyright,sourceURL
2-
zlib,1.2.11,,http://zlib.net,Zlib,Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler,
2+
zlib,1.2.12,21767c654d31d2dccdde4330529775c6c5fd5389,http://zlib.net,Zlib,Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler,

build-setup/windows.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ Finally, copy the file `gnumake.exe` from `C:\tools\make-4.2.1\WinRel` to `C:\us
8787

8888
Whilst it is possible to download a pre-built version of `zlib1.dll`, for consistency we want one that links against the Visual Studio 2019 C runtime library. Therefore it is necessary to build zlib from source.
8989

90-
Download the source code from <http://zlib.net/> - the file is called `zlib1211.zip`. Unzip this file under `C:\tools`, so that you end up with a directory called `C:\tools\zlib-1.2.11`.
90+
Download the source code from <http://zlib.net/> - the file is called `zlib1212.zip`. Unzip this file under `C:\tools`, so that you end up with a directory called `C:\tools\zlib-1.2.12`.
9191

9292
To build, start a command prompt using Start Menu -&gt; Apps -&gt; Visual Studio 2019 -&gt; x64 Native Tools Command Prompt for VS 2019, then in it type:
9393

9494
```
95-
cd \tools\zlib-1.2.11
96-
nmake -f win32/Makefile.msc AS=ml64 LOC="-D_WIN32_WINNT=0x0601 -DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"
95+
cd \tools\zlib-1.2.12
96+
nmake -f win32/Makefile.msc LOC="-D_WIN32_WINNT=0x0601"
9797
nmake -f win32/Makefile.msc test
9898
```
9999

100-
All the build output will end up in the top level `C:\tools\zlib-1.2.11` directory. Once the build is complete, copy `zlib1.dll` and `minigzip.exe` to `C:\usr\local\bin`. Copy `zlib.lib` and `zdll.lib` to `C:\usr\local\lib`. And copy `zlib.h` and `zconf.h` to `C:\usr\local\include`.
100+
All the build output will end up in the top level `C:\tools\zlib-1.2.12` directory. Once the build is complete, copy `zlib1.dll` and `minigzip.exe` to `C:\usr\local\bin`. Copy `zlib.lib` and `zdll.lib` to `C:\usr\local\lib`. And copy `zlib.h` and `zconf.h` to `C:\usr\local\include`.
101101

102102
### libxml2
103103

@@ -161,8 +161,8 @@ Start a command prompt using Start Menu -&gt; Apps -&gt; Visual Studio 2019 -&gt
161161
```
162162
cd \tools\boost_1_77_0
163163
bootstrap.bat
164-
b2 -j6 --layout=versioned --disable-icu --toolset=msvc-14.2 cxxflags="-std:c++17" linkflags="-std:c++17" --build-type=complete -sZLIB_INCLUDE="C:\tools\zlib-1.2.11" -sZLIB_LIBPATH="C:\tools\zlib-1.2.11" -sZLIB_NAME=zdll --without-context --without-coroutine --without-graph_parallel --without-mpi --without-python architecture=x86 address-model=64 optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=BOOST_LOG_WITHOUT_DEBUG_OUTPUT define=BOOST_LOG_WITHOUT_EVENT_LOG define=BOOST_LOG_WITHOUT_SYSLOG define=BOOST_LOG_WITHOUT_IPC define=_WIN32_WINNT=0x0601
165-
b2 install --prefix=C:\usr\local --layout=versioned --disable-icu --toolset=msvc-14.2 cxxflags="-std:c++17" linkflags="-std:c++17" --build-type=complete -sZLIB_INCLUDE="C:\tools\zlib-1.2.11" -sZLIB_LIBPATH="C:\tools\zlib-1.2.11" -sZLIB_NAME=zdll --without-context --without-coroutine --without-graph_parallel --without-mpi --without-python architecture=x86 address-model=64 optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=BOOST_LOG_WITHOUT_DEBUG_OUTPUT define=BOOST_LOG_WITHOUT_EVENT_LOG define=BOOST_LOG_WITHOUT_SYSLOG define=BOOST_LOG_WITHOUT_IPC define=_WIN32_WINNT=0x0601
164+
b2 -j6 --layout=versioned --disable-icu --toolset=msvc-14.2 cxxflags="-std:c++17" linkflags="-std:c++17" --build-type=complete -sZLIB_INCLUDE="C:\tools\zlib-1.2.12" -sZLIB_LIBPATH="C:\tools\zlib-1.2.12" -sZLIB_NAME=zdll --without-context --without-coroutine --without-graph_parallel --without-mpi --without-python architecture=x86 address-model=64 optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=BOOST_LOG_WITHOUT_DEBUG_OUTPUT define=BOOST_LOG_WITHOUT_EVENT_LOG define=BOOST_LOG_WITHOUT_SYSLOG define=BOOST_LOG_WITHOUT_IPC define=_WIN32_WINNT=0x0601
165+
b2 install --prefix=C:\usr\local --layout=versioned --disable-icu --toolset=msvc-14.2 cxxflags="-std:c++17" linkflags="-std:c++17" --build-type=complete -sZLIB_INCLUDE="C:\tools\zlib-1.2.12" -sZLIB_LIBPATH="C:\tools\zlib-1.2.12" -sZLIB_NAME=zdll --without-context --without-coroutine --without-graph_parallel --without-mpi --without-python architecture=x86 address-model=64 optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=BOOST_LOG_WITHOUT_DEBUG_OUTPUT define=BOOST_LOG_WITHOUT_EVENT_LOG define=BOOST_LOG_WITHOUT_SYSLOG define=BOOST_LOG_WITHOUT_IPC define=_WIN32_WINNT=0x0601
166166
```
167167

168168
The Boost headers and appropriate libraries should end up in `C:\usr\local\include` and `C:\usr\local\lib` respectively.

dev-tools/download_windows_deps.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
# limitation.
1010
#
1111
$ErrorActionPreference="Stop"
12-
$Archive="usr-x86_64-windows-2016-6.zip"
12+
$Archive="usr-x86_64-windows-2016-7.zip"
1313
$Destination="C:\"
14-
if (!(Test-Path "$Destination\usr\local\include\pytorch\torch\csrc\profiler\api.h")) {
14+
# If zlib is not version 1.2.12 then we need the latest download
15+
if (!(Test-Path "$Destination\usr\local\include\zlib.h") -Or
16+
!(Select-String -Path "$Destination\usr\local\include\zlib.h" -Pattern "0x12c0" -Quiet)) {
1517
Remove-Item "$Destination\usr" -Recurse -Force -ErrorAction Ignore
1618
$ZipSource="https://s3-eu-west-1.amazonaws.com/prelert-artifacts/dependencies/$Archive"
1719
$ZipDestination="$Env:TEMP\$Archive"

docs/CHANGELOG.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
* Upgrade PyTorch to version 1.11. (See {ml-pull}2233[#2233], {ml-pull}2235[#2235]
3636
and {ml-pull}2238[#2238].)
37+
* Upgrade zlib to version 1.2.12 on Windows. (See {ml-pull}2253[#2253].)
3738

3839
=== Bug Fixes
3940

0 commit comments

Comments
 (0)