rpm-software-management / librepo

A library providing C and Python (libcURL like) API for downloading packages and linux repository metadata in rpm-md format
http://rpm-software-management.github.io/librepo/
GNU Lesser General Public License v2.1
74 stars 91 forks source link

1.14.3: build fails #255

Closed kloczek closed 2 years ago

kloczek commented 2 years ago

Looks like in cmake files it is missinng libz detection

+ /usr/bin/cmake -B x86_64-redhat-linux-gnu -D BUILD_SHARED_LIBS=ON -D CMAKE_AR=/usr/bin/gcc-ar -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_C_FLAGS_RELEASE=-DNDEBUG -D CMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -D CMAKE_Fortran_FLAGS_RELEASE=-DNDEBUG -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_NM=/usr/bin/gcc-nm -D CMAKE_RANLIB=/usr/bin/gcc-ranlib -D CMAKE_VERBOSE_MAKEFILE=ON -D INCLUDE_INSTALL_DIR=/usr/include -D LIB_INSTALL_DIR=/usr/lib64 -D LIB_SUFFIX=64 -D SHARE_INSTALL_PREFIX=/usr/share -D SYSCONF_INSTALL_DIR=/etc -S . -D PYTHON_DESIRED=/usr/bin/python3 -D WITH_ZCHUNK=ON -D ENABLE_PYTHON_TESTS=OFF
-- The C compiler identification is GNU 12.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Deprecation Warning at CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0")
-- Checking for module 'glib-2.0'
--   Found glib-2.0, version 2.72.0
-- Checking for one of the modules 'libcrypto;openssl'
-- Checking for module 'libxml-2.0'
--   Found libxml-2.0, version 2.9.14
-- Found CURL: /usr/lib64/libcurl.so (found suitable version "7.83.0", minimum required is "7.52.0")
-- Found gpgme-config at /usr/bin/gpgme-config
-- Found gpgme v1.17.1-unknown, checking for flavours...
--  Found flavour 'vanilla', checking whether it's usable...yes
--  Found flavour 'pthread', checking whether it's usable...yes
-- Usable gpgme flavours found:  vanilla pthread
-- Checking for module 'zck>=0.9.11'
--   Found zck, version 1.2.2
-- Found PythonInterp: /usr/bin/python3 (found suitable exact version "3.8.13")
-- Found PythonLibs: /usr/lib64/libpython3.8.so (found version "3.8.13")
Building python bindings
-- Python3 install dir is /usr/lib64/python3.8/site-packages
-- Checking for module 'check'
--   Found check, version 0.15.2
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.3") found components: doxygen dot
-- Configuring done
-- Generating done

[..]

+ /usr/bin/cmake --build x86_64-redhat-linux-gnu -j48 --verbose

[..]

[ 38%] Building C object librepo/CMakeFiles/librepo.dir/yum.c.o
cd /home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/x86_64-redhat-linux-gnu/librepo && /usr/bin/gcc -DG_LOG_DOMAIN=\"librepo\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -Dlibrepo_EXPORTS -I/home/tkloczko/rpmbuild/BUILD/librepo-1.14.3 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -std=c99 -Wall -DWITH_ZCHUNK -DNDEBUG -fPIC -MD -MT librepo/CMakeFiles/librepo.dir/yum.c.o -MF CMakeFiles/librepo.dir/yum.c.o.d -o CMakeFiles/librepo.dir/yum.c.o -c /home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/yum.c
/home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/metadata_downloader.c:28:10: fatal error: zconf.h: No such file or directory
   28 | #include <zconf.h>
      |          ^~~~~~~~~
