Dependency not found in CMake when enable AFL_LLVM_CMPLOG

Author: YunlongsCreated Mar 13, 2026Updated Mar 16, 2026

Version clang: 21.1.8

Describe the bug In the building of libpng, if AFL_LLVM_CMPLOG was set to '1'. The CMake system will report missing dependency of zlib.

To Reproduce Steps to reproduce the behavior:

  1. export CC=afl-clang-lto
  2. export CC=afl-clang-lto++
  3. export AFL_LLVM_CMPLOG=1
bash
git clone https://github.com/pnggroup/libpng.git
# 1. Clean and prepare build directory
rm -rf /tmp/build_tmp
mkdir -p /tmp/build_tmp
cd /tmp/build_tmp

# 2. Install zlib dependency if not already installed
echo "Checking for zlib dependency..."
if ! pkg-config --exists zlib; then
    echo "zlib not found, installing from system packages..."
    apt-get update && apt-get install -y zlib1g-dev
fi

# 3. Try CMake build first
echo "Attempting CMake build..."
    # Configure with CMake
    cmake -DCMAKE_INSTALL_PREFIX="$WORK" \
          -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
          -DCMAKE_C_COMPILER="$CC" \
          -DCMAKE_C_FLAGS="$CFLAGS" \
          -DPNG_SHARED=OFF \
          -DPNG_STATIC=ON \
          -DPNG_TESTS=OFF \
          -DPNG_TOOLS=OFF \
          -DBUILD_TESTING=OFF \
          "$SRC"

Expected behavior If I didn't set AFL_LLVM_CMPLOG, libpng will build successfully. But the building will fail if I set AFL_LLVM_CMPLOG.

Screen output/Screenshots

Checking for zlib dependency...
Attempting CMake build...
-- The C compiler identification is Clang 21.1.8
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/afl-clang-lto - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Building for target architecture: x86_64
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.3")
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.28/Modules/FindZLIB.cmake:199 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:141 (find_package)

Additional context Add any other context about the problem here.