All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/python3: really disable zlib
@ 2023-10-11 16:34 Romain Naour
  0 siblings, 0 replies; 3+ messages in thread
From: Romain Naour @ 2023-10-11 16:34 UTC (permalink / raw
  To: buildroot; +Cc: Romain Naour, James Hilliard, Thomas Petazzoni

The Bootlin toolchain 2023.08-1 provide (by mistake [1]) libz.so in its
sysroot and break several python test in the gitlab-ci [2] since the
python package detect zlib while the zlib package is not build. So
there is no zlib library installed to the target rootfs.

The issue [1] has been fixed in Buildroot [3] but the Bootlin toolchain
needs to be rebuild with the fix to remove libz.so from the sysroot.

With Bootlin toolchain 2023.08-1, zlib is detected by pkg-config and
enable zlib support in binascii python module (-DUSE_ZLIB_CRC32) even
if the zlib module is disabled.
If binascii python module is used at runtime, it fail to load zlib:

  Failed to run: python sample_python_pyyaml_enc.py
  output was:
    Traceback (most recent call last):
      File "/root/sample_python_pyyaml_enc.py", line 1, in <module>
        import yaml
      File "/usr/lib/python3.11/site-packages/yaml/__init__.py", line 8, in <module>
      File "/usr/lib/python3.11/site-packages/yaml/loader.py", line 8, in <module>
      File "/usr/lib/python3.11/site-packages/yaml/constructor.py", line 14, in <module>
      File "/usr/lib/python3.11/base64.py", line 11, in <module>
    ImportError: libz.so.1: cannot open shared object file: No such file or directory

This is also a reproducible build issue since python doesn't provide
the same features if zlib is buid before or after the python build.

Fix this issue by disabling zlib support along with the zlib python
module (--disable-zlib).

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/5201302864 (TestPythonPy3Pyyaml)
https://gitlab.com/buildroot.org/buildroot/-/jobs/5201302828 (TestPythonPy3Mako)
(and many other)

[1] 3341ceb1e58536cf43a4c000e4bb3cdbff3f6de5 (package/gdb: zlib is mandatory, not optional)
[2] https://gitlab.com/buildroot.org/buildroot/-/jobs/5201302864
[3] 8ce33fed49aea319da556eab388211a705afe7d0 (package/gdb: gdbserver does not need zlib)

Cc; Asaf Kahlon <asafka7@gmail.com>
Cc: James Hilliard <james.hilliard1@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
runtime tested:
  TestPythonPy3Flask.test_run (with zlib & zlib python module enabled)
  TestPythonPy3Pyyaml (without zlib)
---
 ...032-configure.ac-really-disable-zlib.patch | 96 +++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 package/python3/0032-configure.ac-really-disable-zlib.patch

diff --git a/package/python3/0032-configure.ac-really-disable-zlib.patch b/package/python3/0032-configure.ac-really-disable-zlib.patch
new file mode 100644
index 0000000000..6d9fb2c3f1
--- /dev/null
+++ b/package/python3/0032-configure.ac-really-disable-zlib.patch
@@ -0,0 +1,96 @@
+From 9b5a79f7b5bc5ccfa8f3909ee6d3a94b2efb617d Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@gmail.com>
+Date: Wed, 11 Oct 2023 15:33:54 +0200
+Subject: [PATCH] configure.ac: really disable zlib
+
+Commit "Add options to disable zlib, bzip2 and xz modules" allowed
+to disable the python zlib module but the configure script still
+check for zlib library using pkg-config even if --disable-zlib is
+provided.
+
+If zlib is detected by pkg-config it enable zlib support in binascii
+python module (-DUSE_ZLIB_CRC32) even if the zlib module is disabled.
+This is also a reproducible build issue since python doesn't provide
+the same features if zlib is buid before or after the python build.
+
+Fix this issue by disabling zlib support along with the zlib python
+module (--disable-zlib).
+
+Upstream: Not applicable
+(patching a BR patch 0025-Add-options-to-disable-zlib-bzip2-and-xz-modules.patch)
+
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
+---
+ configure.ac | 45 ++++++++++++++++++++++++---------------------
+ 1 file changed, 24 insertions(+), 21 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 3f5e7400c6..fa7cdfa0df 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -4288,7 +4288,8 @@ AC_ARG_ENABLE(zlib,
+ 	AS_HELP_STRING([--disable-zlib], [disable zlib]),
+ 	[ if test "$enableval" = "no"; then
+ 	     DISABLED_EXTENSIONS="${DISABLED_EXTENSIONS} zlib"
+-	  fi])
++	     enable_zlib=${enableval}
++	  fi], [enable_zlib=auto])
+ 
+ AC_ARG_ENABLE(xz,
+ 	AS_HELP_STRING([--disable-xz], [disable xz]),
+@@ -4899,30 +4900,32 @@ if test "$ac_cv_have_lchflags" = yes ; then
+   AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
+ fi
+ 
+-dnl Check for compression libraries
+-AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy])
++if test "x$enable_zlib" != xno; then
++  dnl Check for compression libraries
++  AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy])
+ 
+-dnl detect zlib from Emscripten emport
+-PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])
++  dnl detect zlib from Emscripten emport
++  PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])
+ 
+-PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
+-  have_zlib=yes
+-  dnl zlib 1.2.0 (2003) added inflateCopy
+-  AC_DEFINE([HAVE_ZLIB_COPY], [1])
+-], [
+-  WITH_SAVE_ENV([
+-    CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
+-    LDFLAGS="$LDFLAGS $ZLIB_LIBS"
+-    AC_CHECK_HEADERS([zlib.h], [
+-      PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no])
+-    ], [have_zlib=no])
+-    AS_VAR_IF([have_zlib], [yes], [
+-      ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
+-      ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
+-      PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
++  PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
++    have_zlib=yes
++    dnl zlib 1.2.0 (2003) added inflateCopy
++    AC_DEFINE([HAVE_ZLIB_COPY], [1])
++  ], [
++    WITH_SAVE_ENV([
++      CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS"
++      LDFLAGS="$LDFLAGS $ZLIB_LIBS"
++      AC_CHECK_HEADERS([zlib.h], [
++        PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no])
++      ], [have_zlib=no])
++      AS_VAR_IF([have_zlib], [yes], [
++        ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
++        ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
++        PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
++      ])
+     ])
+   ])
+-])
++fi
+ 
+ dnl binascii can use zlib for optimized crc32.
+ AS_VAR_IF([have_zlib], [yes], [
+-- 
+2.41.0
+
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] package/python3: really disable zlib
       [not found] <20231011163408.32325-1-romain.naour__9329.73186006478$1697042081$gmane$org@gmail.com>
@ 2023-10-11 17:23 ` Bernd Kuhls
  2023-10-12 11:52   ` Romain Naour
  0 siblings, 1 reply; 3+ messages in thread
From: Bernd Kuhls @ 2023-10-11 17:23 UTC (permalink / raw
  To: buildroot

Am Wed, 11 Oct 2023 18:34:08 +0200 schrieb Romain Naour:

> +Upstream: Not applicable +(patching a BR patch
> 0025-Add-options-to-disable-zlib-bzip2-and-xz-modules.patch)

Hi Romain,

did you test whether this patch also fixes the problem?
https://patchwork.ozlabs.org/project/buildroot/patch/
20230809211401.3587177-4-bernd@kuhls.net/

Regards, Bernd

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] package/python3: really disable zlib
  2023-10-11 17:23 ` Bernd Kuhls
@ 2023-10-12 11:52   ` Romain Naour
  0 siblings, 0 replies; 3+ messages in thread
From: Romain Naour @ 2023-10-12 11:52 UTC (permalink / raw
  To: Bernd Kuhls, buildroot

Hello Bernd,

Le 11/10/2023 à 19:23, Bernd Kuhls a écrit :
> Am Wed, 11 Oct 2023 18:34:08 +0200 schrieb Romain Naour:
> 
>> +Upstream: Not applicable +(patching a BR patch
>> 0025-Add-options-to-disable-zlib-bzip2-and-xz-modules.patch)
> 
> Hi Romain,
> 
> did you test whether this patch also fixes the problem?
> https://patchwork.ozlabs.org/project/buildroot/patch/
> 20230809211401.3587177-4-bernd@kuhls.net/

No but it's seems there is the same issue with python 3.12 [1].

Let's try to fix gitlab-ci issues related to python before switching to python
3.12 :)

[1] https://github.com/python/cpython/blob/3.12/configure.ac#L5045

Best regards,
Romain


> 
> Regards, Bernd
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-12 11:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-11 16:34 [Buildroot] [PATCH] package/python3: really disable zlib Romain Naour
     [not found] <20231011163408.32325-1-romain.naour__9329.73186006478$1697042081$gmane$org@gmail.com>
2023-10-11 17:23 ` Bernd Kuhls
2023-10-12 11:52   ` Romain Naour

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.