Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zlib] build failure with vcpkg #34597

Closed
PTamis opened this issue Oct 19, 2023 · 8 comments
Closed

[zlib] build failure with vcpkg #34597

PTamis opened this issue Oct 19, 2023 · 8 comments
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team.

Comments

@PTamis
Copy link

PTamis commented Oct 19, 2023

Hello I am trying to build zlib in my Windows 11 PC but it emits errors.
If I try another package like bzip2 it is working fine. But it fails all the time with the zlib.

Host Environment

Host: x64-windows 11
Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33126.1 for x64
vcpkg-tool version: git log -1
commit 2815578 (HEAD -> master, origin/master, origin/HEAD)
Visual Studio Community Edition 2022 (Preview), 2019, 2017 are installed with C++.
Windows 10 SDK is also install, multiple versions (10.0.14, 15, 16, 17, 18 ...)
RAM: 64GB

To Reproduce
.\vcpkg install zlib

Failure logs

.\vcpkg install zlib --triplet=x64-windows-vs22

Computing installation plan...
The following packages will be built and installed:
zlib:x64-windows-vs22 -> 1.3
Detecting compiler hash for triplet x64-windows-vs22...
Restored 0 package(s) from C:\Users\PTamt\AppData\Local\vcpkg\archives in 74.5 us. Use --debug to see more details.
Installing 1/1 zlib:x64-windows-vs22...
Building zlib:x64-windows-vs22...
-- Using cached madler-zlib-v1.3.tar.gz.
-- Cleaning sources at C:/Users/PTamt/source/repos/VCPKG/vcpkg/buildtrees/zlib/src/v1.3-8825ee792f.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source C:/Users/PTamt/source/repos/VCPKG/vcpkg/downloads/madler-zlib-v1.3.tar.gz
-- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch
-- Applying patch 0002-skip-building-examples.patch
-- Applying patch 0003-build-static-or-shared-not-both.patch
-- Applying patch 0004-android-and-mingw-fixes.patch
-- Using source at C:/Users/PTamt/source/repos/VCPKG/vcpkg/buildtrees/zlib/src/v1.3-8825ee792f.clean
-- Found external ninja('1.11.0').
-- Configuring x64-windows-vs22
-- Building x64-windows-vs22-dbg
CMake Warning at scripts/cmake/vcpkg_execute_build_process.cmake:65 (message):
Please ensure your system has sufficient memory.
Call Stack (most recent call first):
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:74 (vcpkg_execute_build_process)
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:16 (vcpkg_cmake_build)
ports/zlib/portfile.cmake:26 (vcpkg_cmake_install)
scripts/ports.cmake:168 (include)`

-- Restarting build without parallelism
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
Command failed: "C:/Program Files/CMake/bin/cmake.exe" --build . --config Debug --target install -- -v -j33
Working Directory: C:/Users/PTamt/source/repos/VCPKG/vcpkg/buildtrees/zlib/x64-windows-vs22-dbg
See logs for more information:
C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\install-x64-windows-vs22-dbg-out.log
C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\install-x64-windows-vs22-dbg-out-1.log

Call Stack (most recent call first):
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:74 (vcpkg_execute_build_process)
installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:16 (vcpkg_cmake_build)
ports/zlib/portfile.cmake:26 (vcpkg_cmake_install)
scripts/ports.cmake:168 (include)

error: building zlib:x64-windows-vs22 failed with: BUILD_FAILED
Elapsed time to handle zlib:x64-windows-vs22: 6.9 s
Please ensure you're using the latest port files with git pull and vcpkg update.
Then check for known issues at:
https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+zlib
You can submit a new issue at:
https://github.com/microsoft/vcpkg/issues/new?title=[zlib]+Build+error&body=Copy+issue+body+from+C%3A%2FUsers%2FPTamt%2Fsource%2Frepos%2FVCPKG%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

I also attach the diagnostic logs
C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\install-x64-windows-vs22-dbg-out.log
C:\Users\PTamt\source\repos\VCPKG\

install-x64-windows-vs22-dbg-out-1.log

install-x64-windows-vs22-dbg-out.log

I tried to run execute the commands stated in the logs by hand:

C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\x64-windows-vs22-dbg> C:/PROGRA~1/CMake/bin/cmcldeps.exe RC C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\src\v1.3-8825ee792f.clean\win32\zlib1.rc CMakeFiles\zlib.dir\win32\zlib1.rc.res.d CMakeFiles\zlib.dir\win32\zlib1.rc.res "Note: including file: " "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33126/bin/Hostx64/x64/cl.exe" "C:\PROGRA~2\Windows Kits\10\bin\10.0.22621.0\x64\rc.exe" -DNO_FSEEKO -DZLIB_DLL -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -I C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\src\v1.3-8825ee792f.clean -I C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\x64-windows-vs22-dbg -c65001 /DWIN32 -D_DEBUG /fo CMakeFiles\zlib.dir\win32\zlib1.rc.res C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\src\v1.3-8825ee792f.clean\win32\zlib1.rc
output

cl : Command line warning D9002 : ignoring unknown option '-c65001' C:\Users\PTamt\source\repos\VCPKG\vcpkg\buildtrees\zlib\src\v1.3-8825ee792f.clean\win32\zlib1.rc(1): fatal error C1083: Cannot open include file: 'winver.h': No such file or directory

So it seems that winver.h seems not to be found. But the file exists in my machine under path:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um

What it might goes wrong?
Does vcpkg needs any includes in order to work and find that file?

I am at your disposal for any additional logs

@PTamis PTamis changed the title zlib build failure with vcpkg [zlib] build failure with vcpkg Oct 19, 2023
@JonLiu1993 JonLiu1993 added the category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team. label Oct 20, 2023
@PTamis
Copy link
Author

PTamis commented Oct 20, 2023

I de-installed everything and installed again only VS 2022 Release edition and not the preview that I had before.
I now run vcpkg directly from VS 2022 terminal in order to be the one installed from VS.

Again the same error is produced.

PS C:\Users\PTamt\source\repos\motion-engine> vcpkg.exe install
warning: Starting with the September 2023 release, the default triplet for vcpkg libraries will change from x86-windows to the detected host triplet (x64-windows). To resolve this message, add --triplet x86-windows to keep the same behavior.
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
Detecting compiler hash for triplet x64-windows...
Detecting compiler hash for triplet x86-windows...
The following packages will be built and installed:
  * vcpkg-cmake:x64-windows -> 2021-12-20 -- C:\Users\PTamt\AppData\Local\vcpkg\registries\git-trees\a35eb7c761372dc64526d59fa918a13c0dfbba1b
    zlib:x86-windows -> 1.3 -- C:\Users\PTamt\AppData\Local\vcpkg\registries\git-trees\5ac18c6e6e3e2bf5a9e3d0bc8a845f198e4c4e05
Additional packages (*) will be modified to complete this operation.
A suitable version of 7zip was not found (required v21.7.0) Downloading portable 7zip 21.7.0...
Downloading 7zip...
https://www.7-zip.org/a/7z2107-extra.7z->C:\Users\PTamt\AppData\Local\vcpkg\downloads\7z2107-extra.7z
Downloading https://www.7-zip.org/a/7z2107-extra.7z
Extracting 7zip...
Restored 0 package(s) from C:\Users\PTamt\AppData\Local\vcpkg\archives in 1 ms. Use --debug to see more details.
Installing 1/2 vcpkg-cmake:x64-windows...
Building vcpkg-cmake:x64-windows...
-- Installing port from location: C:\Users\PTamt\AppData\Local\vcpkg\registries\git-trees\a35eb7c761372dc64526d59fa918a13c0dfbba1b
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_get_vars.cmake
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/cmake_get_vars
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/cmake_get_vars/CMakeLists.txt
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg-port-config.cmake
-- Installing: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/pkgs/vcpkg-cmake_x64-windows/share/vcpkg-cmake/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 199 ms.
Elapsed time to handle vcpkg-cmake:x64-windows: 361 ms
Installing 2/2 zlib:x86-windows...
Building zlib:x86-windows...
-- Installing port from location: C:\Users\PTamt\AppData\Local\vcpkg\registries\git-trees\5ac18c6e6e3e2bf5a9e3d0bc8a845f198e4c4e05
-- Downloading https://github.com/madler/zlib/archive/v1.3.tar.gz -> madler-zlib-v1.3.tar.gz...
-- Extracting source C:/Users/PTamt/AppData/Local/vcpkg/downloads/madler-zlib-v1.3.tar.gz
-- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch
-- Applying patch 0002-skip-building-examples.patch
-- Applying patch 0003-build-static-or-shared-not-both.patch
-- Applying patch 0004-android-and-mingw-fixes.patch
-- Using source at C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/blds/zlib/src/v1.3-8825ee792f.clean
-- Found external ninja('1.11.0').
-- Configuring x86-windows
-- Building x86-windows-dbg
CMake Warning at scripts/cmake/vcpkg_execute_build_process.cmake:65 (message):
  Please ensure your system has sufficient memory.
Call Stack (most recent call first):
  C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:102 (vcpkg_execute_build_process)
  C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:41 (vcpkg_cmake_build)
  C:/Users/PTamt/AppData/Local/vcpkg/registries/git-trees/5ac18c6e6e3e2bf5a9e3d0bc8a845f198e4c4e05/portfile.cmake:26 (vcpkg_cmake_install)
  scripts/ports.cmake:147 (include)


-- Restarting build without parallelism
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
    Command failed: "C:/Program Files/CMake/bin/cmake.exe" --build . --config Debug --target install -- -v -j33
    Working Directory: C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/vcpkg/blds/zlib/x86-windows-dbg
    See logs for more information:
      C:\Users\PTamt\source\repos\motion-engine\vcpkg_installed\vcpkg\blds\zlib\install-x86-windows-dbg-out.log
      C:\Users\PTamt\source\repos\motion-engine\vcpkg_installed\vcpkg\blds\zlib\install-x86-windows-dbg-out-1.log

Call Stack (most recent call first):
  C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake:102 (vcpkg_execute_build_process)
  C:/Users/PTamt/source/repos/motion-engine/vcpkg_installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake:41 (vcpkg_cmake_build)
  C:/Users/PTamt/AppData/Local/vcpkg/registries/git-trees/5ac18c6e6e3e2bf5a9e3d0bc8a845f198e4c4e05/portfile.cmake:26 (vcpkg_cmake_install)
  scripts/ports.cmake:147 (include)


error: building zlib:x86-windows failed with: BUILD_FAILED
Elapsed time to handle zlib:x86-windows: 7.4 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
    https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+zlib
You can submit a new issue at:
    https://github.com/microsoft/vcpkg/issues/new?title=[zlib]+Build+error&body=Copy+issue+body+from+C%3A%2FUsers%2FPTamt%2Fsource%2Frepos%2Fmotion-engine%2Fvcpkg_installed%2Fvcpkg%2Fissue_body.md

vcpkg.json file used

{
    "name": "versions-test",
    "version": "1.0.0",
    "dependencies": [
        {
            "name": "zlib",
            "version>=": "1.3"
        }
    ],
    "builtin-baseline": "76d4836f3b1e027758044fdbdde91256b0f0955d"
}

I don't think I am using a community-triplet but rather a tested triplet x64-windows

@PTamis
Copy link
Author

PTamis commented Oct 20, 2023

I installed a new VM win11 with only VS2022 and git.
And then vcpkg worked fined!

I checked the logs and saw that vcpkg was downloading cmake in order to make the build.
I saw the version and downloaded the same version in my PC, and then everything worked fine!

Then I also changed cmake version to 3.27.7 (latest release) and again everything worked fine.
Before I had 3.28 which is still RC

I installed again CMAKE 3.28-rc2 in mt PC and again the problem reproduced.
So I gone and installed CMAKE 3.28 RC also to my fresh VM, and zlib compilation worked fine.

So CMAKE 3.28 along with something else in combination in my PC (which I still do not know) make vcpkg build to fail.
I will stick to 3.27.7 cmake and close the issue since it works for me now, but I think this issue will open again when more people move to CMAKE 3.28.

@PTamis PTamis closed this as completed Oct 20, 2023
@Naheulf
Copy link

Naheulf commented Oct 20, 2023

Got the same error with both CMake 3.28.0-rc1 and CMake 3.28.0-rc2 in windows sandbox.

However I use cmd.exe instead of VS console. Command line:

.\vcpkg install zlib --triplet=x64-windows

Also works fine with CMake 3.27.7 without reboot. Thanks @PTamis to find it.

Edit: created a topic on cmake forum for that issue. Hopefully it will allow kitware to fix that issue before the non rc release.

@mathstuf
Copy link

Can someone who can reproduce the issue please bisect to find out what broke things? git bisect --first-parent start v3.28.0-rc2 v3.27.7 would probably be the easiest.

@PTamis
Copy link
Author

PTamis commented Oct 21, 2023

Thanks @mathstuf for the recommendation.
According to git bisect this is the commit that breaks staff

 git bisect bad
4771544386302f0642b83194656d14014d600e70 is the first bad commit
commit 4771544386302f0642b83194656d14014d600e70
Merge: 00a7acb7da a5f98df778
Author: Brad King <brad.king@kitware.com>
Date:   Wed Sep 6 15:22:13 2023 +0000

    Merge topic 'replace-cmsysprocess-with-cmuvprocesschain'

    a5f98df778 Source: Fix mysterious new IWYU warnings
    0712e3cfea cmCTestCoverageHandler: Replace cmsysProcess with cmUVProcessChain
    96b3dd329e cmCTestLaunchReporter: Replace cmsysProcess with cmUVProcessChain
    b15ad7ebb6 cmCTest: Replace cmsysProcess with cmUVProcessChain
    50a6e78a82 cmSystemTools::RunSingleCommand(): Replace cmsysProcess with cmUVProcessChain
    49a37d5a97 cmCTestScriptHandler: Replace cmsysProcess with cmUVProcessChain
    bc702aa97e cmcmd: Replace cmsysProcess with cmUVProcessChain
    ec124582ac cmProcessTools::RunProcess(): Replace cmsysProcess with cmUVProcessChain
    ...

    Acked-by: Kitware Robot <kwrobot@kitware.com>
    Tested-by: buildbot <buildbot@kitware.com>
    Merge-request: !8665

 Source/CPack/cmCPackSTGZGenerator.cxx              |   2 +
 Source/CTest/cmCTestBZR.cxx                        |  31 +-
 Source/CTest/cmCTestBuildAndTestHandler.cxx        |  15 +-
 Source/CTest/cmCTestBuildHandler.cxx               | 291 +++++++-------
 Source/CTest/cmCTestBuildHandler.h                 |   6 +-
 Source/CTest/cmCTestCVS.cxx                        |  18 +-
 Source/CTest/cmCTestConfigureHandler.cxx           |   2 +-
 Source/CTest/cmCTestCoverageHandler.cxx            | 111 +-----
 Source/CTest/cmCTestGIT.cxx                        | 130 +++----
 Source/CTest/cmCTestHG.cxx                         |  35 +-
 Source/CTest/cmCTestLaunch.cxx                     | 126 +++---
 Source/CTest/cmCTestLaunch.h                       |   5 +-
 Source/CTest/cmCTestLaunchReporter.cxx             |  50 +--
 Source/CTest/cmCTestLaunchReporter.h               |   4 +-
 Source/CTest/cmCTestP4.cxx                         |  66 ++--
 Source/CTest/cmCTestP4.h                           |   2 +-
 Source/CTest/cmCTestSVN.cxx                        |  36 +-
 Source/CTest/cmCTestSVN.h                          |   2 +-
 Source/CTest/cmCTestScriptHandler.cxx              |  84 ++--
 Source/CTest/cmCTestVC.cxx                         |  45 +--
 Source/CTest/cmCTestVC.h                           |   9 +-
 Source/LexerParser/cmCTestResourceGroupsLexer.cxx  |   4 +
 Source/LexerParser/cmCTestResourceGroupsLexer.in.l |   4 +
 Source/cmCTest.cxx                                 | 429 +++++++++++----------
 Source/cmCTest.h                                   |  16 +-
 Source/cmExecuteProcessCommand.cxx                 | 384 +++++++++---------
 Source/cmProcessTools.cxx                          |  82 ++--
 Source/cmProcessTools.h                            |   8 +-
 Source/cmSystemTools.cxx                           | 288 ++++++++------
 Source/cmSystemTools.h                             |  21 +-
 Source/cmcmd.cxx                                   | 102 +++--
 Tests/CMakeLib/testUVProcessChainHelper.cxx        |   4 -
 Tests/RunCMake/CMakeLists.txt                      |   1 +
 Tests/RunCMake/execute_process/RunCMakeTest.cmake  |   1 +
 Tests/RunCMake/execute_process/Stdin-stdin.txt     |   1 +
 Tests/RunCMake/execute_process/Stdin-stdout.txt    |   1 +
 Tests/RunCMake/execute_process/Stdin.cmake         |   1 +
 Utilities/IWYU/mapping.imp                         |   4 +
 bootstrap                                          |   1 +
 39 files changed, 1237 insertions(+), 1185 deletions(-)
 create mode 100644 Tests/RunCMake/execute_process/Stdin-stdin.txt
 create mode 100644 Tests/RunCMake/execute_process/Stdin-stdout.txt
 create mode 100644 Tests/RunCMake/execute_process/Stdin.cmake

I don't know if it helps but the exe that breaks staff is cmcldeps.exe because at first I was coping only cmake.exe.
After I restarted the procedure from start coping both cmcldeps.exe cmake.exe to my CMAKE bin folder I was able to reproduce the issue again.

@mathstuf
Copy link

Thanks for bisecting! Could you bisect that MR to try and narrow it down further? git bisect start 4771544386302f0642b83194656d14014d600e70 4771544386302f0642b83194656d14014d600e70~. CMake issue reported here for further investigations on our side: https://gitlab.kitware.com/cmake/cmake/-/issues/25355

@PTamis
Copy link
Author

PTamis commented Oct 22, 2023

Hello, I did bisect again as asked.
Bellow are the results:

git bisect good
50a6e78a8295ac89149639839cebc3b61f2f9db3 is the first bad commit
commit 50a6e78a8295ac89149639839cebc3b61f2f9db3
Author: Kyle Edwards <kyle.edwards@kitware.com>
Date:   Tue Jul 25 15:12:33 2023 -0400

    cmSystemTools::RunSingleCommand(): Replace cmsysProcess with cmUVProcessChain

    And pass OUTPUT_PASSTHROUGH in one call where it was missing.

 Source/cmSystemTools.cxx | 202 ++++++++++++++++++++++++++---------------------
 Source/cmSystemTools.h   |   1 -
 Source/cmcmd.cxx         |   3 +-
 3 files changed, 116 insertions(+), 90 deletions(-)

Indeed, when I build CMAKE 50a6e78a8295ac89149639839cebc3b61f2f9db3 command .\vcpkg.exe install zlib breaks
While with the previous commit 49a37d5a97ccd6e59b9e205a96b9dec251708f76 it is fine.

Hope it helps further.

@PTamis
Copy link
Author

PTamis commented Oct 23, 2023

Issue found in CMAKE.
For reference also see:
https://gitlab.kitware.com/cmake/cmake/-/issues/25355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team.
Projects
None yet
Development

No branches or pull requests

4 participants