Reducing static binary sizes
Andrea aime
andrea.aime@aliceposta.it
Tue Jan 10 22:22:00 GMT 2006
Andrew Haley wrote:
>> Please paste what you did with the compiler output; we need detail.
Here we go. First I shrinked everything with gcclass:
> java -cp bcel-5.1.jar;gcclass.jar com.brian_web.gcclass.GCClass
=libgcj-4.0.0.jar;swt.jar;org.eclipse.core.runtime_3.1.1.jar;org.eclipse.jface_3.1.1.jar;explorer.jar;org.eclipse.core.commands_3.1.0.jar;org.eclipse.osgi_3.1.1.jar;org.eclipse.core.expressions_3.1.0.jar
out explorer_12.Explorer.main
> jar c out/* > out.jar
which really means, take these jars (libgcj.jar included), strip
out everything is not needed by the explorer_12.Explorer.main method
and put the rest in the out folder, then jar it for gcj to use.
Then I've tried with the following:
> gcj -fjni -findirect-dispatch -nostdlib -lmingw32 -lmoldname
-lmingwex -lmsvcrt -lm -liconv -lgdi32 -lws2_32 -lmingw32 -lmoldname
-lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32
-lgcc -lmoldname -lmingwex -lmsvcrt out.jar --main=explorer_12.Explorer
-o jfex
gcj: libgcj.spec: No such file or directory
Uh oh... what's that spec file? Ok, I searched for it and found one in
gcc-4.0\i686-pc-mingw32\lib, whose contents are:
#
# This spec file is read by gcj when linking.
# It is used to specify the standard libraries we need in order
# to link with libgcj.
#
%rename lib liborig
*lib: --start-group -lgcj --whole-archive -lswtimgloader
--no-whole-archive --end-group -lm -liconv -lgdi32 -lws2_32
%(libgcc) %(liborig)
*jc1: -fhash-synchronization -fuse-divide-subroutine -fcheck-references
-fuse-boehm-gc -fnon-call-exceptions -fno-omit-frame-pointer
-fkeep-inline-functions
So I've tried to refer to it by hand with:
> gcj -specs=..\..\gcc-4.0\i686-pc-mingw32\lib\libgcj.spec -fjni
-findirect-dispatch -nostdlib -lmingw32 -lmoldname -lmingwex -lmsvcrt
-lm -liconv -lgdi32 -lws2_32 -lmingw32 -lmoldname -lmingwex -lmsvcrt
-luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname
-lmingwex -lmsvcrt out.jar --main=explorer_12.Explorer -o jfex
gcj: libgcj.spec: No such file or directory
??? The file is there, I've checked the path...
I've also tried to copy the spec file into the working directory,
but apparently this breaks my gcj install and I end up with the "cannot
find jc1.exe ..." message...
What should I do? I've tried to read the online docs
(http://gcc.gnu.org/onlinedocs/gcj/), but there is no mention of spec
files...
Best regards
Andrea Aime
More information about the Java
mailing list