madler / zlib

A massively spiffy yet delicately unobtrusive compression library.
http://zlib.net/
Other
5.44k stars 2.41k forks source link

Problem with CMake`s check_type_size #972

Open pfhgil opened 2 months ago

pfhgil commented 2 months ago

Hi, I'm getting a rather strange error when installing zlib using vcpkg. I use MinGW Clang for cross compilation and my MinGW triplet for vcpkg (it differs from the standard x64-mingw-dynamic triplet only in the installation of the mingw-llvm toolchain). No error occurs when building for the host device.

I noticed that this error seems to appear on line 42 of zlib's CMakeLists.txt. This line says check_type_size(off64_t OFF64_T)

Host:

Target:

Vcpkg version: 2024-02-07-8a83681f921b10d86ae626fd833c253f4f8c355b Build type: release

Target triplet:

set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "/home/ilya/pixelfield/test-windows/cmake/mingw.cmake")

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_ENV_PASSTHROUGH PATH)

set(VCPKG_CMAKE_SYSTEM_NAME MinGW)
set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)

Using toolchain:

SET(CMAKE_C_COMPILER "$ENV{SUNGEAR_LLVM_MINGW_PATH}/bin/x86_64-w64-mingw32-clang")
SET(CMAKE_CXX_COMPILER "$ENV{SUNGEAR_LLVM_MINGW_PATH}/bin/x86_64-w64-mingw32-clang++")
SET(CMAKE_ASM_COMPILER "$ENV{SUNGEAR_LLVM_MINGW_PATH}/bin/x86_64-w64-mingw32-clang")
set(CMAKE_RC_COMPILER "$ENV{SUNGEAR_LLVM_MINGW_PATH}/bin/llvm-rc")

config-sg-x64-mingw-dynamic-out.log:

[1/2] "/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" -E chdir "../../sg-x64-mingw-dynamic-dbg" "/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" "/home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/src/v1.3.1-2e5db616bf.clean" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=/home/ilya/.vcpkg-clion/vcpkg/packages/zlib_sg-x64-mingw-dynamic/debug" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DSKIP_INSTALL_FILES=ON" "-DZLIB_BUILD_EXAMPLES=OFF" "-DCMAKE_MAKE_PROGRAM=/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/ilya/pixelfield/test-windows/cmake/mingw.cmake" "-DVCPKG_TARGET_TRIPLET=sg-x64-mingw-dynamic" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=/home/ilya/.vcpkg-clion/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=static" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=/home/ilya/.vcpkg-clion/vcpkg" "-D_VCPKG_INSTALLED_DIR=/home/ilya/pixelfield/test-windows/cmake-build-release-mingw-x86-64/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF" "-DSKIP_INSTALL_HEADERS=ON"
FAILED: ../../sg-x64-mingw-dynamic-dbg/CMakeCache.txt 
"/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" -E chdir "../../sg-x64-mingw-dynamic-dbg" "/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" "/home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/src/v1.3.1-2e5db616bf.clean" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=/home/ilya/.vcpkg-clion/vcpkg/packages/zlib_sg-x64-mingw-dynamic/debug" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DSKIP_INSTALL_FILES=ON" "-DZLIB_BUILD_EXAMPLES=OFF" "-DCMAKE_MAKE_PROGRAM=/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/ilya/pixelfield/test-windows/cmake/mingw.cmake" "-DVCPKG_TARGET_TRIPLET=sg-x64-mingw-dynamic" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=/home/ilya/.vcpkg-clion/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=static" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=/home/ilya/.vcpkg-clion/vcpkg" "-D_VCPKG_INSTALLED_DIR=/home/ilya/pixelfield/test-windows/cmake-build-release-mingw-x86-64/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF" "-DSKIP_INSTALL_HEADERS=ON"
-- The C compiler identification is Clang 18.1.5
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/ilya/pixelfield/llvm-mingw-20240502-msvcrt-ubuntu-20.04-x86_64/bin/x86_64-w64-mingw32-clang
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: /home/ilya/pixelfield/llvm-mingw-20240502-msvcrt-ubuntu-20.04-x86_64/bin/x86_64-w64-mingw32-clang - works
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for sys/types.h - found
-- Looking for stdint.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for stdint.h - found
-- Looking for stddef.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for stddef.h - found
-- Check size of off64_t
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
CMake Error at /home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/share/cmake-3.27/Modules/CheckTypeSize.cmake:146 (try_compile):
  Cannot copy output executable

    ''

  to destination specified by COPY_FILE:

    '/home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/sg-x64-mingw-dynamic-dbg/CMakeFiles/CheckTypeSize/OFF64_T.bin'

  because:

    No such file or directory (input)

  Recorded try_compile output location doesn't exist:

    /home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/sg-x64-mingw-dynamic-dbg/CMakeFiles/CMakeScratch/TryCompile-QwZPze/cmTC_e2858

Call Stack (most recent call first):
  /home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/share/cmake-3.27/Modules/CheckTypeSize.cmake:271 (__check_type_size_impl)
  CMakeLists.txt:42 (check_type_size)

-- Looking for fseeko
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for fseeko - found
-- Looking for unistd.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for unistd.h - found
-- Configuring incomplete, errors occurred!
[2/2] "/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" -E chdir ".." "/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" "/home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/src/v1.3.1-2e5db616bf.clean" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=/home/ilya/.vcpkg-clion/vcpkg/packages/zlib_sg-x64-mingw-dynamic" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DSKIP_INSTALL_FILES=ON" "-DZLIB_BUILD_EXAMPLES=OFF" "-DCMAKE_MAKE_PROGRAM=/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/ilya/pixelfield/test-windows/cmake/mingw.cmake" "-DVCPKG_TARGET_TRIPLET=sg-x64-mingw-dynamic" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=/home/ilya/.vcpkg-clion/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=static" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=/home/ilya/.vcpkg-clion/vcpkg" "-D_VCPKG_INSTALLED_DIR=/home/ilya/pixelfield/test-windows/cmake-build-release-mingw-x86-64/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
FAILED: ../CMakeCache.txt 
"/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" -E chdir ".." "/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake" "/home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/src/v1.3.1-2e5db616bf.clean" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=/home/ilya/.vcpkg-clion/vcpkg/packages/zlib_sg-x64-mingw-dynamic" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-DSKIP_INSTALL_FILES=ON" "-DZLIB_BUILD_EXAMPLES=OFF" "-DCMAKE_MAKE_PROGRAM=/home/ilya/.vcpkg-clion/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja" "-DCMAKE_SYSTEM_NAME=MinGW" "-DBUILD_SHARED_LIBS=ON" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/ilya/pixelfield/test-windows/cmake/mingw.cmake" "-DVCPKG_TARGET_TRIPLET=sg-x64-mingw-dynamic" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=/home/ilya/.vcpkg-clion/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=static" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=/home/ilya/.vcpkg-clion/vcpkg" "-D_VCPKG_INSTALLED_DIR=/home/ilya/pixelfield/test-windows/cmake-build-release-mingw-x86-64/vcpkg_installed" "-DVCPKG_MANIFEST_INSTALL=OFF"
-- The C compiler identification is Clang 18.1.5
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/ilya/pixelfield/llvm-mingw-20240502-msvcrt-ubuntu-20.04-x86_64/bin/x86_64-w64-mingw32-clang
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Check for working C compiler: /home/ilya/pixelfield/llvm-mingw-20240502-msvcrt-ubuntu-20.04-x86_64/bin/x86_64-w64-mingw32-clang - works
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for sys/types.h - found
-- Looking for stdint.h
System is unknown to cmake, create:I noticed that this error seems to appear on line 42 of zlib's CMakeLists.txt. This line says ```check_type_size(off64_t OFF64_T)```
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for stdint.h - found
-- Looking for stddef.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for stddef.h - found
-- Check size of off64_t
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
CMake Error at /home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/share/cmake-3.27/Modules/CheckTypeSize.cmake:146 (try_compile):
  Cannot copy output executable

    ''

  to destination specified by COPY_FILE:

    '/home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/sg-x64-mingw-dynamic-rel/CMakeFiles/CheckTypeSize/OFF64_T.bin'

  because:

    No such file or directory (input)

  Recorded try_compile output location doesn't exist:

    /home/ilya/.vcpkg-clion/vcpkg/buildtrees/zlib/sg-x64-mingw-dynamic-rel/CMakeFiles/CMakeScratch/TryCompile-IHn0yx/cmTC_b32eb

Call Stack (most recent call first):
  /home/ilya/.vcpkg-clion/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/share/cmake-3.27/Modules/CheckTypeSize.cmake:271 (__check_type_size_impl)
  CMakeLists.txt:42 (check_type_size)

-- Looking for fseeko
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for fseeko - found
-- Looking for unistd.h
System is unknown to cmake, create:
Platform/MinGW to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
-- Looking for unistd.h - found
-- Configuring incomplete, errors occurred!
ninja: build stopped: subcommand failed.
WildCard65 commented 1 week ago

Your Mingw triplet is bad potentially, CMAKE_SYSTEM_NAME ends up as 'MINGW' instead 'Windows'.

The following system names are possible on Windows:

CYGWIN - Only if using the Cygwin version of CMake. MSYS - Only if using the MSYS2 version of CMAKE inside an MSYS environment (MSYSTEM=MSYS) Windows - Only if the above 2 don't apply.

There may be more cases, which you can see here: https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html