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()
This commit is contained in:
Junio C Hamano 2022-02-16 15:14:29 -08:00
Родитель f2cb46a6b3 07564773c2
Коммит 00e38ba6d8
8 изменённых файлов: 21 добавлений и 46 удалений

Просмотреть файл

@ -264,8 +264,6 @@ all::
#
# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
#
# Define NO_UNCOMPRESS2 if your zlib does not have uncompress2.
#
# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
# as the compiler can crash (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
#
@ -871,6 +869,7 @@ LIB_OBJS += commit-reach.o
LIB_OBJS += commit.o
LIB_OBJS += compat/obstack.o
LIB_OBJS += compat/terminal.o
LIB_OBJS += compat/zlib-uncompress2.o
LIB_OBJS += config.o
LIB_OBJS += connect.o
LIB_OBJS += connected.o
@ -1204,7 +1203,8 @@ THIRD_PARTY_SOURCES += compat/regex/%
THIRD_PARTY_SOURCES += sha1collisiondetection/%
THIRD_PARTY_SOURCES += sha1dc/%
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB)
# xdiff and reftable libs may in turn depend on what is in libgit.a
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
EXTLIBS =
GIT_USER_AGENT = git/$(GIT_VERSION)
@ -1736,11 +1736,6 @@ ifdef NO_DEFLATE_BOUND
BASIC_CFLAGS += -DNO_DEFLATE_BOUND
endif
ifdef NO_UNCOMPRESS2
BASIC_CFLAGS += -DNO_UNCOMPRESS2
REFTABLE_OBJS += compat/zlib-uncompress2.o
endif
ifdef NO_POSIX_GOODIES
BASIC_CFLAGS += -DNO_POSIX_GOODIES
endif

Просмотреть файл

@ -18,7 +18,6 @@
#include "repository.h"
#include "mem-pool.h"
#include <zlib.h>
typedef struct git_zstream {
z_stream z;
unsigned long avail_in;

Просмотреть файл

@ -197,7 +197,6 @@ esac
case "$jobname" in
linux32)
CC=gcc
MAKEFLAGS="$MAKEFLAGS NO_UNCOMPRESS2=1"
;;
linux-musl)
CC=gcc

Просмотреть файл

@ -1,3 +1,6 @@
#include "git-compat-util.h"
#if ZLIB_VERNUM < 0x1290
/* taken from zlib's uncompr.c
commit cacf7f1d4e3d44d871b605da3b647f07d718623f
@ -8,16 +11,11 @@
*/
#include "../reftable/system.h"
#define z_const
/*
* Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <zlib.h>
/* clang-format off */
/* ===========================================================================
@ -93,3 +91,6 @@ int ZEXPORT uncompress2 (
err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
err;
}
#else
static void *dummy_variable = &dummy_variable;
#endif

Просмотреть файл

@ -66,7 +66,6 @@ ifeq ($(uname_S),Linux)
# centos7/rhel7 provides gcc 4.8.5 and zlib 1.2.7.
ifneq ($(findstring .el7.,$(uname_R)),)
BASIC_CFLAGS += -std=c99
NO_UNCOMPRESS2 = YesPlease
endif
endif
ifeq ($(uname_S),GNU/kFreeBSD)
@ -268,10 +267,6 @@ ifeq ($(uname_S),FreeBSD)
FILENO_IS_A_MACRO = UnfortunatelyYes
endif
ifeq ($(uname_S),OpenBSD)
# Versions < 7.0 need compatibility layer
ifeq ($(shell expr "$(uname_R)" : "[1-6]\."),2)
NO_UNCOMPRESS2 = UnfortunatelyYes
endif
NO_STRCASESTR = YesPlease
NO_MEMMEM = YesPlease
USE_ST_TIMESPEC = YesPlease
@ -531,7 +526,6 @@ ifeq ($(uname_S),Interix)
endif
endif
ifeq ($(uname_S),Minix)
NO_UNCOMPRESS2 = YesPlease
NO_IPV6 = YesPlease
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
NO_NSEC = YesPlease
@ -587,7 +581,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
NO_SETENV = YesPlease
NO_UNSETENV = YesPlease
NO_MKDTEMP = YesPlease
NO_UNCOMPRESS2 = YesPlease
# Currently libiconv-1.9.1.
OLD_ICONV = UnfortunatelyYes
NO_REGEX = NeedsStartEnd

Просмотреть файл

@ -664,22 +664,9 @@ AC_LINK_IFELSE([ZLIBTEST_SRC],
NO_DEFLATE_BOUND=yes])
LIBS="$old_LIBS"
AC_DEFUN([ZLIBTEST_UNCOMPRESS2_SRC], [
AC_LANG_PROGRAM([#include <zlib.h>],
[uncompress2(NULL,NULL,NULL,NULL);])])
AC_MSG_CHECKING([for uncompress2 in -lz])
old_LIBS="$LIBS"
LIBS="$LIBS -lz"
AC_LINK_IFELSE([ZLIBTEST_UNCOMPRESS2_SRC],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
NO_UNCOMPRESS2=yes])
LIBS="$old_LIBS"
GIT_UNSTASH_FLAGS($ZLIB_PATH)
GIT_CONF_SUBST([NO_DEFLATE_BOUND])
GIT_CONF_SUBST([NO_UNCOMPRESS2])
#
# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,

Просмотреть файл

@ -1398,6 +1398,18 @@ void unleak_memory(const void *ptr, size_t len);
#define UNLEAK(var) do {} while (0)
#endif
#define z_const
#include <zlib.h>
#if ZLIB_VERNUM < 0x1290
/*
* This is uncompress2, which is only available in zlib >= 1.2.9
* (released as of early 2017). See compat/zlib-uncompress2.c.
*/
int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong *sourceLen);
#endif
/*
* This include must come after system headers, since it introduces macros that
* replace system names.

Просмотреть файл

@ -16,17 +16,6 @@ https://developers.google.com/open-source/licenses/bsd
#include "hash.h" /* hash ID, sizes.*/
#include "dir.h" /* remove_dir_recursively, for tests.*/
#include <zlib.h>
#ifdef NO_UNCOMPRESS2
/*
* This is uncompress2, which is only available in zlib >= 1.2.9
* (released as of early 2017)
*/
int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong *sourceLen);
#endif
int hash_size(uint32_t id);
#endif