Control: tags -1 + patch

On Thu, 12 Sep 2024 at 10:20:59 -0300, Carlos Henrique Lima Melara wrote:
> > E   ImportError: /lib/i386-linux-gnu/libcurl-gnutls.so.4: undefined symbol: 
> > gnutls_free
> 
> We are aware of the issue and will try to solve by
> the end of the week - or as soon as we have time to debug it.

I think I can see why this happens. The OpenSSL code path in
lib/Makefile.am changed some of the lists of parameters in 8.10.0 (in
particular the variable containing dependency libraries was renamed),
and the GNUTLS code path that is patched in by the Debian packaging
wasn't updated to match.

The attached patch 0001 makes it easy to see this failure mode, by refusing
to link the library with incomplete dependencies. Please consider applying
this so that the same failure mode cannot happen again.

I believe the attached patch 0002 fixes the regression (it compiles
successfully, not otherwise tested).

Please also consider patch 0003 which ensures that the correct compilation
flags are used for libcurlu.la, the static library that is used by some
(all?) of the unit tests.

As a future improvement, it might be worthwhile to restructure the GNUTLS
patch so that it works more like this (pseudo-diff, hopefully you will
see what I mean):

--------
diff...
---...
+++...
 libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_la_CPPFLAGS_EXTRA)
 libcurl_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_la_LDFLAGS_EXTRA) 
$(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE)
 libcurl_la_CFLAGS = $(AM_CFLAGS) $(libcurl_la_CFLAGS_EXTRA)
+
+if GNUTLSBUILD
+libcurl_la_CPPFLAGS = $(libcurl_la_CPPFLAGS)
+libcurl_la_LDFLAGS = $(libcurl_la_LDFLAGS)
+libcurl_la_CFLAGS = $(libcurl_la_CFLAGS)
+endif
--------

but that would be a more intrusive change, so I haven't done that, for the
sake of providing a minimal proposed fix sooner.

    smcv
>From fe7322ff926f71f34ed766c754d590f08f391c20 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Thu, 12 Sep 2024 17:23:56 +0100
Subject: [PATCH 1/3] d/rules: Do not allow any undefined symbols when linking

Instead of allowing creation of a library with missing dependencies if
the build has gone wrong, make sure that the build will fail early.

Reproduces: #1081517
---
 debian/rules | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/rules b/debian/rules
index b982151d3f..6acc0e875e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -35,6 +35,7 @@ endif
 
 export DEB_CFLAGS_MAINT_APPEND = -D_DEB_HOST_ARCH=\"$(DEB_HOST_MULTIARCH)\" -DCURL_PATCHSTAMP=\"$(DEB_VERSION)\"
 export DEB_CXXFLAGS_MAINT_APPEND = -D_DEB_HOST_ARCH=\"$(DEB_HOST_MULTIARCH)\" -DCURL_PATCHSTAMP=\"$(DEB_VERSION)\"
+export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-undefined
 
 ifneq ($(filter pkg.curl.openssl-only,$(DEB_BUILD_PROFILES)),)
 	DEB_BUILD_PROFILES += pkg.curl.no-gnutls
-- 
2.45.2

>From d277e4e16ad7b06479e2bee5a314af86d6f6b314 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Thu, 12 Sep 2024 17:31:07 +0100
Subject: [PATCH 2/3] ZZZgnutls-build.patch: Resync libraries used for GNUTLS
 flavour

The libraries used to link the OpenSSL flavour moved from
LIBCURL_LIBS to LIBCURL_PC_LIBS_PRIVATE in 8.10.0 upstream.
Link the GNUTLS flavour to the same libraries.

Closes: #1081517
---
 debian/patches/ZZZgnutls-build.patch | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/debian/patches/ZZZgnutls-build.patch b/debian/patches/ZZZgnutls-build.patch
index aa0b11f679..85e2ccca12 100644
--- a/debian/patches/ZZZgnutls-build.patch
+++ b/debian/patches/ZZZgnutls-build.patch
@@ -4,7 +4,7 @@ Subject: Build with GnuTLS.
 
 Origin: vendor
 Forwarded: not-needed
-Last-Update: 2024-09-11
+Last-Update: 2024-09-12
 ---
  configure.ac                   | 10 ++++++++
  docs/examples/Makefile.am      |  2 +-
@@ -51,7 +51,7 @@ index 91f90cf..13874e1 100644
  # This might hold -Werror
  CFLAGS += @CURL_CFLAG_EXTRAS@
 diff --git a/lib/Makefile.am b/lib/Makefile.am
-index 851cee2..0191200 100644
+index 851cee2..f0fddca 100644
 --- a/lib/Makefile.am
 +++ b/lib/Makefile.am
 @@ -34,7 +34,11 @@ EXTRA_DIST = Makefile.mk config-win32.h config-win32ce.h config-plan9.h \
