summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/cmake/config-ix.cmake19
-rw-r--r--llvm/include/llvm/Config/config.h.cmake6
-rw-r--r--llvm/lib/Support/CMakeLists.txt5
-rw-r--r--llvm/lib/Support/CRC.cpp2
-rw-r--r--llvm/lib/Support/Compression.cpp4
-rw-r--r--llvm/test/CMakeLists.txt2
-rw-r--r--llvm/test/lit.site.cfg.py.in2
-rw-r--r--llvm/unittests/Support/CompressionTest.cpp2
8 files changed, 32 insertions, 10 deletions
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index d5a15a680a6..e7e5e5dcf2f 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -56,6 +56,7 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
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)
@@ -117,8 +118,17 @@ 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.*")
+ set(HAVE_LIBZ 0)
if(LLVM_ENABLE_ZLIB)
- find_package(ZLIB REQUIRED)
+ 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()
endif()
# Don't look for these libraries on Windows.
@@ -505,8 +515,11 @@ else( LLVM_ENABLE_THREADS )
message(STATUS "Threads disabled.")
endif()
-if(LLVM_ENABLE_ZLIB)
- find_package(ZLIB REQUIRED)
+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)
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index db170ae5d62..1a38bc15ab9 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -109,6 +109,9 @@
/* Define to 1 if you have the `pthread_setname_np' function. */
#cmakedefine HAVE_PTHREAD_SETNAME_NP ${HAVE_PTHREAD_SETNAME_NP}
+/* Define to 1 if you have the `z' library (-lz). */
+#cmakedefine HAVE_LIBZ ${HAVE_LIBZ}
+
/* Define to 1 if you have the <link.h> header file. */
#cmakedefine HAVE_LINK_H ${HAVE_LINK_H}
@@ -223,6 +226,9 @@
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
#cmakedefine HAVE_VALGRIND_VALGRIND_H ${HAVE_VALGRIND_VALGRIND_H}
+/* Define to 1 if you have the <zlib.h> header file. */
+#cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H}
+
/* Have host's _alloca */
#cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA}
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 2fa641ff5da..ddc4d2324a0 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -1,4 +1,7 @@
-set(system_libs ${ZLIB_LIBRARY})
+set(system_libs)
+if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
+ set(system_libs ${system_libs} ${ZLIB_LIBRARIES})
+endif()
if( MSVC OR MINGW )
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
diff --git a/llvm/lib/Support/CRC.cpp b/llvm/lib/Support/CRC.cpp
index a3dba1a3aa1..7c008d3b599 100644
--- a/llvm/lib/Support/CRC.cpp
+++ b/llvm/lib/Support/CRC.cpp
@@ -25,7 +25,7 @@
using namespace llvm;
-#if !LLVM_ENABLE_ZLIB
+#if LLVM_ENABLE_ZLIB == 0 || !HAVE_ZLIB_H
static const uint32_t CRCTable[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
diff --git a/llvm/lib/Support/Compression.cpp b/llvm/lib/Support/Compression.cpp
index 4165a2740cd..97d5ffaadf8 100644
--- a/llvm/lib/Support/Compression.cpp
+++ b/llvm/lib/Support/Compression.cpp
@@ -17,13 +17,13 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
-#if LLVM_ENABLE_ZLIB
+#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
#include <zlib.h>
#endif
using namespace llvm;
-#if LLVM_ENABLE_ZLIB
+#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
static Error createError(StringRef Err) {
return make_error<StringError>(Err, inconvertibleErrorCode());
}
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index be5abe279af..6a11dcb1109 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -1,12 +1,12 @@
llvm_canonicalize_cmake_booleans(
BUILD_SHARED_LIBS
HAVE_LIBXAR
+ HAVE_LIBZ
HAVE_OCAMLOPT
HAVE_OCAML_OUNIT
LLVM_ENABLE_DIA_SDK
LLVM_ENABLE_FFI
LLVM_ENABLE_THREADS
- LLVM_ENABLE_ZLIB
LLVM_INCLUDE_GO_TESTS
LLVM_LIBXML2_ENABLED
LLVM_LINK_LLVM_DYLIB
diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index 0f5e09b6cda..e313b0d3504 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -36,7 +36,7 @@ config.host_cxx = "@HOST_CXX@"
config.host_ldflags = '@HOST_LDFLAGS@'
config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zlib = @HAVE_LIBZ@
config.have_libxar = @HAVE_LIBXAR@
config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
config.enable_ffi = @LLVM_ENABLE_FFI@
diff --git a/llvm/unittests/Support/CompressionTest.cpp b/llvm/unittests/Support/CompressionTest.cpp
index 51723898e95..cc7be431b62 100644
--- a/llvm/unittests/Support/CompressionTest.cpp
+++ b/llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
namespace {
-#if LLVM_ENABLE_ZLIB
+#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
void TestZlibCompression(StringRef Input, int Level) {
SmallString<32> Compressed;
OpenPOWER on IntegriCloud