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 625195 - g-ir-scanner not working well without libtool
g-ir-scanner not working well without libtool
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: g-ir-scanner
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-07-24 16:08 UTC by Allison Karlitskaya (desrt)
Modified: 2015-10-20 17:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
this is enough for me... (413 bytes, patch)
2010-07-24 16:10 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
Fix non-libtool linker flags on Darwin (1.81 KB, patch)
2015-01-18 21:38 UTC, Philip Chimento
none Details | Review
Fix non-libtool linker flags on Darwin (1.81 KB, patch)
2015-01-19 02:34 UTC, Philip Chimento
none Details | Review
Updated patch (1.65 KB, patch)
2015-05-10 22:10 UTC, Philip Chimento
none Details | Review
scanner: Fix non-libtool linker flags on Darwin (1.83 KB, patch)
2015-10-20 16:49 UTC, Philip Chimento
accepted-commit_now Details | Review

Description Allison Karlitskaya (desrt) 2010-07-24 16:08:35 UTC
i just dropped libtool from dconf and now i'm having trouble with the g-ir-scanner.

there are quite a lot of ways that this could be fixed up.

g-ir-scanner currently (appears to?) ignore its --library-path= commandline argument.  this could be used to set LD_LIBRARY_PATH or to set an rpath when building the binary.

better still, the scanner could also be more intelligent about its realisation that the library that it is introspecting is very likely in '.' and add that to the rpath/LD_LIBRARY_PATH.  it already adds the '-L.' option for this reason, but that's only enough to get the link to succeed -- not necessarily enough to get the thing to run.
Comment 1 Allison Karlitskaya (desrt) 2010-07-24 16:10:19 UTC
Created attachment 166491 [details] [review]
this is enough for me...

this trivial patch is enough to fix it for me.

i'm not sure about the compatibility of the -rpath= linker flag.
Comment 2 Colin Walters 2010-07-27 21:21:59 UTC
Review of attachment 166491 [details] [review]:

