This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static executables


Tom Tromey wrote:
"Andrzej" == Andrzej Bialecki <ab@getopt.org> writes:

Andrzej> The question is: is it possible to build static binaries on Linux/BSD, Andrzej> and if yes, what is the right incantation to do this, for input files Andrzej> consisting of a mix of *.java, *.jar, and JNI *.o objects? Eg. if I'm Andrzej> using Fedora Core 4, which sports gcc 4.0.2, whenever I try to pass Andrzej> the -static flag, the compiler complains that static compilation is Andrzej> not supported.

Funny, I didn't realize that this error was in there.
I don't remember this decision.

Andrzej> * it's not supported, because it's broken in some well-defined cases

Any code that uses reflection will not work properly. This is a
problem because parts of the core class library depend on reflection.
For instance, character set translators and locales are loaded this
way.

Ugh, that's pretty serious ... Ok, then this means that it's not possible to redistribute binaries to machines where there is no runtime installation. :-( Or at least not as a single file. For me it was one of the expected major advantages of gcj over the standard JVM, but unfortunately that's not the case...


You can work around this by explicitly linking in the ones you need,
but you need to know some internal details of libgcj to make this
work. We've talked occasionally of adding compiler options to make
this simpler, but nobody has done that yet.

If I were to have the libgcj.a (I don't think it's installed by default), could I pick by hand some of the .o files from it and explictly tell the linker to keep all symbols from those files? Would it work then? Or keep all symbols from the whole libgcj (and tell linker to ignore duplicates), would this work?


It would be helpful if someone wrote a page for the gcc wiki about
static linking.

Yes, please ...


--
Best regards,
Andrzej Bialecki     <><
___. ___ ___ ___ _ _   __________________________________
[__ || __|__/|__||\/|  Information Retrieval, Semantic Web
___|||__||  \|  ||  |  Embedded Unix, System Integration
http://www.sigram.com  Contact: info at sigram dot com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]