After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699442 - g-ir-scanner fails when no symbols used in dumper
g-ir-scanner fails when no symbols used in dumper
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-05-02 07:57 UTC by Robert Ancell
Modified: 2015-02-07 16:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Ensure libraries always link when using libtool so we can resolve their names later (983 bytes, patch)
2013-05-02 07:57 UTC, Robert Ancell
none Details | Review
Ensure libraries always link when not using libtool so we can resolve their names later (987 bytes, patch)
2013-05-02 16:00 UTC, Robert Ancell
reviewed Details | Review
Fix scanning libraries with no GObjects and linker using --as-needed (1.03 KB, patch)
2013-05-02 16:34 UTC, Robert Ancell
committed Details | Review

Description Robert Ancell 2013-05-02 07:57:28 UTC
Created attachment 243022 [details] [review]
Ensure libraries always link when using libtool so we can resolve their names later

Simple library:

== test.c ==
int test_foo()
{
  return 42;
}
============

== test.h ==
int test_foo();
============

Scan with:
$ g-ir-scanner --no-libtool --namespace=Test --nsversion=0 --library=test --output Test-0.gir --include=GObject-2.0 test.c test.h
...
ERROR: can't resolve libraries to shared libraries: test

The reason it fails is the scanner doesn't find any test_*_get_type() functions so the generated dumper program uses no symbols from test.c. Thus when ldd is used to find libtest.so it fails because ld didn't link the binary against libtest.

The solution is to link with --no-as-needed
Comment 1 Robert Ancell 2013-05-02 07:58:34 UTC
I have one uncertainty about the patch - not sure how this works with other linkers.
Comment 2 Robert Ancell 2013-05-02 15:59:31 UTC
After talking to Ryan Lortie this seems to mainly be a problem on Ubuntu where the linker is set to --no-as-needed by default.
Comment 3 Robert Ancell 2013-05-02 16:00:32 UTC
Created attachment 243071 [details] [review]
Ensure libraries always link when not using libtool so we can resolve their names later

Fix typo in the commit message
Comment 4 Colin Walters 2013-05-02 16:25:24 UTC
Review of attachment 243071 [details] [review]:

"Fix scanning libraries with no GObjects and --as-needed" might be a more informative commit message.  Can you also link back to this bug in the commit message?

One concern: This looks likely to break the MSVC case; I guess the current discriminator is "if self._pkgconfig_msvc_flags", so add that to the conditional?
Comment 5 Robert Ancell 2013-05-02 16:34:20 UTC
Created attachment 243075 [details] [review]
Fix scanning libraries with no GObjects and linker using --as-needed
Comment 6 Colin Walters 2013-05-02 16:43:56 UTC
Review of attachment 243075 [details] [review]:

Looks good, thanks!
Comment 7 Robert Ancell 2013-05-02 16:52:26 UTC
Comment on attachment 243075 [details] [review]
Fix scanning libraries with no GObjects and linker using --as-needed

Thanks for the review!
Comment 8 André Klapper 2015-02-07 16:56:07 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]