[med-svn] [Git][med-team/libdeflate][upstream] New upstream version 1.13

Lance Lin (@linqigang) gitlab at salsa.debian.org
Tue Aug 9 14:02:21 BST 2022



Lance Lin pushed to branch upstream at Debian Med / libdeflate


Commits:
35d898da by Lance Lin at 2022-08-09T20:00:51+07:00
New upstream version 1.13
- - - - -


14 changed files:

- .github/workflows/ci.yml
- Makefile
- NEWS.md
- README.md
- lib/arm/cpu_features.h
- lib/arm/crc32_impl.h
- lib/arm/crc32_pmull_helpers.h
- lib/matchfinder_common.h
- lib/x86/crc32_pclmul_template.h
- libdeflate.h
- programs/prog_util.c
- + scripts/check.sh
- scripts/gzip_tests.sh
- scripts/run_tests.sh


Changes:

=====================================
.github/workflows/ci.yml
=====================================
@@ -22,7 +22,7 @@ jobs:
     - run: scripts/run_tests.sh
 
   other-arch-build-and-test:
-    name: Build and test (${{ matrix.arch }}, Debian Buster, ${{ matrix.compiler }})
+    name: Build and test (${{ matrix.arch }}, Debian Bullseye, ${{ matrix.compiler }})
     strategy:
       matrix:
         arch: [armv6, armv7, aarch64, s390x, ppc64le]
@@ -30,10 +30,10 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout at v2
-      - uses: uraimo/run-on-arch-action at v2.0.5
+      - uses: uraimo/run-on-arch-action at v2.2.0
         with:
           arch: ${{ matrix.arch }}
-          distro: buster
+          distro: bullseye
           githubToken: ${{ github.token }}
           install: |
             apt-get update
@@ -70,14 +70,24 @@ jobs:
     - run: make all check
 
   windows-msys2-build-and-test:
-    name: Build and test (Windows, MSYS2)
+    name: Build and test (Windows, MSYS2, ${{matrix.sys}})
     runs-on: windows-latest
+    strategy:
+      matrix:
+        include:
+        - { sys: mingw64, env: x86_64 }
+        - { sys: mingw32, env: i686 }
+    defaults:
+      run:
+        shell: msys2 {0}
     steps:
     - uses: actions/checkout at v2
-    - shell: bash
-      run: |
-        PATH="C:\\msys64\\mingw64\\bin:C:\\msys64\\usr\\bin:$PATH" \
-          make CC=gcc all check
+    - uses: msys2/setup-msys2 at v2
+      with:
+        msystem: ${{matrix.sys}}
+        update: true
+        install: make mingw-w64-${{matrix.env}}-cc mingw-w64-${{matrix.env}}-zlib
+    - run: make all check
 
   windows-msvc-build:
     name: Build (Windows, Visual Studio)


