From d9276df2832905124c7d2aa20de39d6f61f71ec11092387ad8e301a3de72b6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Thu, 27 Aug 2020 06:56:05 +0000 Subject: [PATCH 1/2] - Set -DDFLTCC_LEVEL_MASK=0x7e on s390/s390x jsc#13776 OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/zlib?expand=0&rev=66 --- zlib.changes | 5 +++++ zlib.spec | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/zlib.changes b/zlib.changes index d30b5ed..40a5952 100644 --- a/zlib.changes +++ b/zlib.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Aug 27 06:55:29 UTC 2020 - Tomáš Chvátal + +- Set -DDFLTCC_LEVEL_MASK=0x7e on s390/s390x jsc#13776 + ------------------------------------------------------------------- Thu Aug 6 08:36:48 UTC 2020 - Lidong Zhong diff --git a/zlib.spec b/zlib.spec index 4715d05..e059253 100644 --- a/zlib.spec +++ b/zlib.spec @@ -131,7 +131,11 @@ cp %{SOURCE4} . %build %global _lto_cflags %{_lto_cflags} -ffat-lto-objects export LDFLAGS="-Wl,-z,relro,-z,now" -export CFLAGS="%{optflags}" +%ifarch s390x s390 + export CFLAGS="%{optflags} -DDFLTCC_LEVEL_MASK=0x7e" +%else + export CFLAGS="%{optflags}" +%endif # For sure not autotools build CC="cc" ./configure \ --shared \ From 41ca660d5c95863b397d4da87cae3f13110706a452a03f232eb97a0bf1b88392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Fri, 28 Aug 2020 08:08:43 +0000 Subject: [PATCH 2/2] - Add patch to fix compression level switching bsc#1175811 bsc#1175830 bsc#1175831 * zlib-compression-switching.patch OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/zlib?expand=0&rev=67 --- zlib-compression-switching.patch | 184 +++++++++++++++++++++++++++++++ zlib.changes | 7 ++ zlib.spec | 2 + 3 files changed, 193 insertions(+) create mode 100644 zlib-compression-switching.patch diff --git a/zlib-compression-switching.patch b/zlib-compression-switching.patch new file mode 100644 index 0000000..302ef22 --- /dev/null +++ b/zlib-compression-switching.patch @@ -0,0 +1,184 @@ +Index: zlib-1.2.11/configure +=================================================================== +--- zlib-1.2.11.orig/configure ++++ zlib-1.2.11/configure +@@ -923,7 +923,7 @@ cat > $test.c << EOF + #include + int main() { return 0; } + EOF +-if try ${CC} ${CFLAGS} $test.c; then ++if try $CC -c $CFLAGS $test.c; then + echo "Checking for sys/sdt.h ... Yes." | tee -a configure.log + CFLAGS="$CFLAGS -DHAVE_SYS_SDT_H" + SFLAGS="$SFLAGS -DHAVE_SYS_SDT_H" +Index: zlib-1.2.11/contrib/s390/dfltcc.c +=================================================================== +--- zlib-1.2.11.orig/contrib/s390/dfltcc.c ++++ zlib-1.2.11/contrib/s390/dfltcc.c +@@ -350,8 +350,12 @@ int ZLIB_INTERNAL dfltcc_deflate(strm, f + int soft_bcc; + int no_flush; + +- if (!dfltcc_can_deflate(strm)) ++ if (!dfltcc_can_deflate(strm)) { ++ /* Clear history. */ ++ if (flush == Z_FULL_FLUSH) ++ param->hl = 0; + return 0; ++ } + + again: + masked_avail_in = 0; +@@ -376,7 +380,8 @@ again: + /* Clear history. */ + if (flush == Z_FULL_FLUSH) + param->hl = 0; +- *result = need_more; ++ /* Trigger block post-processing if necessary. */ ++ *result = no_flush ? need_more : block_done; + return 1; + } + +@@ -403,13 +408,18 @@ again: + param->bcf = 0; + dfltcc_state->block_threshold = + strm->total_in + dfltcc_state->block_size; +- if (strm->avail_out == 0) { +- *result = need_more; +- return 1; +- } + } + } + ++ /* No space for compressed data. If we proceed, dfltcc_cmpr() will return ++ * DFLTCC_CC_OP1_TOO_SHORT without buffering header bits, but we will still ++ * set BCF=1, which is wrong. Avoid complications and return early. ++ */ ++ if (strm->avail_out == 0) { ++ *result = need_more; ++ return 1; ++ } ++ + /* The caller gave us too much data. Pass only one block worth of + * uncompressed data to DFLTCC and mask the rest, so that on the next + * iteration we start a new block. +@@ -679,10 +689,15 @@ local inline int is_dfltcc_enabled(void) + * compiling with -m31, gcc defaults to ESA mode, however, since the kernel + * is 64-bit, it's always z/Architecture mode at runtime. + */ +- __asm__ volatile(".machinemode push\n" ++ __asm__ volatile( ++#ifndef __clang__ ++ ".machinemode push\n" + ".machinemode zarch\n" ++#endif + "stfle %[facilities]\n" ++#ifndef __clang__ + ".machinemode pop\n" ++#endif + : [facilities] "=Q" (facilities) + , [r0] "+r" (r0) + : +@@ -835,6 +850,28 @@ int ZLIB_INTERNAL dfltcc_deflate_params( + return Z_OK; + } + ++int ZLIB_INTERNAL dfltcc_deflate_done(strm, flush) ++ z_streamp strm; ++ int flush; ++{ ++ deflate_state FAR *state = (deflate_state FAR *)strm->state; ++ struct dfltcc_state FAR *dfltcc_state = GET_DFLTCC_STATE(state); ++ struct dfltcc_param_v0 FAR *param = &dfltcc_state->param; ++ ++ /* When deflate(Z_FULL_FLUSH) is called with small avail_out, it might ++ * close the block without resetting the compression state. Detect this ++ * situation and return that deflation is not done. ++ */ ++ if (flush == Z_FULL_FLUSH && strm->avail_out == 0) ++ return 0; ++ ++ /* Return that deflation is not done if DFLTCC is used and either it ++ * buffered some data (Continuation Flag is set), or has not written EOBS ++ * yet (Block-Continuation Flag is set). ++ */ ++ return !dfltcc_can_deflate(strm) || (!param->cf && !param->bcf); ++} ++ + /* + Preloading history. + */ +@@ -888,6 +925,7 @@ int ZLIB_INTERNAL dfltcc_deflate_set_dic + + append_history(param, state->window, dictionary, dict_length); + state->strstart = 1; /* Add FDICT to zlib header */ ++ state->block_start = state->strstart; /* Make deflate_stored happy */ + return Z_OK; + } + +Index: zlib-1.2.11/contrib/s390/dfltcc_deflate.h +=================================================================== +--- zlib-1.2.11.orig/contrib/s390/dfltcc_deflate.h ++++ zlib-1.2.11/contrib/s390/dfltcc_deflate.h +@@ -11,6 +11,7 @@ int ZLIB_INTERNAL dfltcc_deflate_params + int level, + int strategy, + int *flush)); ++int ZLIB_INTERNAL dfltcc_deflate_done OF((z_streamp strm, int flush)); + int ZLIB_INTERNAL dfltcc_deflate_set_dictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dict_length)); +@@ -41,6 +42,7 @@ int ZLIB_INTERNAL dfltcc_deflate_get_dic + if (err == Z_STREAM_ERROR) \ + return err; \ + } while (0) ++#define DEFLATE_DONE dfltcc_deflate_done + #define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, source_len) \ + do { \ + if (dfltcc_can_deflate((strm))) \ +Index: zlib-1.2.11/deflate.c +=================================================================== +--- zlib-1.2.11.orig/deflate.c ++++ zlib-1.2.11/deflate.c +@@ -75,6 +75,7 @@ const char deflate_copyright[] = + #define DEFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0) + #define DEFLATE_RESET_KEEP_HOOK(strm) do {} while (0) + #define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) do {} while (0) ++#define DEFLATE_DONE(strm, flush) 1 + #define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, sourceLen) do {} while (0) + #define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) 0 + #define DEFLATE_HOOK(strm, flush, bstate) 0 +@@ -600,14 +601,15 @@ int ZEXPORT deflateParams(strm, level, s + DEFLATE_PARAMS_HOOK(strm, level, strategy, &hook_flush); + func = configuration_table[s->level].func; + +- if ((strategy != s->strategy || func != configuration_table[level].func || +- hook_flush != Z_NO_FLUSH) && s->last_flush != -2) { ++ if (((strategy != s->strategy || func != configuration_table[level].func) && ++ s->last_flush != -2) || hook_flush != Z_NO_FLUSH) { + /* Flush the last buffer: */ +- int err = deflate(strm, RANK(hook_flush) > RANK(Z_BLOCK) ? +- hook_flush : Z_BLOCK); ++ int flush = RANK(hook_flush) > RANK(Z_BLOCK) ? hook_flush : Z_BLOCK; ++ int err = deflate(strm, flush); + if (err == Z_STREAM_ERROR) + return err; +- if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) ++ if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead || ++ !DEFLATE_DONE(strm, flush)) + return Z_BUF_ERROR; + } + if (s->level != level) { +Index: zlib-1.2.11/test/infcover.c +=================================================================== +--- zlib-1.2.11.orig/test/infcover.c ++++ zlib-1.2.11/test/infcover.c +@@ -373,7 +373,7 @@ local void cover_support(void) + mem_setup(&strm); + strm.avail_in = 0; + strm.next_in = Z_NULL; +- ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); ++ ret = inflateInit_(&strm, &ZLIB_VERSION[1], (int)sizeof(z_stream)); + assert(ret == Z_VERSION_ERROR); + mem_done(&strm, "wrong version"); + diff --git a/zlib.changes b/zlib.changes index 40a5952..3a63426 100644 --- a/zlib.changes +++ b/zlib.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Aug 28 07:58:23 UTC 2020 - Tomáš Chvátal + +- Add patch to fix compression level switching + bsc#1175811 bsc#1175830 bsc#1175831 + * zlib-compression-switching.patch + ------------------------------------------------------------------- Thu Aug 27 06:55:29 UTC 2020 - Tomáš Chvátal diff --git a/zlib.spec b/zlib.spec index e059253..32e6a29 100644 --- a/zlib.spec +++ b/zlib.spec @@ -43,6 +43,7 @@ Patch4: 410.patch Patch5: zlib-no-version-check.patch Patch6: bsc1174736-DFLTCC_LEVEL_MASK-set-to-0x1ff.patch Patch7: bsc1174551-fxi-imcomplete-raw-streams.patch +Patch8: zlib-compression-switching.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool @@ -126,6 +127,7 @@ developing applications which use minizip. %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 cp %{SOURCE4} . %build