From owner-freebsd-ports@FreeBSD.ORG Sat Dec 22 12:21:40 2007 Return-Path: Delivered-To: ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34A3016A494 for ; Sat, 22 Dec 2007 12:21:40 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:610:652::211]) by mx1.freebsd.org (Postfix) with ESMTP id E356813C45A for ; Sat, 22 Dec 2007 12:21:37 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 63BDB1CDA8; Sat, 22 Dec 2007 13:21:49 +0100 (CET) Date: Sat, 22 Dec 2007 13:21:49 +0100 From: Ed Schouten To: ports@freebsd.org Message-ID: <20071222122149.GK1169@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FnOKg9Ah4tDwTfQS" Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) Cc: Subject: pkg-config and library dependencies X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Dec 2007 12:21:40 -0000 --FnOKg9Ah4tDwTfQS Content-Type: multipart/mixed; boundary="5mZBmBd1ZkdwT1ny" Content-Disposition: inline --5mZBmBd1ZkdwT1ny Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello everyone, This morning I ran a `readelf -d' on an application that I maintain (audio/herrie) and I saw that my application depends on a lot of libraries that the application doesn't use anyway, but get pulled in recursively. If I understand correctly, this is bad behaviour. If your application uses GNOME's GLib, it always depends on libiconv, even though you don't call any functions in those libraries. So when libiconv's major gets bumped, you don't need to recompile a single library, but the entire tree of applications. It turns out that my configure script added some unneeded -lfoo's, so I removed those, but there were still a lot of libraries that got added by pkg-config and friends. It turns out that a lot of those .pc's add rubbish: | $ pkg-config --libs libcurl | -rpath=3D/usr/lib:/usr/local/lib -L/usr/local/lib -lcurl =20 | $ pkg-config --libs glib-2.0 | -L/usr/local/lib -lglib-2.0 -liconv =20 | $ pkg-config --libs gthread-2.0 | -pthread -L/usr/local/lib -lgthread-2.0 -lglib-2.0 -liconv =20 The last case is even worse. Your application will link directly against libthr if your use libgthread, voiding the entire idea of abstracting the threads library. I guess the reason they were added, is keep things working when compiling static binaries, because you can't recursively pull dependencies in that case, but that is a wrong argument, because you can then add the libraries to Libs.private and use `pkg-config --static'. I've added a bunch of patches for the ports I use for audio/herrie. I didn't file any PR's yet, because I'd like to hear your opinions on this matter. Are my findings correct? --=20 Ed Schouten WWW: http://g-rave.nl/ --5mZBmBd1ZkdwT1ny Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="curl.patch" --- ftp/curl/files/patch-libcurl.pc.in 1970-01-01 01:00:00.000000000 +0100 +++ ftp/curl/files/patch-libcurl.pc.in 2007-12-22 11:18:46.000000000 +0100 @@ -0,0 +1,10 @@ +--- libcurl.pc.in 2007-02-18 10:41:27.000000000 +0100 ++++ libcurl.pc.in 2007-12-22 10:19:13.000000000 +0100 +@@ -33,6 +33,6 @@ + URL: http://curl.haxx.se/ + Description: Library to transfer files with ftp, http, etc. + Version: @VERSION@ +-Libs: -L${libdir} -lcurl @LDFLAGS@ @LIBS@ ++Libs: -L${libdir} -lcurl + Libs.private: @LIBCURL_LIBS@ @LIBS@ + Cflags: -I${includedir} --5mZBmBd1ZkdwT1ny Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="glib20.patch" Content-Transfer-Encoding: quoted-printable --- devel/glib20/files/patch-pkgconfig 1970-01-01 01:00:00.000000000 +0100 +++ devel/glib20/files/patch-pkgconfig 2007-12-22 13:00:56.000000000 +0100 @@ -0,0 +1,51 @@ +--- glib-2.0.pc.in 2007-11-24 07:41:02.000000000 +0100 ++++ glib-2.0.pc.in 2007-12-22 12:59:43.000000000 +0100 +@@ -10,6 +10,7 @@ + Name: GLib + Description: C Utility Library + Version: @VERSION@ +-Libs: -L${libdir} -lglib-2.0 @INTLLIBS@ @ICONV_LIBS@ ++Libs: -L${libdir} -lglib-2.0 ++Libs.private: @INTLLIBS@ @ICONV_LIBS@ + Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include=20 +=20 +--- gmodule-2.0.pc.in 2007-11-24 07:41:02.000000000 +0100 ++++ gmodule-2.0.pc.in 2007-12-22 12:59:43.000000000 +0100 +@@ -9,5 +9,6 @@ + Description: Dynamic module loader for GLib + Requires: glib-2.0 + Version: @VERSION@ +-Libs: -L${libdir} @G_MODULE_LDFLAGS@ -lgmodule-2.0 @G_MODULE_LIBS@ ++Libs: -L${libdir} @G_MODULE_LDFLAGS@ -lgmodule-2.0 ++Libs.private: @G_MODULE_LIBS@ + Cflags: +--- gmodule-export-2.0.pc.in 2007-11-24 07:41:02.000000000 +0100 ++++ gmodule-export-2.0.pc.in 2007-12-22 12:59:43.000000000 +0100 +@@ -9,5 +9,6 @@ + Description: Dynamic module loader for GLib + Requires: glib-2.0 + Version: @VERSION@ +-Libs: -L${libdir} @G_MODULE_LDFLAGS@ -lgmodule-2.0 @G_MODULE_LIBS@ ++Libs: -L${libdir} @G_MODULE_LDFLAGS@ -lgmodule-2.0 ++Libs.private: @G_MODULE_LIBS@ + Cflags: +--- gmodule-no-export-2.0.pc.in 2007-11-24 07:41:02.000000000 +0100 ++++ gmodule-no-export-2.0.pc.in 2007-12-22 12:59:43.000000000 +0100 +@@ -9,5 +9,6 @@ + Description: Dynamic module loader for GLib + Requires: glib-2.0 + Version: @VERSION@ +-Libs: -L${libdir} -lgmodule-2.0 @G_MODULE_LIBS@ ++Libs: -L${libdir} -lgmodule-2.0 ++Libs.private: @G_MODULE_LIBS@ + Cflags: +--- gthread-2.0.pc.in 2007-11-24 07:41:02.000000000 +0100 ++++ gthread-2.0.pc.in 2007-12-22 12:59:43.000000000 +0100 +@@ -7,5 +7,6 @@ + Description: Thread support for GLib + Requires: glib-2.0 + Version: @VERSION@ +-Libs: -L${libdir} -lgthread-2.0 @G_THREAD_LIBS@ ++Libs: -L${libdir} -lgthread-2.0 ++Libs.private: @G_THREAD_LIBS@ + Cflags: @G_THREAD_CFLAGS@ --5mZBmBd1ZkdwT1ny Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="libid3tag.patch" --- audio/libid3tag/files/patch-id3tag.pc.in 2003-12-29 20:54:29.000000000 +0100 +++ audio/libid3tag/files/patch-id3tag.pc.in 2007-12-22 11:31:05.000000000 +0100 @@ -1,6 +1,6 @@ --- id3tag.pc.in.orig 1970-01-01 09:00:00.000000000 +0900 +++ id3tag.pc.in 2003-11-11 08:42:38.000000000 +0900 -@@ -0,0 +1,10 @@ +@@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ @@ -9,5 +9,6 @@ +Name: ID3TAG +Description: libid3tag - ID3 tag manipulation library +Version: @VERSION@ -+Libs: -L${libdir} -lid3tag -lz ++Libs: -L${libdir} -lid3tag ++Libs.private: -lz +Cflags: --5mZBmBd1ZkdwT1ny Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="libmad.patch" --- audio/libmad/files/mad.pc.in 2004-10-12 00:20:46.000000000 +0200 +++ audio/libmad/files/mad.pc.in 2007-12-22 11:28:06.000000000 +0100 @@ -7,5 +7,6 @@ Description: MPEG Audio Decoder Requires: Version: %VERSION% -Libs: -L${libdir} -lmad -lm +Libs: -L${libdir} -lmad +Libs.private: -lm Cflags: -I${includedir} --5mZBmBd1ZkdwT1ny Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="libmodplug.patch" Content-Transfer-Encoding: quoted-printable --- audio/libmodplug/files/patch-libmodplug.pc.in 1970-01-01 01:00:00.00000= 0000 +0100 +++ audio/libmodplug/files/patch-libmodplug.pc.in 2007-12-22 11:28:39.00000= 0000 +0100 @@ -0,0 +1,10 @@ +--- libmodplug.pc.in 2005-07-05 02:20:34.000000000 +0200 ++++ libmodplug.pc.in 2007-12-22 11:28:30.000000000 +0100 +@@ -7,5 +7,6 @@ + Description: The ModPlug mod file playing library. + Version: @VERSION@ + Requires:=20 +-Libs: -L${libdir} -lmodplug -lstdc++ -lm ++Libs: -L${libdir} -lmodplug ++Libs.private: -lstdc++ -lm + Cflags: -I${includedir} -I${includedir}/libmodplug --5mZBmBd1ZkdwT1ny-- --FnOKg9Ah4tDwTfQS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFHbQFd52SDGA2eCwURAncTAJ9femRJJ/f3DPKlOVaN32pj00Jo6wCfSl4h bOhLkHk+mSpYyBMO1Iz3LiM= =WBkP -----END PGP SIGNATURE----- --FnOKg9Ah4tDwTfQS--