Bug 209813 - Problems with implicit library dependencies introduced by gnome ports
Summary: Problems with implicit library dependencies introduced by gnome ports
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-gnome (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-28 15:13 UTC by Dmitry Marakasov
Modified: 2020-12-21 18:07 UTC (History)
6 users (show)

See Also:


Attachments
Add libintl.so to glib20_LIB_DEPENDS (586 bytes, patch)
2016-12-18 09:53 UTC, Antoine Brodin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov freebsd_committer freebsd_triage 2016-05-28 15:13:54 UTC
Gnome libraries add a lot of implicit library dependencies via their pkg-config files:

% pkg-config --libs gtk+-2.0
-L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lpthread -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lfontconfig -lfreetype  

These libraries are now detected as unlisted dependencies:

Error: /usr/local/lib/libgoocanvas.so.3.5.0 is linked to /usr/local/lib/libgdk_pixbuf-2.0.so.0 from graphics/gdk-pixbuf2 but it is not declared as a dependency
Warning: you need USE_GNOME+=gdkpixbuf2
Error: /usr/local/lib/libgoocanvas.so.3.5.0 is linked to /usr/local/lib/libfontconfig.so.1 from x11-fonts/fontconfig but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libfontconfig.so:x11-fonts/fontconfig
Error: /usr/local/lib/libgoocanvas.so.3.5.0 is linked to /usr/local/lib/libfreetype.so.6 from print/freetype2 but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libfreetype.so:print/freetype2
Error: /usr/local/lib/libgoocanvas.so.3.5.0 is linked to /usr/local/lib/libcairo.so.2 from graphics/cairo but it is not declared as a dependency
Warning: you need USE_GNOME+=cairo
Error: /usr/local/lib/libgoocanvas.so.3.5.0 is linked to /usr/local/lib/libintl.so.8 from devel/gettext-runtime but it is not declared as a dependency
Warning: you need USES+=gettext

This should be fixed ASAP if we don't want many ports to be polluted with these bogus dependencies.

Instead, these additional dependencies should be added implicitly by USE_GNOME parts.
Comment 1 Tijl Coosemans freebsd_committer freebsd_triage 2016-05-30 19:48:50 UTC
Yes they should be added via USE_GNOME, but please look at the .pc file to determine the dependencies instead of using "pkg-config --libs".
Comment 2 Dmitry Marakasov freebsd_committer freebsd_triage 2016-05-30 20:47:26 UTC
(In reply to Tijl Coosemans from comment #1)
> Yes they should be added via USE_GNOME, but please look at the .pc file to
> determine the dependencies instead of using "pkg-config --libs".

You mean Requires line? It's incomplete. gettext is not listed, for instance.
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2016-05-30 21:17:12 UTC
Requires and Libs.  -lintl is added by glib-2.0.pc so it can be added to glib20_LIB_DEPENDS.
Comment 4 Mathieu Arnold freebsd_committer freebsd_triage 2016-05-31 10:38:56 UTC
Mmm, might this be a case of overlinking ?
Comment 5 Baptiste Daroussin freebsd_committer freebsd_triage 2016-05-31 12:38:17 UTC
yes this is overlinking, it is known that lots of the gnome '.pc' files lead to overlinking and are badly formatted :(
Comment 6 Tijl Coosemans freebsd_committer freebsd_triage 2016-05-31 13:15:06 UTC
As far as I know upstream is very well aware of this and it's all intentional.  The dependencies are added by the headers.  Some glib headers include libintl.h and then use gettext in some macros.  Programs that use this API (directly or indirectly) can end up with calls to gettext and need to be linked with libintl.so.  These programs shouldn't have to care about how the API is implemented (with gettext or something else) so the reasoning is that it's pkg-config's job to add -lintl.  This means -lintl is always added even when it isn't strictly necessary, but there isn't any more fine-grained method.  It would be nice if library requirements could be expressed in headers (and object files) so the compiler (and linker) know exactly what libraries are needed.
Comment 7 Antoine Brodin freebsd_committer freebsd_triage 2016-12-18 09:53:23 UTC
Created attachment 178045 [details]
Add libintl.so to glib20_LIB_DEPENDS

Attached patch adds libintl.so to glib20_LIB_DEPENDS.

It should fix a very small part of the issue but this small part affects around 1800 ports.
Comment 8 commit-hook freebsd_committer freebsd_triage 2017-03-12 08:26:23 UTC
A commit references this bug:

Author: antoine
Date: Sun Mar 12 08:25:23 UTC 2017
New revision: 435977
URL: https://svnweb.freebsd.org/changeset/ports/435977

Log:
  Add libintl.so to glib20_LIB_DEPENDS

  As noted in PR 209813, some glib headers include libintl.h and then use
  gettext in some macros.  Programs that use this API (directly or indirectly)
  can end up with calls to gettext and need to be linked with libintl.so.
  glib-2.0.pc has -lintl in its Libs too.

  PR:		209813
  With hat:	portmgr

Changes:
  head/Mk/Uses/gnome.mk
Comment 9 Walter Schwarzenfeld freebsd_triage 2018-02-07 23:07:51 UTC
Forgotten to close?
Comment 10 Tijl Coosemans freebsd_committer freebsd_triage 2018-02-08 21:43:12 UTC
No, libintl was just one case.
Comment 11 Tobias C. Berner freebsd_committer freebsd_triage 2020-12-19 14:36:31 UTC
Moin moin 

Please re-open if this is still an issue.


mfg Tobias
Comment 12 Dmitry Marakasov freebsd_committer freebsd_triage 2020-12-21 18:06:18 UTC
It is, in fact nothing has been done to fix it.

Here's an example:

---
PORTNAME=       testport
PORTVERSION=    0.0.0
DISTVERSIONPREFIX=      v
CATEGORIES=     devel
DISTFILES=      #

MAINTAINER=     amdmi3@FreeBSD.org
COMMENT=        Empty comment

USES=           pkgconfig
USE_GNOME=      gtk30

PLIST_FILES=    bin/testbin

do-build:
        @${MKDIR} ${WRKSRC}
        echo 'int main(){}' > ${WRKSRC}/main.c
        cd ${WRKSRC} && ${CC} `pkg-config --libs --cflags gtk+-3.0` main.c -o testbin

do-install:
        ${INSTALL_PROGRAM} ${WRKSRC}/testbin ${STAGEDIR}${PREFIX}/bin/

.include <bsd.port.mk>
---

====> Running Q/A tests (stage-qa)
Error: /usr/local/bin/testbin is linked to /usr/local/lib/libcairo-gobject.so.2 from graphics/cairo but it is not declared as a dependency
Warning: you need USE_GNOME+=cairo
Error: /usr/local/bin/testbin is linked to /usr/local/lib/libcairo.so.2 from graphics/cairo but it is not declared as a dependency
Warning: you need USE_GNOME+=cairo
Error: /usr/local/bin/testbin is linked to /usr/local/lib/libgdk_pixbuf-2.0.so.0 from graphics/gdk-pixbuf2 but it is not declared as a dependency
Warning: you need USE_GNOME+=gdkpixbuf2
Comment 13 Dmitry Marakasov freebsd_committer freebsd_triage 2020-12-21 18:07:04 UTC
I can work on this if there's no objection