Bug 226356 - [patch] Build against xulrunner
Summary: [patch] Build against xulrunner
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-04-09 15:56 EDT by Andrew Overholt CLA
Modified: 2009-04-06 19:33 EDT (History)
0 users

See Also:


Attachments
Patch (1016 bytes, patch)
2008-04-09 15:57 EDT, Andrew Overholt CLA
no flags Details | Diff
if xulrunner: make_mozilla -> make_xulrunner (1.08 KB, patch)
2009-03-05 15:42 EST, Andrew Overholt CLA
no flags Details | Diff
look for swt-xulrunner when MOZILLA_FIVE_HOME found (1.57 KB, patch)
2009-03-18 16:01 EDT, Andrew Overholt CLA
no flags Details | Diff
another potential patch to build.sh (1.66 KB, patch)
2009-03-20 17:13 EDT, Andrew Overholt CLA
no flags Details | Diff
build both libswt-xpcominit AND (libswt-xulrunner OR libswt-mozilla) (1.51 KB, patch)
2009-04-06 17:13 EDT, Andrew Overholt CLA
no flags Details | Diff
work around libxul.pc having -lxpcomglue_s and not -lxpcomglue (1.52 KB, patch)
2009-04-06 17:14 EDT, Andrew Overholt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Overholt CLA 2008-04-09 15:56:30 EDT
I've added a block to build.sh to build the mozilla bindings against xulrunner's pkg-config file, libxul.pc.  I'll attach the patch.
Comment 1 Andrew Overholt CLA 2008-04-09 15:57:36 EDT
Created attachment 95418 [details]
Patch

Patch adding the block checking for libxul.pc.
Comment 2 Grant Gayed CLA 2008-04-10 09:47:04 EDT
Thanks for the patch!  Committed to the gtk and motif streams > 0410.
Comment 3 Andrew Overholt CLA 2009-03-05 15:42:16 EST
Created attachment 127709 [details]
if xulrunner:  make_mozilla -> make_xulrunner

I think I made a mistake with my original patch.  If we find XULRunner
development libraries, we want to make_xulrunner and not make_mozilla,
right?
Comment 4 Andrew Overholt CLA 2009-03-05 15:44:46 EST
Re-opening.
Comment 5 Grant Gayed CLA 2009-03-13 17:09:11 EDT
makes sense, released > 20090313
Comment 6 Andrew Overholt CLA 2009-03-17 13:38:21 EDT
I just ran a build of Eclipse SDK 3.4.2 with this patch.  It built fine and I got the xulrunner .so files.  The internal browser no longer works, though:

/usr/lib64/xulrunner-1.9'] (java.lang.UnsatisfiedLinkError: no swt-mozilla-gtk-3452 or swt-mozilla-gtk in swt.library.path, java.library.path or the jar file)
org.eclipse.swt.SWTError: No more handles

Any thoughts, Grant?  Thanks.
Comment 7 Grant Gayed CLA 2009-03-17 13:47:42 EDT
So it thinks that it wants the swt-mozilla lib at runtime, not the swt-xulrunner one, which is unexpected because I'd assume that your OS has a xulrunner available for it to find.  What does running http://www.eclipse.org/swt/faq.php#printmozillapath write to stdout?
Comment 8 Andrew Overholt CLA 2009-03-17 13:56:53 EDT
(In reply to comment #7)
> So it thinks that it wants the swt-mozilla lib at runtime, not the
> swt-xulrunner one, which is unexpected because I'd assume that your OS has a
> xulrunner available for it to find.

Yeah, I'm using Firefox which is using XULRunner right now :)  It's all in /usr/lib64/xulrunner-1.9 AFAICT.

> What does running
> http://www.eclipse.org/swt/faq.php#printmozillapath write to stdout?

>>>Snippet creating SWT.MOZILLA-style Browser
>>>This failed with the following error:
org.eclipse.swt.SWTError: No more handles [Could not detect registered XULRunner to use]
	at org.eclipse.swt.SWT.error(SWT.java:3803)
	at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:327)
	at org.eclipse.swt.browser.Browser.<init>(Browser.java:118)
	at DisplayMozillaVersion.main(DisplayMozillaVersion.java:13)


