Index: llvm/cmake/config-ix.cmake =================================================================== --- llvm/cmake/config-ix.cmake +++ llvm/cmake/config-ix.cmake @@ -43,7 +43,6 @@ check_include_file(termios.h HAVE_TERMIOS_H) check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) -check_include_file(zlib.h HAVE_ZLIB_H) check_include_file(fenv.h HAVE_FENV_H) check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT) check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT) @@ -105,17 +104,12 @@ # 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.*") - set(HAVE_LIBZ 0) if(LLVM_ENABLE_ZLIB) - foreach(library z zlib_static zlib) - string(TOUPPER ${library} library_suffix) - check_library_exists(${library} compress2 "" HAVE_LIBZ_${library_suffix}) - if(HAVE_LIBZ_${library_suffix}) - set(HAVE_LIBZ 1) - set(ZLIB_LIBRARIES "${library}") - break() - endif() - endforeach() + find_package(ZLIB) + if (ZLIB_FOUND) + set(HAVE_LIBZ TRUE) + include_directories(${ZLIB_INCLUDE_DIR}) + endif() endif() # Don't look for these libraries on Windows. @@ -481,13 +475,6 @@ message(STATUS "Threads disabled.") endif() -if (LLVM_ENABLE_ZLIB ) - # Check if zlib is available in the system. - if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ ) - set(LLVM_ENABLE_ZLIB 0) - endif() -endif() - if (LLVM_ENABLE_DOXYGEN) message(STATUS "Doxygen enabled.") find_package(Doxygen REQUIRED) Index: llvm/include/llvm/Config/config.h.cmake =================================================================== --- llvm/include/llvm/Config/config.h.cmake +++ llvm/include/llvm/Config/config.h.cmake @@ -223,9 +223,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_VALGRIND_VALGRIND_H ${HAVE_VALGRIND_VALGRIND_H} -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H} - /* Have host's _alloca */ #cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA} @@ -293,9 +290,6 @@ /* Doesn't use `cmakedefine` because it is allowed to be empty. */ #define LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" -/* Define if zlib compression is available */ -#cmakedefine01 LLVM_ENABLE_ZLIB - /* Define if overriding target triple is enabled */ #cmakedefine LLVM_TARGET_TRIPLE_ENV "${LLVM_TARGET_TRIPLE_ENV}" Index: llvm/lib/Support/CMakeLists.txt =================================================================== --- llvm/lib/Support/CMakeLists.txt +++ llvm/lib/Support/CMakeLists.txt @@ -1,5 +1,5 @@ set(system_libs) -if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ ) +if ( HAVE_LIBZ ) set(system_libs ${system_libs} ${ZLIB_LIBRARIES}) endif() if( MSVC OR MINGW ) Index: llvm/lib/Support/Compression.cpp =================================================================== --- llvm/lib/Support/Compression.cpp +++ llvm/lib/Support/Compression.cpp @@ -18,13 +18,13 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" -#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H +#if HAVE_LIBZ #include #endif using namespace llvm; -#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ +#if HAVE_LIBZ static Error createError(StringRef Err) { return make_error(Err, inconvertibleErrorCode()); } Index: llvm/unittests/Support/CompressionTest.cpp =================================================================== --- llvm/unittests/Support/CompressionTest.cpp +++ llvm/unittests/Support/CompressionTest.cpp @@ -22,7 +22,7 @@ namespace { -#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ +#if HAVE_LIBZ void TestZlibCompression(StringRef Input, zlib::CompressionLevel Level) { SmallString<32> Compressed;