Skip to main content

Buidling phoneme as a shared library

3 replies [Last post]
dfoteinakis
Offline
Joined: 2007-12-05

Hello,
I'm trying to build phoneme foundation as a shared library.
The approach i'm taking currently is to use ld to link the generated object files into a shared library.

gcc -shared -fPIC -o obj/libmala.so --export-dynamic obj/*.o -lpthread -ldl -lm

My problem is after launching the cvm, via an external application invoking ansiJavaMain, i get a signal 11. I traced that problem in the initialization of Class
(runStaticInitializers method).

I'm wondering if there is a specific method or linker options that are needed in order to build phoneme as a shared libary.
Should the above method work? Or is there something in phoneme that will not work as a shared library?

Thanks for any help,
Dimitris

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cjplummer
Offline
Joined: 2006-10-16

Building CVM as a dll is not supported, but you might be able to get it to work. If you are on MIPS, you'll first need to apply the following patch:

http://forums.java.net/jive/thread.jspa?messageID=232147&#232147

Make sure you get the formatting correct. A previous user had spaces after the backslash (\) line continuation character, which messed up the macro.

Chris

dfoteinakis
Offline
Joined: 2007-12-05

Thank you very much Chris.

With the patch phoneme works as a library smoothly up to now.
I believe that the crucial thing was the -fno-unit-at-a-time flag in GNUMakefile.

cjplummer
Offline
Joined: 2006-10-16

-fno-unit-at-a-time seems to have the beneficial side affect of restoring %gp after every function call. I've looked at the -fno-unit-at-a-time documentation and there is nothing in its description that indicates it should do this. MIPS code only needs to restore %gp after a function call if the callee needs it again, and you do see cases of it not getting restored when you don't use -fno-unit-at-a-time.

The JIT generates code that will clobber %gp. However, since with -fno-unit-at-a-time it seems to always gets restored, this gets around the problem of JIT code clobbering %gp, and never restoring it. This is a somewhat fragile fix, and could break if the mips code generator stops being so kind about %gp restoration. The proper fix involves a lot of changes in the MIPS ccm glue assembler functions so they properly save and restore %gp.

Chris