comp.lang.ada
 help / color / mirror / Atom feed
From: Tero Koskinen <tero.koskinen@iki.fi>
Subject: Re: Reducing the size of executables produced by GNAT
Date: Wed, 13 Feb 2008 19:34:22 +0200
Date: 2008-02-13T19:34:22+02:00	[thread overview]
Message-ID: <20080213193422.85039cf0.tero.koskinen@iki.fi> (raw)
In-Reply-To: 40e9c01a-8d31-4554-9d9b-18cce7834d56@s12g2000prg.googlegroups.com

On Wed, 13 Feb 2008 03:52:49 -0800 (PST) Hibou57 wrote:
> I'm afraid of what it means : take long to initialize at startup ? (I
> need fast application, for CGI on a Linux server), many unusefull
> dependencies on external library ? etc, etc

Like others suggested, look at AWS. It is a fast web server, much
faster than normal http-server + CGI app combination.

> to do it (strange...). I've tryed to compile with "pragma
> No_Run_Time", 

Here is simple example which uses C runtime instead of Ada runtime
for output:
==snip==
pragma No_Run_Time;
with Interfaces.C; use Interfaces.C;

procedure Hello is
   procedure Puts (Str : Char_Array);
   pragma Import (C, Puts, "puts");
begin
   Puts ("Hello, World!");
end Hello;
==snip==
Compile it using command:
$ gnatmake -Os hello
or:
$ gnatmake -Os hello -largs -static
(add -lc if needed)

On OpenBSD/i386 with GCC 4.3 I get following sizes (after strip):
-rwxr-xr-x  1 tkoskine  tkoskine   5752 Feb 13 19:21 hello.dynamic
-rwxr-xr-x  1 tkoskine  tkoskine  75908 Feb 13 19:17 hello.static

Normal hello using Ada.Text_IO and full Ada runtime:
-rwxr-xr-x  1 tkoskine  tkoskine  91140 Feb 13 19:32 hello.normal.dynamic
-rwxr-xr-x  1 tkoskine  tkoskine  210088 Feb 13 19:32 hello.normal.static

On Linux system you probably get smaller binaries, because OpenBSD
includes all kinds of magical buffer overflow protection stuff into
binaries.

But like you noticed without runtime your life gets harder.
It is easier to just use full Ada runtime. My AWS binaries
have been from 1.5M to 3M and you should be able to fit that
on any modern system with a network connection.

-- 
Tero Koskinen - http://iki.fi/tero.koskinen/



  parent reply	other threads:[~2008-02-13 17:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-13 11:52 Reducing the size of executables produced by GNAT Hibou57
2008-02-13 14:38 ` Martin Krischik
2008-02-13 20:03   ` Hibou57
2008-02-13 20:25     ` Pascal Obry
2008-02-13 21:41       ` Maciej Sobczak
2008-02-13 23:35         ` Ludovic Brenta
2008-02-13 20:37     ` tmoran
2008-02-14 10:12       ` Georg Bauhaus
2008-02-14 11:07         ` Ludovic Brenta
2008-02-14 22:07           ` Hibou57
2008-02-15  0:19             ` Robert A Duff
2008-02-13 21:27     ` Gautier
2008-02-13 22:14       ` Hibou57
2008-02-14 10:34         ` Georg Bauhaus
2008-02-14 10:53         ` anon
2008-02-15  5:52         ` Randy Brukardt
2008-02-15  5:52         ` Randy Brukardt
2008-02-15  5:52         ` Randy Brukardt
2008-02-19  0:41           ` Hibou57
2008-02-13 14:50 ` gautier_niouzes
2008-02-13 15:41   ` Pascal Obry
2008-02-13 15:52 ` Ludovic Brenta
2008-02-13 16:19 ` anon
2008-02-13 16:28   ` Pascal Obry
2008-02-13 17:34 ` Tero Koskinen [this message]
2008-02-13 21:32 ` Jeffrey R. Carter
2008-02-14  6:58 ` Jacob Sparre Andersen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox