diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -114,18 +114,20 @@ set(LLVM_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT}) endif() +if(LLVM_ENABLE_ZLIB) + if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON) + find_package(ZLIB REQUIRED) + elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + find_package(ZLIB) + else() + set(ZLIB_FOUND FALSE) + endif() + set(LLVM_ENABLE_ZLIB "${ZLIB_FOUND}") +endif() + # Don't look for these libraries if we're using MSan, since uninstrumented third # party code may call MSan interceptors like strlen, leading to false positives. if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") - if(LLVM_ENABLE_ZLIB) - if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON) - find_package(ZLIB REQUIRED) - else() - find_package(ZLIB) - endif() - set(LLVM_ENABLE_ZLIB "${ZLIB_FOUND}") - endif() - # Don't look for these libraries on Windows. if (NOT PURE_WINDOWS) # Skip libedit if using ASan as it contains memory leaks. @@ -164,8 +166,6 @@ endif() endif() endif() -else() - set(LLVM_ENABLE_ZLIB FALSE) endif() if (LLVM_ENABLE_LIBXML2 STREQUAL "FORCE_ON" AND NOT LLVM_LIBXML2_ENABLED)