Skip to content

Commit 00e38ba

Browse files
committed
Merge branch 'ab/auto-detect-zlib-compress2'
The build procedure has been taught to notice older version of zlib and enable our replacement uncompress2() automatically. * ab/auto-detect-zlib-compress2: compat: auto-detect if zlib has uncompress2()
2 parents f2cb46a + 0756477 commit 00e38ba

File tree

8 files changed

+21
-46
lines changed

8 files changed

+21
-46
lines changed

Makefile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ all::
264264
#
265265
# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
266266
#
267-
# Define NO_UNCOMPRESS2 if your zlib does not have uncompress2.
268-
#
269267
# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
270268
# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
271269
#
@@ -871,6 +869,7 @@ LIB_OBJS += commit-reach.o
871869
LIB_OBJS += commit.o
872870
LIB_OBJS += compat/obstack.o
873871
LIB_OBJS += compat/terminal.o
872+
LIB_OBJS += compat/zlib-uncompress2.o
874873
LIB_OBJS += config.o
875874
LIB_OBJS += connect.o
876875
LIB_OBJS += connected.o
@@ -1204,7 +1203,8 @@ THIRD_PARTY_SOURCES += compat/regex/%
12041203
THIRD_PARTY_SOURCES += sha1collisiondetection/%
12051204
THIRD_PARTY_SOURCES += sha1dc/%
12061205

1207-
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)
1206+
# xdiff and reftable libs may in turn depend on what is in libgit.a
1207+
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
12081208
EXTLIBS =
12091209

12101210
GIT_USER_AGENT = git/$(GIT_VERSION)
@@ -1736,11 +1736,6 @@ ifdef NO_DEFLATE_BOUND
17361736
BASIC_CFLAGS += -DNO_DEFLATE_BOUND
17371737
endif
17381738

1739-
ifdef NO_UNCOMPRESS2
1740-
BASIC_CFLAGS += -DNO_UNCOMPRESS2
1741-
REFTABLE_OBJS += compat/zlib-uncompress2.o
1742-
endif
1743-
17441739
ifdef NO_POSIX_GOODIES
17451740
BASIC_CFLAGS += -DNO_POSIX_GOODIES
17461741
endif

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "repository.h"
1919
#include "mem-pool.h"
2020

21-
#include <zlib.h>
2221
typedef struct git_zstream {
2322
z_stream z;
2423
unsigned long avail_in;

ci/lib.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ esac
197197
case "$jobname" in
198198
linux32)
199199
CC=gcc
200-
MAKEFLAGS="$MAKEFLAGS NO_UNCOMPRESS2=1"
201200
;;
202201
linux-musl)
203202
CC=gcc

compat/zlib-uncompress2.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include "git-compat-util.h"
2+
3+
#if ZLIB_VERNUM < 0x1290
14
/* taken from zlib's uncompr.c
25
36
commit cacf7f1d4e3d44d871b605da3b647f07d718623f
@@ -8,16 +11,11 @@
811
912
*/
1013

11-
#include "../reftable/system.h"
12-
#define z_const
13-
1414
/*
1515
* Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
1616
* For conditions of distribution and use, see copyright notice in zlib.h
1717
*/
1818

19-
#include <zlib.h>
20-
2119
/* clang-format off */
2220