@@ -155,7 +155,7 @@ index 851cee2..0191200 100644
  
 +if GNUTLSBUILD
 +libcurl_gnutls_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_gnutls_la_CPPFLAGS_EXTRA)
-+libcurl_gnutls_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_gnutls_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_LIBS)
++libcurl_gnutls_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_gnutls_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE)
 +libcurl_gnutls_la_CFLAGS = $(AM_CFLAGS) $(libcurl_gnutls_la_CFLAGS_EXTRA)
 +libcurlu_gnutls_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
 +libcurlu_gnutls_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_LIBS)
-- 
2.45.2

>From 625dea43c80dc7f25223e6c9239ca1322d07ab2c Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Thu, 12 Sep 2024 17:34:59 +0100
Subject: [PATCH 3/3] ZZZgnutls-build.patch: De-conditionalize libcurlu.la
 parameters

The static library used to link unit tests is always libcurlu.la, never
libcurlu-gnutls.la, regardless of whether the shared library is going
to be libcurl.la (OpenSSL flavour) or libcurl-gnutls.la (GNUTLS flavour).
---
 debian/patches/ZZZgnutls-build.patch | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/debian/patches/ZZZgnutls-build.patch b/debian/patches/ZZZgnutls-build.patch
index 85e2ccca12..f403a83aea 100644
--- a/debian/patches/ZZZgnutls-build.patch
+++ b/debian/patches/ZZZgnutls-build.patch
@@ -8,13 +8,13 @@ Last-Update: 2024-09-12
 ---
  configure.ac                   | 10 ++++++++
  docs/examples/Makefile.am      |  2 +-
- lib/Makefile.am                | 56 ++++++++++++++++++++++++++++++++++++++++--
+ lib/Makefile.am                | 53 ++++++++++++++++++++++++++++++++++++++++--
  lib/libcurl.vers.in            |  2 +-
  src/Makefile.am                |  2 +-
  tests/http/clients/Makefile.am |  2 +-
  tests/http/clients/Makefile.in | 18 +++++++-------
- tests/libtest/Makefile.am      |  4 +--
- 8 files changed, 79 insertions(+), 17 deletions(-)
+ tests/libtest/Makefile.am      |  4 ++--
+ 8 files changed, 76 insertions(+), 17 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
 index 269d7bd..b87b7cf 100644
@@ -51,7 +51,7 @@ index 91f90cf..13874e1 100644
  # This might hold -Werror
  CFLAGS += @CURL_CFLAG_EXTRAS@
 diff --git a/lib/Makefile.am b/lib/Makefile.am
-index 851cee2..f0fddca 100644
+index 851cee2..2674a22 100644
 --- a/lib/Makefile.am
 +++ b/lib/Makefile.am
 @@ -34,7 +34,11 @@ EXTRA_DIST = Makefile.mk config-win32.h config-win32ce.h config-plan9.h \
@@ -66,13 +66,13 @@ index 851cee2..f0fddca 100644
  
  if BUILD_UNITTESTS
  noinst_LTLIBRARIES = libcurlu.la
-@@ -70,55 +74,103 @@ AM_CFLAGS =
+@@ -70,52 +74,97 @@ AM_CFLAGS =
  # Makefile.inc provides the CSOURCES and HHEADERS defines
  include Makefile.inc
  
 +if GNUTLSBUILD
 +libcurl_gnutls_la_SOURCES = $(CSOURCES) $(HHEADERS)
-+libcurlu_gnutls_la_SOURCES = $(CSOURCES) $(HHEADERS)
++libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS)
 +libcurl_gnutls_la_CPPFLAGS_EXTRA =
 +libcurl_gnutls_la_LDFLAGS_EXTRA =
 +libcurl_gnutls_la_CFLAGS_EXTRA =
@@ -157,21 +157,15 @@ index 851cee2..f0fddca 100644
 +libcurl_gnutls_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_gnutls_la_CPPFLAGS_EXTRA)
 +libcurl_gnutls_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_gnutls_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE)
 +libcurl_gnutls_la_CFLAGS = $(AM_CFLAGS) $(libcurl_gnutls_la_CFLAGS_EXTRA)
-+libcurlu_gnutls_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
-+libcurlu_gnutls_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_LIBS)
-+libcurlu_gnutls_la_CFLAGS = $(AM_CFLAGS)
 +else
  libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_la_CPPFLAGS_EXTRA)
  libcurl_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE)
  libcurl_la_CFLAGS = $(AM_CFLAGS) $(libcurl_la_CFLAGS_EXTRA)
 -
++endif
  libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
  libcurlu_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_PC_LIBS_PRIVATE)
  libcurlu_la_CFLAGS = $(AM_CFLAGS)
-+endif
- 
- CHECKSRC = $(CS_$(V))
- CS_0 = @echo "  RUN     " $@;
 diff --git a/lib/libcurl.vers.in b/lib/libcurl.vers.in
 index ae978a4..7fd4c07 100644
 --- a/lib/libcurl.vers.in
-- 
2.45.2

Reply via email to