Skip to contentSkip to conversation

package/cups: fix static linking with GnuTLS

PATCH New Jörg Krause 3 participants 5 messages Feb 28, 2016 – Jul 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/cups: fix static linking with GnuTLS

cups forgets to link against the libs found by pkg-config if it is build with GnuTLS support.

Otherwise, static build fails with:
../cups/libcups.a(tls.o): In function `http_gnutls_create_credential':
cups-2.1.2/cups/tls-gnutls.c:762: undefined reference to `gnutls_x509_crt_init' [..]

Fixes:
http://autobuild.buildroot.net/results/205/20509b7d1edc73dc2a7622f2ae7dbf9f6665a918/
http://autobuild.buildroot.net/results/b86/b86d685caf8cf812f9505fca2de36fb8c18baee1/

Patch is sent upstream.

---
 .../cups/0004-Fix-static-linking-with-GnuTLS.patch | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 package/cups/0004-Fix-static-linking-with-GnuTLS.patch
package/cups/0004-Fix-static-linking-with-GnuTLS.patch new file +39 -0
new file mode 100644
index 0000000..67df4dc
@@ -0,0 +1,39 @@
+From ceaed5f1efe917c70e5ae9161695ba1c559b912d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rg=20Krause?= <[email protected]>
+Date: Sun, 28 Feb 2016 16:35:56 +0100
+Subject: [PATCH] Fix static linking with GnuTLS
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cups forgets to link against the libs found by pkg-config if it is build with
+GnuTLS support.
+
+Otherwise, static build fails with:
+../cups/libcups.a(tls.o): In function `http_gnutls_create_credential':
+cups-2.1.2/cups/tls-gnutls.c:762: undefined reference to `gnutls_x509_crt_init'
+[..]
+
+Status upstream: Pending
+
+Signed-off-by: J?rg Krause <[email protected]>
+---
+ Makedefs.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makedefs.in b/Makedefs.in
+index 5d261c3..1d00c73 100644
+--- a/Makedefs.in
++++ b/Makedefs.in
+@@ -143,7 +143,7 @@ IPPFIND_MAN	=	@IPPFIND_MAN@
+ LDFLAGS		=	-L../cgi-bin -L../cups -L../filter -L../ppdc \
+ 			-L../scheduler @LDARCHFLAGS@ \
+ 			@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
+-LINKCUPS	=	@LINKCUPS@ $(LIBGSSAPI) $(DNSSDLIBS) $(LIBZ)
++LINKCUPS	=	@LINKCUPS@ $(SSLLIBS) $(LIBGSSAPI) $(DNSSDLIBS) $(LIBZ)
+ LINKCUPSIMAGE	=	@LINKCUPSIMAGE@
+ LIBS		=	$(LINKCUPS) $(COMMONLIBS)
+ ONDEMANDFLAGS	=	@ONDEMANDFLAGS@
+-- 
+2.7.2
+
Signature · 1 line
2.7.2
#1 lore raw

PATCH 1/1 package/cups: fix static linking with GnuTLS

Dear J?rg Krause,

Quoted 2 lines · J?rg Krause

cups forgets to link against the libs found by pkg-config if it is build with GnuTLS support.

If this was true, then it would not only fail in static linking scenarios, but also in dynamic linking scenarios.

What apparently is happening is that libcups.so is properly linked against libgnutls.so, so that when you link a binary against libcups.so, everything works fine.

However, when you switch to static linking, this doesn't work, because library dependencies are not recursively taken into account.

While your fix probably works (I haven't tested it), it has the drawback of linking the cups binaries directly with libgnutls.so even in a dynamic linking scenario, while this is not really needed.

This is normally fixed with pkg-config by using the Libs.private field, but here we are *inside* a given package, so the pkg-config files have not yet been installed by the time we link the cups binaries.

I think this problem is normally handled by libtool, but since cups is using only autoconf and not automake/libtool... Maybe we should consult with the cups developers?

Arnout, Yann, do you have other advises?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/cups: fix static linking with GnuTLS

Quoted 7 lines · Thomas Petazzoni

This is normally fixed with pkg-config by using the Libs.private field, but here we are *inside* a given package, so the pkg-config files have not yet been installed by the time we link the cups binaries.

I think this problem is normally handled by libtool, but since cups is using only autoconf and not automake/libtool... Maybe we should consult with the cups developers?

Well, inside a package, it's the responsibility of the package build system to
link with all required libraries (in the required order). That can either be handled by a helper like libtool, or the Makefile should handle it manually.

In other words: I beliver Joerg's fix is the correct one.

Regards,
Arnout

Quoted 2 lines

Arnout, Yann, do you have other advises?

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH 1/1 package/cups: fix static linking with GnuTLS

Dear Arnout Vandecappelle,

Quoted 5 lines · Arnout Vandecappelle

Well, inside a package, it's the responsibility of the package build system to
link with all required libraries (in the required order). That can either be handled by a helper like libtool, or the Makefile should handle it manually.

In other words: I beliver Joerg's fix is the correct one.

As I said in my reply: the issue with Joerg fix is that in the dynamic linking case, it creates useless additional NEEDED entries in the binaries, which are not needed since those binaries are already linked with libcups.so, which itself is linked with libgnutls.so.

Now whether it strongly matters can be discussed, but it is for sure not very elegant.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 package/cups: fix static linking with GnuTLS

In reply to Jörg Krause

Hello,

Quoted 12 lines · J?rg Krause

cups forgets to link against the libs found by pkg-config if it is build with GnuTLS support.

Otherwise, static build fails with:
../cups/libcups.a(tls.o): In function `http_gnutls_create_credential':
cups-2.1.2/cups/tls-gnutls.c:762: undefined reference to `gnutls_x509_crt_init' [..]

Fixes:
http://autobuild.buildroot.net/results/205/20509b7d1edc73dc2a7622f2ae7dbf9f6665a918/
http://autobuild.buildroot.net/results/b86/b86d685caf8cf812f9505fca2de36fb8c18baee1/

Quoted 7 lines

Patch is sent upstream.

---
 .../cups/0004-Fix-static-linking-with-GnuTLS.patch | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 package/cups/0004-Fix-static-linking-with-GnuTLS.patch

In the end, since nobody ever worked on a better solution, I applied your patch (together with a bump to cups 2.1.4).

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com