Subject: | undefined symbol: js_InternalInvoke when using libmozjs from xulrunner |
Hi,
I'm packaging the Javascript module for Debian, and there's a linker
error with 1.03 when running 'make test':
t/00-init.........................
# Failed test 'use JavaScript;'
# in t/00-init.t at line 5.
# Tried to use 'JavaScript'.
# Error: Can't load
'/tmp/buildd/libjavascript-perl-1.03/blib/arch/auto/JavaScript/JavaScript.so'
for module JavaScript:
/tmp/buildd/libjavascript-perl-1.03/blib/arch/auto/JavaScript/JavaScript.so:
undefined symbol: js_InternalInvoke at /usr/lib/perl/5.8/DynaLoader.pm
line 225.
I have looked into this, and the problem as I understand it is that
Javascript.xs is using js_InternalCall(), which is not part of the
public API of libmozjs. (The js_InternalCall() function is #define'd as
js_InternalInvoke() in <mozjs/js_interph>, hence the linker error message.)
Now, the Debian libmozjs comes from the xulrunner package:
http://ftp.mozilla.org/pub/mozilla.org/xulrunner/
which contains a copy of the same code as
ftp://ftp.mozilla.org/pub/js
but with one notable difference: the xulrunner build system hides all
library symbols by default, unless they are declared as public. This
comes from config/gcc_hidden.h in the xulrunner package:
#pragma GCC visibility push(hidden)
which is more or less the same as compiling with "gcc -fvisibility=hidden".
Since js_InternalCall() (or js_InternalInvoke()) is not a public symbol,
it's not exported from libmozjs.so (as seen with eg. objdump -T) and the
result is the linker error.
I don't know much about mozjs internals, but it seems to me that the
right fix is to use only the symbols declared as JS_PUBLIC_API (or maybe
JS_FRIEND_API, I don't know) in the headers.
Version numbers: this has been researched with xulrunner 1.8.0.11, which
is apparently not an official release but just a release tag in the
mozilla CVS repository. I did look at 1.8.0.4, which is available as an
official released tarball, and I don't see any difference in this
regard. I haven't actually tested this against anything else than
1.8.0.11, though.
The mozjs version inside xulrunner 1.8.0.11 seems to be 1.60, according
to jsconfig.h .
Hope this makes sense. Please let me know if you need more information,
and I'll do my best to help.
Thanks for your work on the Javascript module,
--
Niko Tyni (on behalf of the Debian Perl Group)
ntyni@iki.fi