llvm / llvm/llvm-project

ZLIB can not be configured with zlib-ng config files

Open
#164,629 1 comment 1 reaction 0 assignees View on GitHub
cmake
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://github.com/llvm/llvm-project/blob/d08cbc1cdd7b73e9a582f5602e8ca4829decab8c/llvm/cmake/config-ix.cmake#L171C1-L182C10

```cmake
if(ZLIB_FOUND)
# Check if zlib we found is usable; for example, we may have found a 32-bit
# library on a 64-bit system which would result in a link-time failure.
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY})
check_symbol_exists(compress2 zlib.h HAVE_ZLIB)
cmake_pop_check_state()
if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB)
message(FATAL_ERROR "Failed to configure zlib")
endif()
endif()
```

The old CMake ZLIB module variables `ZLIB_INCLUDE_DIRS` and `ZLIB_LIBRARY` are not availiable with modern CMake config files from [zlib-ng](https://github.com/zlib-ng/zlib-ng). If you configure with `CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON` and zlib-ng (in compatebility mode) the configuration fails.

Note that with modern CMake config files there is no need for the check in the first place.

Contributor guide

Open the contributing guide

Research direction

Start in llvm/cmake/config-ix.cmake at the linked ZLIB usability check. Reproduce configuration with CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON and zlib-ng in compatibility mode, then verify that modern zlib-ng config files configure successfully without relying on the unavailable legacy variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.