2321
/* ===========================================================================
@@ -93,3 +91,6 @@ int ZEXPORT uncompress2 (
9391
err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
9492
err;
9593
}
94+
#else
95+
static void *dummy_variable = &dummy_variable;
96+
#endif

config.mak.uname

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ ifeq ($(uname_S),Linux)
6666
# centos7/rhel7 provides gcc 4.8.5 and zlib 1.2.7.
6767
ifneq ($(findstring .el7.,$(uname_R)),)
6868
BASIC_CFLAGS += -std=c99
69-
NO_UNCOMPRESS2 = YesPlease
7069
endif
7170
endif
7271
ifeq ($(uname_S),GNU/kFreeBSD)
@@ -268,10 +267,6 @@ ifeq ($(uname_S),FreeBSD)
268267
FILENO_IS_A_MACRO = UnfortunatelyYes
269268
endif
270269
ifeq ($(uname_S),OpenBSD)
271-
# Versions < 7.0 need compatibility layer
272-
ifeq ($(shell expr "$(uname_R)" : "[1-6]\."),2)
273-
NO_UNCOMPRESS2 = UnfortunatelyYes
274-
endif
275270
NO_STRCASESTR = YesPlease
276271
NO_MEMMEM = YesPlease
277272
USE_ST_TIMESPEC = YesPlease
@@ -531,7 +526,6 @@ ifeq ($(uname_S),Interix)
531526
endif
532527
endif
533528
ifeq ($(uname_S),Minix)
534-
NO_UNCOMPRESS2 = YesPlease
535529
NO_IPV6 = YesPlease
536530
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
537531
NO_NSEC = YesPlease
@@ -587,7 +581,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
587581
NO_SETENV = YesPlease
588582
NO_UNSETENV = YesPlease
589583
NO_MKDTEMP = YesPlease
590-
NO_UNCOMPRESS2 = YesPlease
591584
# Currently libiconv-1.9.1.
592585
OLD_ICONV = UnfortunatelyYes
593586
NO_REGEX = NeedsStartEnd

configure.ac

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -664,22 +664,9 @@ AC_LINK_IFELSE([ZLIBTEST_SRC],
664664
NO_DEFLATE_BOUND=yes])
665665
LIBS="$old_LIBS"
666666

667-
AC_DEFUN([ZLIBTEST_UNCOMPRESS2_SRC], [
668-
AC_LANG_PROGRAM([#include <zlib.h>],
669-
[uncompress2(NULL,NULL,NULL,NULL);])])
670-
AC_MSG_CHECKING([for uncompress2 in -lz])
671-
old_LIBS="$LIBS"
672-
LIBS="$LIBS -lz"
673-
AC_LINK_IFELSE([ZLIBTEST_UNCOMPRESS2_SRC],
674-
[AC_MSG_RESULT([yes])],
675-
[AC_MSG_RESULT([no])
676-
NO_UNCOMPRESS2=yes])
677-
LIBS="$old_LIBS"
678-
679667
GIT_UNSTASH_FLAGS($ZLIB_PATH)
680668

681669
GIT_CONF_SUBST([NO_DEFLATE_BOUND])
682-
GIT_CONF_SUBST([NO_UNCOMPRESS2])
683670

684671
#
685672
# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,

git-compat-util.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,18 @@ void unleak_memory(const void *ptr, size_t len);
13981398
#define UNLEAK(var) do {} while (0)
13991399
#endif
14001400

1401+
#define z_const
1402+
#include <zlib.h>
1403+
1404+
#if ZLIB_VERNUM < 0x1290
1405+
/*
1406+
* This is uncompress2, which is only available in zlib >= 1.2.9
1407+
* (released as of early 2017). See compat/zlib-uncompress2.c.
1408+
*/
1409+
int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
1410+
uLong *sourceLen);
1411+
#endif
1412+
14011413
/*
14021414
* This include must come after system headers, since it introduces macros that
14031415
* replace system names.

reftable/system.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ license that can be found in the LICENSE file or at
1616
#include "hash.h" /* hash ID, sizes.*/
1717
#include "dir.h" /* remove_dir_recursively, for tests.*/
1818

19-
#include <zlib.h>
20-
21-
#ifdef NO_UNCOMPRESS2
22-
/*
23-
* This is uncompress2, which is only available in zlib >= 1.2.9
24-
* (released as of early 2017)
25-
*/
26-
int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
27-
uLong *sourceLen);
28-
#endif
29-
3019
int hash_size(uint32_t id);
3120

3221
#endif

0 commit comments

Comments
 (0)