Bug 132220

Summary: [GTK] GObject introspection links to installed libs when using jhbuild
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bunhere, cdumez, commit-queue, gyuyoung.kim, lantw44, rakuco, sergio
Priority: P2 Keywords: Gtk, Regression
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 132226    
Attachments:
Description Flags
Patch mrobinson: review+

Description Carlos Garcia Campos 2014-04-26 03:16:00 PDT
See:

/home/cgarcia/src/git/gnome/WebKit/WebKitBuild/Release/Source/WebKit2/tmp-introspecttMzAlB/WebKit2WebExtension-3.0.o:(.data+0x4b8): referencia a `webkit_dom_vtt_cue_get_type' sin definir (this is undefined reference in English)
collect2: error: ld returned 1 exit status
linking of temporary binary failed: Command '['/home/cgarcia/src/git/icecream/bin/cc', '-o', '/home/cgarcia/src/git/gnome/WebKit/WebKitBuild/Release/Source/WebKit2/tmp-introspecttMzAlB/WebKit2WebExtension-3.0', '-Wno-deprecated-declarations', '-L/home/cgarcia/gnome/lib64', '/home/cgarcia/src/git/gnome/WebKit/WebKitBuild/Release/Source/WebKit2/tmp-introspecttMzAlB/WebKit2WebExtension-3.0.o', '-L.', '-Wl,-rpath=.', '-Wl,--no-as-needed', '-lwebkit2gtk-3.0', '-ljavascriptcoregtk-3.0', '-L/home/cgarcia/src/git/gnome/WebKit/WebKitBuild/Release/lib', '-Wl,-rpath=/home/cgarcia/src/git/gnome/WebKit/WebKitBuild/Release/lib', '-Wl,--export-dynamic', '-pthread', '-L/home/cgarcia/gnome/lib64', '-lgmodule-2.0', '-lgtk-3', '-lgdk-3', '-latk-1.0', '-lpangocairo-1.0', '-lgdk_pixbuf-2.0', '-lcairo-gobject', '-lpango-1.0', '-lcairo', '-lsoup-2.4', '-lgio-2.0', '-lgobject-2.0', '-lglib-2.0']' returned non-zero exit status 1

As you can see there's two -L/home/cgarcia/gnome/lib64, and the first one is very early an takes precedence. That first one comes from the LDFLAGS env varaibles that jhbuild sets. The other one, which is correctly set after the builddir paths, is deduced by g-ir-scanner from the lib arguments passed using ldd. This didn't happen with autotools because g-ir-scanner used libtool. 
This is not a problem when using the internal jhbuild because we never run make install for webkit, only for the dependencies, so the linker never finds a installed webkit in jhbuild env.
Since we are already overriding the CFLAGS env var we can simply override LDFLAGS as well to unset it, since g-ir-scanner will do the right thing deducing all library paths using ldd.
Comment 1 Carlos Garcia Campos 2014-04-26 03:22:03 PDT
Created attachment 230240 [details]
Patch
Comment 2 Martin Robinson 2014-04-26 08:27:01 PDT
Comment on attachment 230240 [details]
Patch

Seems reasonable, though I wonder if some flags should be passed through. What is the value of LDFLAGS that is causing the incorrect link.
Comment 3 Carlos Garcia Campos 2014-04-26 12:03:20 PDT
(In reply to comment #2)
> (From update of attachment 230240 [details])
> Seems reasonable, though I wonder if some flags should be passed through. What is the value of LDFLAGS that is causing the incorrect link.

$ jhbuild run env | grep LDFLAGS
LDFLAGS=-L/home/cgarcia/gnome/lib64

That's added later guessed from the deps. We are already overriding the CFLAGS as well. jhbuild sets the LDFLAGS env var to make sure the programs compiled during configure build against the jhbuild environment. Note that this only affects the temporary files compiled by gobject-introspection to generate the gir files, so I'm pretty sure it's safe to override the LDFLAGS.
Comment 4 Carlos Garcia Campos 2014-04-28 00:52:17 PDT
Committed r167873: <http://trac.webkit.org/changeset/167873>
Comment 5 Ting-Wei Lan 2014-08-06 11:25:57 PDT
Ignoring LDFLAGS causes build failure on FreeBSD because it cannot find libintl via LDFLAGS.