Skip to content

Commit

Permalink
Remove indirect dependency on system ZLIB (#26888)
Browse files Browse the repository at this point in the history
* Remove indirect dependency on system ZLIB

- build LLVM without ZLIB support
- use the bundled ZLIB for libgit

* backport bundled zlib patch
  • Loading branch information
vchuravy authored and ararslan committed Apr 30, 2018
1 parent 509d6a1 commit 8770821
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
7 changes: 6 additions & 1 deletion deps/libgit2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: | $(build_prefix)/manifest/curl
endif
endif

LIBGIT2_OPTS := $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DTHREADSAFE=ON
LIBGIT2_OPTS := $(CMAKE_COMMON) -DCMAKE_BUILD_TYPE=Release -DTHREADSAFE=ON -DUSE_BUNDLED_ZLIB=ON
ifeq ($(OS),WINNT)
LIBGIT2_OPTS += -DWIN32=ON -DMINGW=ON
ifneq ($(ARCH),x86_64)
Expand Down Expand Up @@ -71,6 +71,10 @@ $(LIBGIT2_SRC_PATH)/libgit2-ssh-loop.patch-applied: $(LIBGIT2_SRC_PATH)/source-e
cd $(LIBGIT2_SRC_PATH) && \
patch -p1 -f < $(SRCDIR)/patches/libgit2-ssh-loop.patch
echo 1 > $@
$(LIBGIT2_SRC_PATH)/libgit2-bundled_zlib.patch-applied: $(LIBGIT2_SRC_PATH)/source-extracted | $(LIBGIT2_SRC_PATH)/libgit2-ssh-loop.patch-applied
cd $(LIBGIT2_SRC_PATH) && \
patch -p1 -f < $(SRCDIR)/patches/libgit2-bundled_zlib.patch
echo 1 > $@

$(build_datarootdir)/julia/cert.pem:
$(JLDOWNLOAD) $(shell pwd)/cacert-2018-01-17.pem https://curl.haxx.se/ca/cacert-2018-01-17.pem
Expand All @@ -85,6 +89,7 @@ $(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: \
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-verify.patch-applied \
$(LIBGIT2_SRC_PATH)/libgit2-mbedtls-fixup.patch-applied \
$(LIBGIT2_SRC_PATH)/libgit2-ssh-loop.patch-applied \
$(LIBGIT2_SRC_PATH)/libgit2-bundled_zlib.patch-applied \

$(BUILDDIR)/$(LIBGIT2_SRC_DIR)/build-configured: $(LIBGIT2_SRC_PATH)/source-extracted $(build_datarootdir)/julia/cert.pem
mkdir -p $(dir $@)
Expand Down
1 change: 1 addition & 0 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ LLVM_CXXFLAGS += $(CXXFLAGS)
LLVM_CPPFLAGS += $(CPPFLAGS)
LLVM_LDFLAGS += $(LDFLAGS)
LLVM_CMAKE += -DLLVM_TARGETS_TO_BUILD:STRING="$(LLVM_TARGETS)" -DCMAKE_BUILD_TYPE="$(LLVM_CMAKE_BUILDTYPE)"
LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF
ifeq ($(USE_POLLY_ACC),1)
LLVM_CMAKE += -DPOLLY_ENABLE_GPGPU_CODEGEN=ON
endif
Expand Down
55 changes: 55 additions & 0 deletions deps/patches/libgit2-bundled_zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 637f75b2a341df6e308f8a20827dea938a39bd35 Mon Sep 17 00:00:00 2001
From: Valentin Churavy <[email protected]>
Date: Mon, 23 Apr 2018 13:27:50 -0400
Subject: [PATCH] backport bundled zlib patch

---
CMakeLists.txt | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4783e3ef9..aff84e75c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,6 +44,7 @@ OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
OPTION( VALGRIND "Configure build for valgrind" OFF )
OPTION( CURL "Use curl for HTTP if available" ON)
OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
+OPTION( USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF )

IF(DEBUG_POOL)
ADD_DEFINITIONS(-DGIT_DEBUG_POOL)
@@ -340,17 +341,21 @@ ELSE()
ENDIF()

# Optional external dependency: zlib
-FIND_PACKAGE(ZLIB)
-IF (ZLIB_FOUND)
- INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
- LINK_LIBRARIES(${ZLIB_LIBRARIES})
- IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- LIST(APPEND LIBGIT2_PC_LIBS "-lz")
+IF(NOT USE_BUNDLED_ZLIB)
+ FIND_PACKAGE(ZLIB)
+ IF (ZLIB_FOUND)
+ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
+ LINK_LIBRARIES(${ZLIB_LIBRARIES})
+ IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ LIST(APPEND LIBGIT2_PC_LIBS "-lz")
+ ELSE()
+ SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib")
+ ENDIF()
ELSE()
- SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib")
+ MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
ENDIF()
-ELSE()
- MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
+ENDIF()
+IF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
INCLUDE_DIRECTORIES(deps/zlib)
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
FILE(GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h)
--
2.17.0

0 comments on commit 8770821

Please sign in to comment.