Change ctest to test all the files in test/data.
Improved minigzip test configurations in ctest.
Added corpora repository to test/data to test for each run.
Allow for CMake to run tests in parallel.
Seperate minigzip and switchlevels set of tests into test-compress.cmake.
Create run-and-compare.cmake for tests that need to run a command and compare output.
Dan Kegel [Thu, 2 Jul 2020 17:21:50 +0000 (10:21 -0700)]
CMakeLists.txt, configure: match source order; .so's now identical on more platforms.
Also:
- use same name for .so on CMake and configure in --zlib-compat case
- configure: merge i686 and x86_64 sections, since they were essentially identical
- pkgcheck.sh: verify resulting shared libraries are bit-for-bit identical
- pkgcheck.sh: use diffoscope if present to show differences in shared libraries
Don't install diffoscope in ci, since that slows down successful
runs; we can add it later if failures become common.
Dan Kegel [Sun, 21 Jun 2020 00:26:00 +0000 (17:26 -0700)]
configure: don't link shared libraries explicitly with -lc
The -lc was introduced by d6231142d2b883a8c3b253fa34992b5cdb4ac2fe :
which said in part
"Changes in 1.2.3.2 (3 September 2006)
...
- Rig configure --shared to build both shared and static [Teredesai, Truta]"
It's not clear why it was needed. On powerpc, linking -lc explicitly
causes __moddi3 and __stack_chk_fail_local to swap location in the
binary.
If we want configure and cmake to generate identical shared libraries,
either we need to link -lc explicitly in both configure and cmake,
or in neither. Occam's Razor suggests omitting it from configure
rather than adding it to cmake.
Dan Kegel [Fri, 19 Jun 2020 15:50:13 +0000 (08:50 -0700)]
Make static libraries produced by cmake and configure identical.
Also make compat mode .pc files identical.
- cmake: don't do runtime feature checks when doing native builds.
- test/pkgcheck.sh: also compare .a, check compat mode, and handle mac better
- CMakeLists.txt: get Version right in compat mode .pc file
- .github/workflows/pkgcheck.sh: test on more systems, including mac
Default to optimization level 2 in cmake for release mode. Can be overwritten by setting the optimization level with CMAKE_C_FLAGS. MSVC does not have optimization level 3.
Since the introduction of test/adler32_test.c there has been a new
warning about too long strings:
/home/runner/work/zlib-ng/zlib-ng/test/adler32_test.c:178:5: warning: string
length ‘5552’ is greater than the length ‘4095’ ISO C99 compilers are required
to support [-Woverlength-strings]
"byRKqAu3J", 5552, 0x8b81718f},
^~~~~~~~~~~
/home/runner/work/zlib-ng/zlib-ng/test/adler32_test.c:321:5: warning: string
length ‘5552’ is greater than the length ‘4095’ ISO C99 compilers are required
to support [-Woverlength-strings]
"byRKqAu3J", 5552, 0x7dc51be2},
^~~~~~~~~~~
Declaring the long string as a static byte array fixes the issue.
Fixed ubsan error in deflatePrime when bits is 32.
deflate.c:602:15: runtime error: shift exponent 32 is too large for 32-bit type 'int32_t' (aka 'int')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /src/zlib-ng/deflate.c:602:15
Apply float abi flag to all files in cmake (same as configure).
Don't override -mfloat-abi if set via -DCMAKE_C_FLAGS in cmake.
Only set -mfloat-abi=softfp if compiler ends in eabi in cmake. (same as configure).
Fixed integer casting and signed comparison warning in test_gzio.
example.c(199,57): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
example.c:207:32: warning: comparison between signed and unsigned integer expressions
Fixed wrong size being used in calloc in test_deflate_set_header.
CID 293478 (#1 of 1): Wrong size argument (SIZEOF_MISMATCH)
suspicious_sizeof: Passing argument 1UL to function calloc that returns a pointer of type zng_gz_header * is suspicious because a multiple of sizeof (zng_gz_header) /*80*/ is expected.
Fixed avail_out == 0 conditional not returning need_more in deflate_quick.
Fixed ending block when returning need_more caused problems with inflate.
So instead of ending the block each time the function returns to finish the last block, we check upon start to see if it is the last block and if the last block has been started, and if not it will close the previous block and start the last block.
Clean up header includes for Win32 and ARM.
Fixed MSVC compiler warning in storechunk for ARM Neon.
Fixed arm_neon.h include for memchunk for ARM Neon.
Matheus Castanho [Mon, 22 Jun 2020 14:02:10 +0000 (11:02 -0300)]
Add POWER8_VSX_SLIDEHASH macro
The slide_hash optimization for POWER currently depends on POWER8 macro
to be enabled. Switch this to use POWER8_VSX_SLIDEHASH instead to better
match the naming scheme used by other archs.
cmake: Use consistent arch names for POWER targets
The arch detection code used by cmake build exports ppc arch names in an
abbreviated way, e.g. ppc64le instead of powerpc64le. Some parts of
CMakeLists.txt are using the longer form instead, which will not
properly match the desired subarch as expected. Switch to using the
longer form everywhere for consistency with 'configure' script and with
arch names obtained when running under QEMU.
Rogerio Alves [Mon, 9 Dec 2019 17:40:53 +0000 (14:40 -0300)]
Adler32 vector optimization for Power.
This commit implements a Power (POWER8+) vector optimization for Adler32
checksum using VSX (vector) instructions. The VSX adler32 checksum is up
to 10x fast than the adler32 baseline code.
Don [Tue, 9 Jun 2020 16:19:06 +0000 (09:19 -0700)]
Determine whether platform supports dll declspec
Clang contains __has_declspec_attribute for MSVC compatibility. This can be
used to determine whether __declspec is available. Use this to determine if
dllimport/dllexport should be used when exporting the zlib API.
Fixed deflate_quick to not emit a block when there is no available input. Pigz requires no blocks to be emitted in certain instances when calling deflate with Z_BLOCK.
Fixed end block not being emitted between calls to deflate_quick causing invalid stored block lengths in certain instances.
Don [Tue, 9 Jun 2020 16:57:05 +0000 (09:57 -0700)]
Remove Borland C++ compiler references
There are a few guards checking for Borland C++ 5.0 or greater which was released
in 1996. While there is still a descendent of this compiler in Embarcadero C++ Builder
its value for __BORLANDC__ is greater than 0x500 so it is safe to remove these guards.
Fixed variable set but not used static analysis warning in example.
example.c:84:14: warning: variable ‘read’ set but not used [-Wunused-but-set-variable]
int err, read;
example.c:198:5: warning: Value stored to 'read' is never read [deadcode.DeadStores]
read = PREFIX(gzfread)(uncompr, uncomprLen, 1, file);