From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20248 invoked by alias); 24 Sep 2009 15:41:45 -0000 Received: (qmail 20232 invoked by uid 22791); 24 Sep 2009 15:41:44 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail3.caviumnetworks.com (HELO mail3.caviumnetworks.com) (12.108.191.235) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Sep 2009 15:41:41 +0000 Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535) id ; Thu, 24 Sep 2009 08:38:44 -0700 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 24 Sep 2009 08:38:08 -0700 Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 24 Sep 2009 08:38:08 -0700 Message-ID: <4ABB925D.8080605@caviumnetworks.com> Date: Thu, 24 Sep 2009 15:41:00 -0000 From: David Daney User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: "l.civinini@libero.it" CC: Andrew Haley , gcc-help@gcc.gnu.org, java@gcc.gnu.org Subject: Re: About static linking with gcj References: <27986041.3148981253797792277.JavaMail.root@wmail18> <4ABB88D9.3050809@redhat.com> In-Reply-To: <4ABB88D9.3050809@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg00029.txt.bz2 Andrew Haley wrote: > l.civinini@libero.it wrote: >> Hi all, >> I'm trying to make static linking in order to obtain a java executable >> to use on a device with few hardisk space. >> I created a simple java that made >> only a "System.out.println" and after c >> ompiling I obtained am executable file >> of 29 MB. Is it possibile to >> shrink the size of executable? Am I doing >> something worng? >> This is the command that I'm using. >> >> gcc -o Foo Foo.o Foomain. >> i -shared-libgcc -Wl,-non_shared -lgcj -Wl,-call_shared -lsupc++ -Wl,--as- >> needed -lz -lgcc_s -lpthread -lc -lm -ldl -Wl,--no-as-needed > > It's difficult. The nature of the Java library is such that a lot of > stuff is required, and you'll find it gets linked in. SOme folks on the > gcc list have done work in this area, but it's tricky. > You can use -static-libgcj since GCC-4.2. Also you can try the patches I posted to java-patches@ recently to try to reduce the size of the statically linked applications. The best I have been able to achieve on GCC-4.3.4 is about 10MB. David Daney