GNOME Bugzilla – Bug 625195
g-ir-scanner not working well without libtool
Last modified: 2015-10-20 17:32:18 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.
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.
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.
okay. I checked gold and -rpath=... works. I added a 'if not libtool:' and committed.
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.
look at G_MODULE_LDFLAGS in glib's configure.ac
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.
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.
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.
(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++.
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.
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?)
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.
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?)
Forgot a comma in the first patch.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]
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.
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?
(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.)
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
Looks like this needs a rebase on git master.
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?)
Here's a rebased patch; sorry for the wait, I wanted to build WebKit again to make sure everything worked.
Review of attachment 313766 [details] [review]: OK, thanks!
https://git.gnome.org/browse/gobject-introspection/commit/?id=4a724ac699f0c34fba2fb452cfadea11540325e8
Thank you!