My main concern is whether this works with gold or not.  (I can't quite test right now).  Otherwise I'm OK with it.
Comment 3 Allison Karlitskaya (desrt) 2010-07-27 21:35:26 UTC
okay.

I checked gold and -rpath=... works.

I added a 'if not libtool:' and committed.
Comment 4 Fabian Groffen 2011-08-21 08:32:21 UTC
This change breaks on Darwin and probably all other platforms/configurations where GNU ld isn't used, since the linker there doesn't understand the -rpath argument.

I don't know how to either figure out what platform we're on in _add_link_internal_args, or run a test on the linker to see if it supports (or actually needs something like) -rpath=.  Sun ld for instance would need -R.
Comment 5 Dan Winship 2011-08-21 12:20:24 UTC
look at G_MODULE_LDFLAGS in glib's configure.ac
Comment 6 Fabian Groffen 2011-08-21 20:44:21 UTC
I don't understand the configure.ac suggestion, this is all cmake drama, isn't it?

Libtool knows how to create libraries, and how to run programs that link against libraries that aren't yet installed.  Adding rpath instructions isn't really the right thing (they stick), and doesn't work on Darwin either, since paths to libraries are recorded.

I guess I'll be better off disabling introspection for non-Linux for now.
Comment 7 Gary Kramlich 2013-07-23 05:06:24 UTC
I'm using g-ir-scanner via cmake with --no-libtool (so yes cmake drama) anyways... I'm trying to build on darwin, and of course it blows up.  Can we maybe get a --no-rpath arguement?  I realize this is added complexity for a small gain, but seems somewhat reasonable for non-gnu ld.
Comment 8 Gary Kramlich 2014-08-15 01:12:58 UTC
It's been a year now... can I please get feedback on this?  I'm not switching my build system because of one argument.  If a patch is needed, just say so, but saying nothing is worthless.
Comment 9 Colin Walters 2014-08-15 20:12:22 UTC
(In reply to comment #7)
> I'm using g-ir-scanner via cmake with --no-libtool (so yes cmake drama)
> anyways... I'm trying to build on darwin, and of course it blows up.  Can we
> maybe get a --no-rpath arguement? 

Is there some other mechanism by which introspection is finding the library on Darwin?  Does it just search for shared libraries in $(pwd) by default?

If so, I don't think we want a --no-rpath, we'd just want if darwin: <don't use -Wl,rpath=>, similar to what we do for MSVC++.
Comment 10 Philip Chimento 2015-01-02 23:00:16 UTC
I've been trying to build WebKit 2.6.4 (which uses cmake these days) on OSX and I ran into this too.

Apparently the OSX linker does understand -rpath but only in the form -rpath <directory>, not -rpath=<directory>, so you have to pass -Wl,-rpath -Wl,<directory>.

In addition, the OSX linker doesn't understand --no-as-needed, and I'm not sure what the equivalent switch is (the counterpart to --as-needed is -dead_strip_dylibs so perhaps -no_dead_strip_dylibs?)

If someone knows a good way to detect the OSX linker (ld -version doesn't work, so not much help) I might be able to prepare a patch.
Comment 11 Philip Chimento 2015-01-18 21:38:03 UTC
Created attachment 294814 [details] [review]
Fix non-libtool linker flags on Darwin

Darwin's linker doesn't like "-rpath=path"; instead pass "-rpath path".
Additionally, there is no equivalent for "--no-as-needed" (it seems to do
the right thing by default?)
Comment 12 Philip Chimento 2015-01-18 21:38:54 UTC
This works for me; I'm still not sure what the equivalent to --no-as-needed is, but things seem to work properly so far by just leaving it off.
Comment 13 Philip Chimento 2015-01-19 02:34:40 UTC
Created attachment 294836 [details] [review]
Fix non-libtool linker flags on Darwin

Darwin's linker doesn't like "-rpath=path"; instead pass "-rpath path".
Additionally, there is no equivalent for "--no-as-needed" (it seems to do
the right thing by default?)
Comment 14 Philip Chimento 2015-01-19 02:35:11 UTC
Forgot a comma in the first patch.
Comment 15 André Klapper 2015-02-07 17:10:42 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
Comment 16 Philip Chimento 2015-05-10 22:10:13 UTC
Created attachment 303193 [details] [review]
Updated patch

Here's a slightly updated patch. Any comments? I'd like to see it landed, because it's blocking webkitgtk for OSX.
Comment 17 Colin Walters 2015-05-11 12:14:33 UTC
Review of attachment 303193 [details] [review]:

This affects libtool on all platforms; did you test on anything else like GNU/Linux?

::: giscanner/ccompiler.py
@@ +70,3 @@
                     args.append(str.lower(ns) + '.lib')
             else:
+                args.append('-Wl,-rpath,.')

Typo?
Comment 18 Philip Chimento 2015-05-12 05:25:55 UTC
(In reply to Colin Walters from comment #17)
> Review of attachment 303193 [details] [review] [review]:
> 
> This affects libtool on all platforms; did you test on anything else like
> GNU/Linux?

I tested on Fedora 21 (editing the system version of g-ir-scanner in place) on one of my own projects. There was no difference in output when using --no-libtool between the modified and unmodified g-ir-scanner. I did confirm that the modified -Wl,-rpath,. flag occurred in the "g-ir-scanner: link:" output.

(Interestingly, there was a bit of a difference in output between --no-libtool and --libtool, but since it occurs without this change, I would say it's nothing to do with this)
 
> ::: giscanner/ccompiler.py
> @@ +70,3 @@
>                      args.append(str.lower(ns) + '.lib')
>              else:
> +                args.append('-Wl,-rpath,.')
> 
> Typo?

There may well be a typo that I'm overlooking, but if you mean the comma, it's there on purpose. (GNU LD accepts both styles of options, "-rpath=." and "-rpath .", while Darwin LD only accepts the latter. You can pass more than one argument to -Wl by concatenating them with commas, and that way they won't get rearranged.)
Comment 19 Philip Chimento 2015-10-19 01:08:49 UTC
Is there anything I can do to help get this landed? There's currently no way to build introspection bindings on OS X for libraries that don't use libtool.

I'm trying to get WebKitGTK into the GTK-for-OSX JHbuild module sets [1], and this is somewhat of an inconvenience.

[1] https://github.com/jralls/gtk-osx-build/pull/42
Comment 20 Colin Walters 2015-10-19 15:00:58 UTC
Looks like this needs a rebase on git master.
Comment 21 Philip Chimento 2015-10-20 16:49:37 UTC
Created attachment 313766 [details] [review]
scanner: Fix non-libtool linker flags on Darwin

Darwin's linker doesn't like "-rpath=path"; instead pass "-rpath path",
which works on more linkers than the version with the = sign does.
Additionally, Darwin's linker has no equivalent for "--no-as-needed" (it
seems to do the right thing by default?)
Comment 22 Philip Chimento 2015-10-20 16:51:36 UTC
Here's a rebased patch; sorry for the wait, I wanted to build WebKit again to make sure everything worked.
Comment 23 Colin Walters 2015-10-20 17:13:46 UTC
Review of attachment 313766 [details] [review]:

OK, thanks!
Comment 25 Philip Chimento 2015-10-20 17:32:18 UTC
Thank you!