Snippet creating SWT.NONE-style Browser
>>>This failed too, with the following error:
org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
	at org.eclipse.swt.SWT.error(SWT.java:3803)
	at org.eclipse.swt.browser.Mozilla.create(Mozilla.java:339)
	at org.eclipse.swt.browser.Browser.<init>(Browser.java:118)
	at DisplayMozillaVersion.main(DisplayMozillaVersion.java:20)
Comment 9 Grant Gayed CLA 2009-03-17 15:10:15 EDT
> [Could not detect registered XULRunner to use]

So that's why it wants the mozilla library anyways.

I assume you're running 64-bit eclipse?  If you're running 32-bit eclipse then it's probably finding your 64-bit xulrunner, trying to use it, then running away when it fails.

Or alternatively, if you are running 64-bit eclipse, could it be finding a 32-bit xulrunner somewhere else on your OS and failing similarly?

Or, is it possible that your xulrunner isn't properly registered on your OS?  Does executing xulrunner --register-global change anything?
Comment 10 Andrew Overholt CLA 2009-03-17 15:14:32 EDT
(In reply to comment #9)
> > [Could not detect registered XULRunner to use]
> 
> So that's why it wants the mozilla library anyways.

Hmm.

> I assume you're running 64-bit eclipse?

Yes.

> Or alternatively, if you are running 64-bit eclipse, could it be finding a
> 32-bit xulrunner somewhere else on your OS and failing similarly?

I only have a system-wide 64-bit xulrunner installed:

$ which xulrunner
/usr/bin/xulrunner

$ rpm -qf `!!`
rpm -qf `which xulrunner`
xulrunner-1.9.0.6-1.fc10.x86_64

> Or, is it possible that your xulrunner isn't properly registered on your OS? 
> Does executing xulrunner --register-global change anything?

It doesn't appear to.  I get the same results after running that as both my user and root.
Comment 11 Grant Gayed CLA 2009-03-17 16:52:18 EDT
It's difficult to know what's happening then, it sounds like it should find the xulrunner.  I think the best thing to do would be to set a breakpoint.  Steps:

- retrieve swt from cvs: http://www.eclipse.org/swt/cvs.php
- put a breakpoint at the beginning of Mozilla.create()
- run http://www.eclipse.org/swt/faq.php#printmozillapath , hit the breakpoint

Mozilla creation/initialization happens at the beginning of Mozilla.create().  It's a long ugly method, but I think the comments spell out what's happening, it's just a bunch of different attempts that are made to find a usable gre.
Comment 12 Andrew Overholt CLA 2009-03-18 14:19:38 EDT
(In reply to comment #11)
> - put a breakpoint at the beginning of Mozilla.create()
> - run http://www.eclipse.org/swt/faq.php#printmozillapath , hit the breakpoint
> 
> Mozilla creation/initialization happens at the beginning of Mozilla.create(). 
> It's a long ugly method, but I think the comments spell out what's happening,
> it's just a bunch of different attempts that are made to find a usable gre.

It looks like it's not finding libswt-xpcominit-gtk-<version>.  Funny though, 'cause that file didn't exist when I built with make_mozilla either.  In fact, the files in both cases are the same except for the naming:

libswt-mozilla-gtk-3452.so -> libswt-xulrunner-gtk-3452.so

I'll see if I can figure out how this works with the former and what's different with the latter.
Comment 13 Andrew Overholt CLA 2009-03-18 16:01:42 EDT
Created attachment 129281 [details]
look for swt-xulrunner when MOZILLA_FIVE_HOME found

(In reply to comment #12)
> I'll see if I can figure out how this works with the former and what's
> different with the latter.

It looks like it was just a simple case of not looking for swt-xulrunner when MOZILLA_FIVE_HOME has been picked up.  See attached patch for one possible fix.
Comment 14 Grant Gayed CLA 2009-03-18 16:45:04 EDT
If swt's xpcominit lib is not there then this is the problem, this is what's needed to magically detect a xulrunner at runtime.  The solution should be whatever causes this lib to be built.

swt's mozilla and xulrunner libraries should be quite similar (but not identical) to each other.
Comment 15 Andrew Overholt CLA 2009-03-20 16:48:02 EDT
I'm confused as to where the problem lies.  If I alter build.sh to force it to call both make_xulrunner *and* make_xpcominit, my build succeeds but the test program fails with:

symbol lookup error: /home/overholt/workspace/org.eclipse.swt.gtk.linux.x86_64/libswt-xpcominit-gtk-3537.so: undefined symbol: XPCOMGlueStartup

If I modify libxul.pc (the pkg-config file from xulrunner-devel) to change this line:

Libs: -L${sdkdir}/sdk/lib -lxpcomglue_s -lxul -lxpcom 

to be like this:

Libs: -L${sdkdir}/sdk/lib -lxpcomglue_s -lxul -lxpcom -lxpcomglue

as seen at [1], rebuild, and re-run, things work.

[1]
http://bugs.gentoo.org/241400
Comment 16 Grant Gayed CLA 2009-03-20 16:56:52 EDT
When we build swt's libs the following vars are set, maybe these would help?  They're from the swt gtk fragment's buildLibraries_rhel4.csh file.

setenv MOZILLA_INCLUDES "-include ${MOZILLA_SDK}/mozilla-config.h -I${MOZILLA_SDK}/../include/xpcom -I${MOZILLA_SDK}/../include/nspr -I${MOZILLA_SDK}/../include/embed_base -I${MOZILLA_SDK}/../include/embedstring -I${MOZILLA_SDK}/../include/string"
setenv MOZILLA_LIBS "${MOZILLA_SDK}/../lib/libembedstring.a -L${MOZILLA_SDK}/../bin -L${MOZILLA_SDK}/../lib/ -lxpcom -lnspr4 -lplds4 -lplc4"
setenv XULRUNNER_INCLUDES "-include ${XULRUNNER_SDK}/include/mozilla-config.h -I${XULRUNNER_SDK}/include"
setenv XULRUNNER_LIBS "-L${XULRUNNER_SDK}/lib -lxpcomglue"
Comment 17 Andrew Overholt CLA 2009-03-20 17:13:45 EDT
Created attachment 129503 [details]
another potential patch to build.sh

(In reply to comment #16)
> When we build swt's libs the following vars are set, maybe these would help?

Oh, I was assuming you used build.sh.

> setenv XULRUNNER_LIBS "-L${XULRUNNER_SDK}/lib -lxpcomglue"

This is where the difference lies.  The pkg-config file from xulrunner-devel has -lxpcomglue_s whereas you're using -lxpcomglue.
Comment 18 Andrew Overholt CLA 2009-04-06 17:08:39 EDT
(In reply to comment #17)
> > setenv XULRUNNER_LIBS "-L${XULRUNNER_SDK}/lib -lxpcomglue"
> 
> This is where the difference lies.  The pkg-config file from xulrunner-devel
> has -lxpcomglue_s whereas you're using -lxpcomglue.

I've been in touch with the xulrunner .pc maintainer and the "_s" in there may be incorrect.  If that is indeed the case then I'll provide a patch to build.sh to use the pkg-config file but also to rebuild libswt-xpcominit.
Comment 19 Andrew Overholt CLA 2009-04-06 17:13:19 EDT
Created attachment 131059 [details]
build both libswt-xpcominit AND (libswt-xulrunner OR libswt-mozilla)
Comment 20 Andrew Overholt CLA 2009-04-06 17:14:13 EDT
Created attachment 131060 [details]
work around libxul.pc having -lxpcomglue_s and not -lxpcomglue

This patch is just to show how I'm currently planning to work around the libxul.pc issue until it's fixed.
Comment 21 Andrew Overholt CLA 2009-04-06 19:33:07 EDT
FWIW I built 3.4.2 with the second patch (the one to workaround the libxul.pc _s issue) and it worked.  I got libswt-xulrunner and libswt-xpcominit and the browser works.