From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cd7d510783cb3f76 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Executable File Size Differences Date: 1996/10/11 Message-ID: #1/1 X-Deja-AN: 188627497 references: <52bmn5$7r0@sjx-ixn6.ix.netcom.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-10-11T00:00:00+00:00 List-Id: I said: > Note that with dynamic linking and first reference traps or a > similar mechanism, all the pain goes away, and you can have an > executable for Hello World that is under 50 bytes--in any language. In article John Howard writes: > We can always benefit from smaller executables. And we need the option to > share DLL's. But we should not have to use a DLL in order to quote a > smaller size for an executable... No DLL in sight! The trick is that with first reference traps all the (Text_IO) variables never referenced in this program are actually initialized by the first reference traps. The compiler front-end may generate code to update all this junk (column number, line number, page number, etc.), but since there are no visible references, the compiler backend can (and will) delete all the assignments to them. Now all we are left with is a single in-lined system call to write a string literal to standard out. Actually, hmmm... with System; procedure Syswrite is use System; procedure system(X: in Address); pragma Interface(C, system); Temp: String(1..20) := "echo ""Hello World!""" & Ascii.Nul; begin System(Temp'Address); end Syswrite; with Text_IO; procedure Hello is begin Text_IO.Put_Line("Hello World!"); end Hello; SunAda (VADS): -rw-r--r-- 1 eachus 226 Oct 10 19:37 syswrite.a -rw-r--r-- 1 eachus 85 Oct 10 19:43 hello.a -rwxr-xr-x 1 eachus 81920 Oct 10 19:40 SYSWRITE -rwxr-xr-x 1 eachus 270336 Oct 10 19:44 HELLO GNAT 3.05 on SunOS 4.1.3: -rw-r--r-- 1 eachus 219 Oct 10 20:15 syswrite.adb -rw-r--r-- 1 eachus 93 Oct 10 20:01 hello.adb -rwxr-xr-x 1 eachus 65536 Oct 10 20:15 syswrite -rwxr-xr-x 1 eachus 286720 Oct 10 20:05 hello (Slight differences in sources sizes are because I eliminated the constraint on Temp and added "Ada." to Text_IO for GNAT. Force of habit. ;-) Well there is a lot of extra stuff in there still. Anyone want to try some more? -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...