compilation terminated.
gmake[2]: *** [librepo/CMakeFiles/librepo.dir/build.make:191: librepo/CMakeFiles/librepo.dir/metadata_downloader.c.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-redhat-linux/12/include/limits.h:203,
                 from /usr/lib/gcc/x86_64-redhat-linux/12/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/12/include/limits.h:34,
                 from /usr/lib64/glib-2.0/include/glibconfig.h:11,
                 from /usr/include/glib-2.0/glib/gtypes.h:32,
                 from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from /home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/handle.c:24:
/usr/include/features.h:194:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  194 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~
/home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/yum.c: In function 'prepare_repo_download_targets':
/home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/yum.c:742:11: warning: variable 'destdir' set but not used [-Wunused-but-set-variable]
  742 |     char *destdir;  /* Destination dir */
      |           ^~~~~~~
/home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/downloader.c: In function 'prepare_next_transfer':
/home/tkloczko/rpmbuild/BUILD/librepo-1.14.3/librepo/downloader.c:1662:15: warning: unused variable 'cm_rc' [-Wunused-variable]
 1662 |     CURLMcode cm_rc = curl_multi_add_handle(dd->multi_handle, h);
      |               ^~~~~
lukash commented 2 years ago

Looks like it was just that one include and the library is otherwise not used directly. But it's an indirect dependency (through at least glib2), so I'm not sure how you're building librepo without it...

kloczek commented 2 years ago

Tested and all is correct now with that commit and there is no need of the zlib in build env. I've checked as well latest glib and looks like it has no direct or indirect zlib dependencies

[tkloczko@devel-g2v include]$ grep -r zlib
glib-2.0/gio/gio.h:#include <gio/gzlibcompressor.h>
glib-2.0/gio/gio.h:#include <gio/gzlibdecompressor.h>
glib-2.0/gio/gioenums.h: * @G_ZLIB_COMPRESSOR_FORMAT_ZLIB: deflate compression with zlib header
glib-2.0/gio/gioenumtypes.h:GLIB_AVAILABLE_IN_ALL GType g_zlib_compressor_format_get_type (void) G_GNUC_CONST;
glib-2.0/gio/gioenumtypes.h:#define G_TYPE_ZLIB_COMPRESSOR_FORMAT (g_zlib_compressor_format_get_type ())
glib-2.0/gio/gzlibcompressor.h:#define G_TYPE_ZLIB_COMPRESSOR         (g_zlib_compressor_get_type ())
glib-2.0/gio/gzlibcompressor.h:GType            g_zlib_compressor_get_type (void) G_GNUC_CONST;
glib-2.0/gio/gzlibcompressor.h:GZlibCompressor *g_zlib_compressor_new (GZlibCompressorFormat format,
glib-2.0/gio/gzlibcompressor.h:GFileInfo       *g_zlib_compressor_get_file_info (GZlibCompressor *compressor);
glib-2.0/gio/gzlibcompressor.h:void             g_zlib_compressor_set_file_info (GZlibCompressor *compressor,
glib-2.0/gio/gzlibdecompressor.h:#define G_TYPE_ZLIB_DECOMPRESSOR         (g_zlib_decompressor_get_type ())
glib-2.0/gio/gzlibdecompressor.h:GType              g_zlib_decompressor_get_type (void) G_GNUC_CONST;
glib-2.0/gio/gzlibdecompressor.h:GZlibDecompressor *g_zlib_decompressor_new (GZlibCompressorFormat format);
glib-2.0/gio/gzlibdecompressor.h:GFileInfo         *g_zlib_decompressor_get_file_info (GZlibDecompressor *decompressor);
[tkloczko@devel-g2v Packages]$ rpm -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" glib2-devel-2.72.1-2.fc35.x86_64.rpm
/usr/bin/python3
/usr/bin/sh
glib2(x86-64) = 2.72.1-2.fc35
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.28)(64bit)
libc.so.6(GLIBC_2.34)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libelf.so.1()(64bit)
libelf.so.1(ELFUTILS_1.0)(64bit)
libelf.so.1(ELFUTILS_1.5)(64bit)
libgio-2.0.so.0()(64bit)
libglib-2.0.so.0()(64bit)
libgmodule-2.0.so.0()(64bit)
libgobject-2.0.so.0()(64bit)
libgthread-2.0.so.0()(64bit)
pkgconfig(gio-2.0)
pkgconfig(glib-2.0)
pkgconfig(gmodule-no-export-2.0)
pkgconfig(gobject-2.0)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1
rtld(GNU_HASH)
lukash commented 2 years ago

Well the rpm has a dependency via a pkgconfig provide on f36:

$ dnf rq --requires glib2-devel-0:2.72.1-1.fc36.x86_64 | grep zlib
Last metadata expiration check: 0:31:06 ago on Thu May 12 12:21:24 2022.
pkgconfig(zlib)

But I didn't dig further... Not sure why your package doesn't list it.

kloczek commented 2 years ago

But I didn't dig further... Not sure why your package doesn't list it.

It is lot listing because glib2 header fils are not using zlib.

[tkloczko@devel-g2v SPECS]$ rpm -ql glib2-devel | grep include.*.h$ | xargs grep zlib
/usr/include/glib-2.0/gio/gio.h:#include <gio/gzlibcompressor.h>
/usr/include/glib-2.0/gio/gio.h:#include <gio/gzlibdecompressor.h>
/usr/include/glib-2.0/gio/gioenums.h: * @G_ZLIB_COMPRESSOR_FORMAT_ZLIB: deflate compression with zlib header
/usr/include/glib-2.0/gio/gioenumtypes.h:GLIB_AVAILABLE_IN_ALL GType g_zlib_compressor_format_get_type (void) G_GNUC_CONST;
/usr/include/glib-2.0/gio/gioenumtypes.h:#define G_TYPE_ZLIB_COMPRESSOR_FORMAT (g_zlib_compressor_format_get_type ())
/usr/include/glib-2.0/gio/gzlibcompressor.h:#define G_TYPE_ZLIB_COMPRESSOR         (g_zlib_compressor_get_type ())
/usr/include/glib-2.0/gio/gzlibcompressor.h:GType            g_zlib_compressor_get_type (void) G_GNUC_CONST;
/usr/include/glib-2.0/gio/gzlibcompressor.h:GZlibCompressor *g_zlib_compressor_new (GZlibCompressorFormat format,
/usr/include/glib-2.0/gio/gzlibcompressor.h:GFileInfo       *g_zlib_compressor_get_file_info (GZlibCompressor *compressor);
/usr/include/glib-2.0/gio/gzlibcompressor.h:void             g_zlib_compressor_set_file_info (GZlibCompressor *compressor,
/usr/include/glib-2.0/gio/gzlibdecompressor.h:#define G_TYPE_ZLIB_DECOMPRESSOR         (g_zlib_decompressor_get_type ())
/usr/include/glib-2.0/gio/gzlibdecompressor.h:GType              g_zlib_decompressor_get_type (void) G_GNUC_CONST;
/usr/include/glib-2.0/gio/gzlibdecompressor.h:GZlibDecompressor *g_zlib_decompressor_new (GZlibCompressorFormat format);
/usr/include/glib-2.0/gio/gzlibdecompressor.h:GFileInfo         *g_zlib_decompressor_get_file_info (GZlibDecompressor *decompressor);

As you see none of the glib header files are using <zlib.h>.

That is kind of bug in all Linux distributions rpm dependencies generators are treating Requires.pivate as actual dependencies. That is wrong. pkgconfig Requires.private and Libs.pvivate are only for static linking. From https://people.freedesktop.org/~dbn/pkg-config-guide.html

Since pkg-config always exposes the link flags of the Requires libraries, these modules will become direct dependencies of the program. On the other hand, libraries from Requires.private will only be included when static linking. For this reason, it is usually only appropriate to add modules from the same package in Requires.

As I'm removing in all .pc files Requires.private and Libs.pvivate because I'm not providing any static libtraries I'm instantly exposing those overdependencies. Meson dependency(), cmake pind_package() and aclocal PKG_CHECK_MODULE() are querying pkg-config --libs <foo>.

In this case issue is that that if project A is using API of the library described in libX.pc build framework should explicit check in meson/cmake/autoconf availability odf the libX instead relaing on indirect dependencies of other necessary components.

There is no to many packages affercted by still using indirect pkgconfig dependencies and about the same number of packages hich are affected by fact that on building usiually rpm package some Requires.private will be present in buld env because default rpm dependency generator has this overdependency issue.

https://github.com/rpm-software-management/rpm/blob/e36ac91ee20d7c9c32ad7d17f3e4b054f9159c21/scripts/pkgconfigdeps.sh#L42-L59

To fix that instead using --print-requires --print-requires-private should be used only --print-requires. Alternative is to consquently remove everywhere Requires.private if static libraries are not provided.

Nevertheless in this case librepo is not using zlib so it was possible to fix that by remove bogus #include line 😋