=====================================
Makefile
=====================================
@@ -99,11 +99,6 @@ ifneq ($(findstring -mingw,$(TARGET_MACHINE))$(findstring -windows-gnu,$(TARGET_
     SHARED_LIB_CFLAGS  :=
     SHARED_LIB_LDFLAGS := -Wl,--out-implib,libdeflate.lib \
                           -Wl,--output-def,libdeflate.def
-    # Only if not LLVM
-    ifeq ($(findstring -windows-gnu,$(TARGET_MACHINE)),)
-        SHARED_LIB_LDFLAGS += -Wl,--add-stdcall-alias
-    endif
-
     PROG_SUFFIX        := .exe
     PROG_CFLAGS        := -static -municode
     HARD_LINKS         :=
@@ -383,15 +378,7 @@ test_programs:$(TEST_PROGRAMS)
 # A minimal 'make check' target.  This only runs some quick tests;
 # use scripts/run_tests.sh if you want to run the full tests.
 check:test_programs
-	LD_LIBRARY_PATH=. ./benchmark$(PROG_SUFFIX) \
-			< ./benchmark$(PROG_SUFFIX) > /dev/null
-	LD_LIBRARY_PATH=. ./benchmark$(PROG_SUFFIX) -C libz \
-			< ./benchmark$(PROG_SUFFIX) > /dev/null
-	LD_LIBRARY_PATH=. ./benchmark$(PROG_SUFFIX) -D libz \
-			< ./benchmark$(PROG_SUFFIX) > /dev/null
-	for prog in test_*; do		\
-		LD_LIBRARY_PATH=. ./$$prog || exit 1;	\
-	done
+	./scripts/check.sh
 
 # Run the clang static analyzer.
 scan-build:


=====================================
NEWS.md
=====================================
@@ -1,5 +1,12 @@
 # libdeflate release notes
 
+## Version 1.13
+
+* Changed the 32-bit Windows build of the library to use the default calling
+  convention (cdecl) instead of stdcall, reverting a change from libdeflate 1.4.
+
+* Fixed a couple macOS compatibility issues with the gzip program.
+
 ## Version 1.12
 
 This release focuses on improving the performance of the CRC-32 and Adler-32


=====================================
README.md
=====================================
@@ -183,10 +183,7 @@ guessing.  However, libdeflate's decompression routines do optionally provide
 the actual number of output bytes in case you need it.
 
 Windows developers: note that the calling convention of libdeflate.dll is
-"stdcall" -- the same as the Win32 API.  If you call into libdeflate.dll using a
-non-C/C++ language, or dynamically using LoadLibrary(), make sure to use the
-stdcall convention.  Using the wrong convention may crash your application.
-(Note: older versions of libdeflate used the "cdecl" convention instead.)
+"cdecl".  (libdeflate v1.4 through v1.12 used "stdcall" instead.)
 
 # Bindings for other programming languages
 


=====================================
lib/arm/cpu_features.h
=====================================
@@ -82,9 +82,9 @@ static inline u32 get_arm_cpu_features(void) { return 0; }
  */
 #if HAVE_NEON_NATIVE || \
 	(HAVE_NEON_TARGET && GCC_PREREQ(6, 1) && defined(__ARM_FP))
-#  define HAVE_NEON_INTRIN 1
+#  define HAVE_NEON_INTRIN	1
 #else
-#  define HAVE_NEON_INTRIN 0
+#  define HAVE_NEON_INTRIN	0
 #endif
 
 /* PMULL */


=====================================
lib/arm/crc32_impl.h
=====================================
@@ -166,8 +166,8 @@ crc32_arm_crc(u32 crc, const u8 *p, size_t len)
 				wp0++;
 			} while (wp0 != wp0_end);
 			crc = combine_crcs_slow(crc, crc1, crc2, crc3);
-			len -= CRC32_NUM_CHUNKS * CRC32_FIXED_CHUNK_LEN;
 			p += CRC32_NUM_CHUNKS * CRC32_FIXED_CHUNK_LEN;
+			len -= CRC32_NUM_CHUNKS * CRC32_FIXED_CHUNK_LEN;
 		}
 		/*
 		 * Due to the large fixed chunk length used above, there might


=====================================
lib/arm/crc32_pmull_helpers.h
=====================================
@@ -129,25 +129,28 @@ ADD_SUFFIX(fold_partial_vec)(uint8x16_t v, const u8 *p, size_t len,
 	 * vtbl(v, shift_tab[len+16..len+31]) right shifts v by len bytes.
 	 */
 	static const u8 shift_tab[48] = {
-		0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-		0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
 		0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-		0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-		0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 	};
 	const uint8x16_t lshift = vld1q_u8(&shift_tab[len]);
 	const uint8x16_t rshift = vld1q_u8(&shift_tab[len + 16]);
-	uint8x16_t x0, x1;
+	uint8x16_t x0, x1, bsl_mask;
 
 	/* x0 = v left-shifted by '16 - len' bytes */
 	x0 = vtbl(v, lshift);
 
+	/* Create a vector of '16 - len' 0x00 bytes, then 'len' 0xff bytes. */
+	bsl_mask = (uint8x16_t)vshrq_n_s8((int8x16_t)rshift, 7);
+
 	/*
 	 * x1 = the last '16 - len' bytes from v (i.e. v right-shifted by 'len'
 	 * bytes) followed by the remaining data.
 	 */
-	x1 = vbslq_u8((uint8x16_t)vshrq_n_s8((int8x16_t)rshift, 7),
+	x1 = vbslq_u8(bsl_mask /* 0 bits select from arg3, 1 bits from arg2 */,
 		      vld1q_u8(p + len - 16), vtbl(v, rshift));
 
 	return fold_vec(x0, x1, multipliers_1);


=====================================
lib/matchfinder_common.h
=====================================
@@ -27,19 +27,16 @@ loaded_u32_to_u24(u32 v)
 }
 
 /*
- * Load the next 3 bytes from the memory location @p into the 24 low-order bits
- * of a 32-bit value.  The order in which the 3 bytes will be arranged as octets
- * in the 24 bits is platform-dependent.  At least LOAD_U24_REQUIRED_NBYTES
- * bytes must be available at @p; note that this may be more than 3.
+ * Load the next 3 bytes from @p into the 24 low-order bits of a 32-bit value.
+ * The order in which the 3 bytes will be arranged as octets in the 24 bits is
+ * platform-dependent.  At least 4 bytes (not 3) must be available at @p.
  */
 static forceinline u32
 load_u24_unaligned(const u8 *p)
 {
 #if UNALIGNED_ACCESS_IS_FAST
-#  define LOAD_U24_REQUIRED_NBYTES 4
 	return loaded_u32_to_u24(load_u32_unaligned(p));
 #else
-#  define LOAD_U24_REQUIRED_NBYTES 3
 	if (CPU_IS_LITTLE_ENDIAN())
 		return ((u32)p[0] << 0) | ((u32)p[1] << 8) | ((u32)p[2] << 16);
 	else


=====================================
lib/x86/crc32_pclmul_template.h
=====================================
@@ -84,12 +84,12 @@ ADD_SUFFIX(fold_partial_vec)(__m128i v, const u8 *p, size_t len,
 	 * pshufb(v, shift_tab[len+16..len+31]) right shifts v by len bytes.
 	 */
 	static const u8 shift_tab[48] = {
-		0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-		0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
 		0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
-		0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-		0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 	};
 	__m128i lshift = _mm_loadu_si128((const void *)&shift_tab[len]);
 	__m128i rshift = _mm_loadu_si128((const void *)&shift_tab[len + 16]);
@@ -104,6 +104,7 @@ ADD_SUFFIX(fold_partial_vec)(__m128i v, const u8 *p, size_t len,
 	 */
 	x1 = _mm_blendv_epi8(_mm_shuffle_epi8(v, rshift),
 			     _mm_loadu_si128((const void *)(p + len - 16)),
+			     /* msb 0/1 of each byte selects byte from arg1/2 */
 			     rshift);
 
 	return fold_vec(x0, x1, multipliers_1);


=====================================
libdeflate.h
=====================================
@@ -10,15 +10,15 @@ extern "C" {
 #endif
 
 #define LIBDEFLATE_VERSION_MAJOR	1
-#define LIBDEFLATE_VERSION_MINOR	12
-#define LIBDEFLATE_VERSION_STRING	"1.12"
+#define LIBDEFLATE_VERSION_MINOR	13
+#define LIBDEFLATE_VERSION_STRING	"1.13"
 
 #include <stddef.h>
 #include <stdint.h>
 
 /*
  * On Windows, if you want to link to the DLL version of libdeflate, then
- * #define LIBDEFLATE_DLL.  Note that the calling convention is "stdcall".
+ * #define LIBDEFLATE_DLL.  Note that the calling convention is "cdecl".
  */
 #ifdef LIBDEFLATE_DLL
 #  ifdef BUILDING_LIBDEFLATE
@@ -31,12 +31,6 @@ extern "C" {
 #  define LIBDEFLATEEXPORT
 #endif
 
-#if defined(_WIN32) && !defined(_WIN64) && defined(LIBDEFLATE_DLL)
-#  define LIBDEFLATEAPI_ABI	__stdcall
-#else
-#  define LIBDEFLATEAPI_ABI
-#endif
-
 #if defined(BUILDING_LIBDEFLATE) && defined(__GNUC__) && \
 	defined(_WIN32) && !defined(_WIN64)
     /*
@@ -44,13 +38,11 @@ extern "C" {
      * Realign the stack when entering libdeflate to avoid crashing in SSE/AVX
      * code when called from an MSVC-compiled application.
      */
-#  define LIBDEFLATEAPI_STACKALIGN	__attribute__((force_align_arg_pointer))
+#  define LIBDEFLATEAPI	__attribute__((force_align_arg_pointer))
 #else
-#  define LIBDEFLATEAPI_STACKALIGN
+#  define LIBDEFLATEAPI
 #endif
 
-#define LIBDEFLATEAPI	LIBDEFLATEAPI_ABI LIBDEFLATEAPI_STACKALIGN
-
 /* ========================================================================== */
 /*                             Compression                                    */
 /* ========================================================================== */


=====================================
programs/prog_util.c
=====================================
@@ -25,6 +25,12 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#ifdef __APPLE__
+/* for O_NOFOLLOW */
+#  undef _POSIX_C_SOURCE
+#  define _DARWIN_C_SOURCE
+#endif
+
 #include "prog_util.h"
 
 #include <errno.h>
@@ -351,8 +357,11 @@ map_file_contents(struct file_stream *strm, u64 size)
 	strm->mmap_mem = mmap(NULL, size, PROT_READ, MAP_SHARED, strm->fd, 0);
 	if (strm->mmap_mem == MAP_FAILED) {
 		strm->mmap_mem = NULL;
-		if (errno == ENODEV) /* mmap isn't supported on this file */
+		if (errno == ENODEV /* standard */ ||
+		    errno == EINVAL /* macOS */) {
+			/* mmap isn't supported on this file */
 			return read_full_contents(strm);
+		}
 		if (errno == ENOMEM) {
 			msg("%"TS" is too large to be processed by this "
 			    "program", strm->name);


=====================================
scripts/check.sh
=====================================
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# A minimal 'make check' target.  This only runs some quick tests;
+# use scripts/run_tests.sh if you want to run the full tests.
+
+set -e -u
+
+if [ "$(uname)" = Darwin ]; then
+	export DYLD_FALLBACK_LIBRARY_PATH=.
+else
+	export LD_LIBRARY_PATH=.
+fi
+cat lib/*.c | ./benchmark > /dev/null
+cat lib/*.c | ./benchmark -C libz > /dev/null
+cat lib/*.c | ./benchmark -D libz > /dev/null
+for prog in ./test_*; do
+	"$prog"
+done


=====================================
scripts/gzip_tests.sh
=====================================
@@ -15,9 +15,15 @@ set -eu -o pipefail
 
 export -n GZIP GUNZIP TESTDATA
 
+ORIG_PWD=$PWD
 TMPDIR="$(mktemp -d)"
 CURRENT_TEST=
 
+BSD_STAT=false
+if ! stat --version 2>&1 | grep -q coreutils; then
+	BSD_STAT=true
+fi
+
 cleanup() {
 	if [ -n "$CURRENT_TEST" ]; then
 		echo "TEST FAILED: \"$CURRENT_TEST\""
@@ -27,14 +33,13 @@ cleanup() {
 
 trap cleanup EXIT
 
-TESTDATA="$(readlink -f "$TESTDATA")"
-cd "$TMPDIR"
-
 begin_test() {
 	CURRENT_TEST="$1"
 	rm -rf -- "${TMPDIR:?}"/*
-	cp "$TESTDATA" file
-	chmod +w file
+	cd "$ORIG_PWD"
+	cp "$TESTDATA" "$TMPDIR/file"
+	chmod +w "$TMPDIR/file"
+	cd "$TMPDIR"
 }
 
 gzip() {
@@ -45,6 +50,40 @@ gunzip() {
 	$GUNZIP "$@"
 }
 
+get_filesize() {
+	local file=$1
+
+	if $BSD_STAT; then
+		stat -f %z "$file"
+	else
+		stat -c %s "$file"
+	fi
+}
+
+get_linkcount() {
+	local file=$1
+
+	if $BSD_STAT; then
+		stat -f %l "$file"
+	else
+		stat -c %h "$file"
+	fi
+}
+
+get_modeandtimestamps() {
+	local file=$1
+
+	if $BSD_STAT; then
+		stat -f "%p;%a;%m" "$file"
+	elif [ "$(uname -m)" = s390x ]; then
+		# Use seconds precision instead of nanoseconds.
+		# TODO: why is this needed?  QEMU user mode emulation bug?
+		stat -c "%a;%X;%Y" "$file"
+	else
+		stat -c "%a;%x;%y" "$file"
+	fi
+}
+
 assert_status() {
 	local expected_status="$1"
 	local expected_msg="$2"
@@ -94,26 +133,6 @@ assert_equals() {
 	fi
 }
 
-# Get the filesystem type.
-FSTYPE=$(df -T . | tail -1 | awk '{print $2}')
-
-# If gzip or gunzip is the GNU version, require that it supports the '-k'
-# option.  This option was added in v1.6, released in 2013.
-check_version_prereq() {
-	local prog=$1
-
-	if ! echo | { $prog -k || true; } |& grep -q 'invalid option'; then
-		return 0
-	fi
-	if ! $prog -V |& grep -q 'Free Software Foundation'; then
-		echo 1>&2 "Unexpected case: not GNU $prog, but -k option is invalid"
-		exit 1
-	fi
-	echo "GNU $prog is too old; skipping gzip/gunzip tests"
-	exit 0
-}
-check_version_prereq gzip
-check_version_prereq gunzip
 
 begin_test 'Basic compression and decompression works'
 cp file orig
@@ -179,7 +198,7 @@ gunzip -kfd file.gz
 
 
 begin_test 'Compression levels'
-if [ "$GZIP" = /bin/gzip ]; then
+if [ "$GZIP" = /bin/gzip ] || [ "$GZIP" = /usr/bin/gzip ]; then
 	assert_error '\<invalid option\>' gzip -10
 	max_level=9
 else
@@ -333,13 +352,13 @@ cmp <(echo b) b
 begin_test '(gzip) hard linked file skipped without -f or -c'
 cp file orig
 ln file link
-assert_equals 2 "$(stat -c %h file)"
+assert_equals 2 "$(get_linkcount file)"
 assert_skipped gzip file
 gzip -c file > /dev/null
-assert_equals 2 "$(stat -c %h file)"
+assert_equals 2 "$(get_linkcount file)"
 gzip -f file
-assert_equals 1 "$(stat -c %h link)"
-assert_equals 1 "$(stat -c %h file.gz)"
+assert_equals 1 "$(get_linkcount link)"
+assert_equals 1 "$(get_linkcount file.gz)"
 cmp link orig
 # XXX: GNU gzip skips hard linked files with -k, libdeflate's doesn't
 
@@ -348,13 +367,13 @@ begin_test '(gunzip) hard linked file skipped without -f or -c'
 gzip file
 ln file.gz link.gz
 cp file.gz orig.gz
-assert_equals 2 "$(stat -c %h file.gz)"
+assert_equals 2 "$(get_linkcount file.gz)"
 assert_skipped gunzip file.gz
 gunzip -c file.gz > /dev/null
-assert_equals 2 "$(stat -c %h file.gz)"
+assert_equals 2 "$(get_linkcount file.gz)"
 gunzip -f file
-assert_equals 1 "$(stat -c %h link.gz)"
-assert_equals 1 "$(stat -c %h file)"
+assert_equals 1 "$(get_linkcount link.gz)"
+assert_equals 1 "$(get_linkcount file)"
 cmp link.gz orig.gz
 
 
@@ -433,20 +452,12 @@ assert_error '\<invalid suffix\>' gunzip -S '""' file
 
 
 begin_test 'Timestamps and mode are preserved'
-if [ "$FSTYPE" = shiftfs ]; then
-	# In Travis CI, the filesystem (shiftfs) only supports seconds precision
-	# timestamps.  Nanosecond precision still sometimes seems to work,
-	# probably due to caching, but it is unreliable.
-	format='%a;%X;%Y'
-else
-	format='%a;%x;%y'
-fi
 chmod 777 file
-orig_stat="$(stat -c "$format" file)"
+orig_stat=$(get_modeandtimestamps file)
 gzip file
 sleep 1
 gunzip file.gz
-assert_equals "$orig_stat" "$(stat -c "$format" file)"
+assert_equals "$orig_stat" "$(get_modeandtimestamps file)"
 
 
 begin_test 'Decompressing multi-member gzip file'


=====================================
scripts/run_tests.sh
=====================================
@@ -41,8 +41,14 @@ MAKE="make -j$(getconf _NPROCESSORS_ONLN)"
 
 CC_VERSION=$($CC --version | head -1)
 
+UNAME=$(uname)
 ARCH=$(uname -m)
 
+SHLIB=libdeflate.so
+if [ "$UNAME" = Darwin ]; then
+	SHLIB=libdeflate.dylib
+fi
+
 for skip in SKIP_FREESTANDING SKIP_VALGRIND SKIP_UBSAN SKIP_ASAN SKIP_CFI \
 	    SKIP_SHARED_LIB; do
 	if [ "${!skip:-}" = "1" ]; then
@@ -58,7 +64,9 @@ INDENT=0
 
 log() {
 	echo -n "[$(date)] "
-	head -c $(( INDENT * 4 )) /dev/zero | tr '\0' ' '
+	if (( INDENT != 0 )); then
+		head -c $(( INDENT * 4 )) /dev/zero | tr '\0' ' '
+	fi
 	echo "$@"
 }
 
@@ -98,6 +106,10 @@ valgrind_version_at_least() {
 	local want_vers=$1
 	local vers
 
+	if ! type -P valgrind &> /dev/null; then
+		return 1
+	fi
+
 	vers=$(valgrind --version | grep -E -o '[0-9\.]+' | head -1)
 
 	[ "$want_vers" = "$(echo -e "$vers\n$want_vers" | sort -V | head -1)" ]
@@ -170,12 +182,38 @@ verify_freestanding_build() {
 	fi
 }
 
+is_compatible_system_gzip() {
+	local prog=$1
+
+	# Needs to exist.
+	if ! [ -e "$prog" ]; then
+		return 1
+	fi
+	# Needs to be GNU gzip.
+	if ! "$prog" -V 2>&1 | grep -q 'Free Software Foundation'; then
+		return 1
+	fi
+	# Needs to support the -k option, i.e. be v1.6 or later.
+	if echo | { "$prog" -k 2>&1 >/dev/null || true; } \
+				| grep -q 'invalid option'; then
+		return 1
+	fi
+	return 0
+}
+
 gzip_tests() {
 	local gzips=("$PWD/gzip")
 	local gunzips=("$PWD/gunzip")
 	if [ "${1:-}" != "--quick" ]; then
-		gzips+=(/bin/gzip)
-		gunzips+=(/bin/gunzip)
+		if is_compatible_system_gzip /bin/gzip; then
+			gzips+=(/bin/gzip)
+			gunzips+=(/bin/gunzip)
+		elif is_compatible_system_gzip /usr/bin/gzip; then
+			gzips+=(/usr/bin/gzip)
+			gunzips+=(/usr/bin/gunzip)
+		else
+			log "Unsupported system gzip; skipping comparison with system gzip"
+		fi
 	fi
 	local gzip gunzip
 
@@ -196,6 +234,8 @@ do_run_tests() {
 	if [ "${1:-}" != "--quick" ]; then
 		if $SKIP_FREESTANDING; then
 			log "Skipping freestanding build tests due to SKIP_FREESTANDING=1"
+		elif [ "$UNAME" = Darwin ]; then
+			log "Skipping freestanding build tests due to unsupported OS"
 		else
 			build_and_run_tests FREESTANDING=1
 			verify_freestanding_build
@@ -211,13 +251,23 @@ check_symbol_prefixes() {
 		fail "Some global symbols aren't prefixed with \"libdeflate_\""
 	fi
 	log "Checking that all exported symbols are prefixed with \"libdeflate\""
-	$MAKE libdeflate.so > /dev/null
-	if nm libdeflate.so | grep ' T ' \
-			| grep -E -v " (libdeflate_|_init\>|_fini\>)"; then
+	$MAKE $SHLIB > /dev/null
+	if nm $SHLIB | grep ' T ' \
+			| grep -E -v " _?(libdeflate_|_init\>|_fini\>)"; then
 		fail "Some exported symbols aren't prefixed with \"libdeflate_\""
 	fi
 }
 
+is_dynamically_linked() {
+	local prog=$1
+
+	if [ "$UNAME" = Darwin ]; then
+		otool -L "$prog" | grep -q libdeflate
+	else
+		ldd "$prog" | grep -q libdeflate
+	fi
+}
+
 test_use_shared_lib() {
 	if $SKIP_SHARED_LIB; then
 		log "Skipping USE_SHARED_LIB=1 tests due to SKIP_SHARED_LIB=1"
@@ -225,16 +275,13 @@ test_use_shared_lib() {
 	fi
 	log "Testing USE_SHARED_LIB=1"
 	$MAKE gzip > /dev/null
-	if ldd gzip | grep -q 'libdeflate.so'; then
+	if is_dynamically_linked gzip; then
 		fail "Binary should be statically linked by default"
 	fi
 	$MAKE USE_SHARED_LIB=1 all check > /dev/null
-	ldd gzip > "$TMPDIR/ldd.out"
-	if ! grep -q 'libdeflate.so' "$TMPDIR/ldd.out"; then
-		cat 1>&2 "$TMPDIR/ldd.out"
+	if ! is_dynamically_linked gzip; then
 		fail "Binary isn't dynamically linked"
 	fi
-	rm "$TMPDIR/ldd.out"
 }
 
 install_uninstall_tests() {



View it on GitLab: https://salsa.debian.org/med-team/libdeflate/-/commit/35d898dae9db9e2805991bb075df5646141b8615

-- 
View it on GitLab: https://salsa.debian.org/med-team/libdeflate/-/commit/35d898dae9db9e2805991bb075df5646141b8615
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20220809/55d115db/attachment-0001.htm>


More information about the debian-med-commit mailing list