Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: How to build a static application binary?
Date: Sat, 04 Dec 2010 05:27:51
Message-Id: idcjd1$aeo$1@dough.gmane.org
In Reply to: Re: [gentoo-user] Re: How to build a static application binary? by Alan McKinnon
1 On 2010-12-03, Alan McKinnon <alan.mckinnon@×××××.com> wrote:
2 > Apparently, though unproven, at 00:37 on Saturday 04 December 2010, Grant
3 > Edwards did opine thusly:
4 >
5 >> On 2010-12-03, David W Noon <dwnoon@××××××××.com> wrote:
6 >> > What you are seeing is a lot of glibc routines being included by the
7 >> > linkage editor. These handle all sorts of conditions that will
8 >> > likely never occur in your program.
9 >> >
10 >> > Try using a smaller C library, like uclibc or klibc. They might not
11 >> > work as well, but they will give you a smaller executable.
12 >> >
13 >> > Alternatively, try rewriting your code in assembler.
14 >>
15 >> For various reasons (which I doubt anybody cares about), gritting my
16 >> teeth and living with the 520K per application looks like a more
17 >> practical solution that either using assembler or a different libc.
18 >>
19 >> In practice, I'm sure nobody but me will ever even notice (or care
20 >> even if they did notice) the wasted 2MB on a 25MB liveCD. But it will
21 >> still bug me. :/
22 >
23 > That's 8% of your space resources.
24
25 It's closer to 0.5%. My space resources are 700MB on the CD and
26 probably at least 512MB of RAM. Right now I'm using up about 22MB of
27 the space on the CD, and less than that in RAM. By the time I'm done,
28 it will probably be around 25MB. Anything that boots from a single CD
29 in under 15 seconds and runs in 512MB of RAM or more will be fine. The
30 difference between 23MB and 25MB really won't be noticable.
31
32 > Many more than just you will notice and care and whinge loudly.
33 > Probably including me.
34
35 Well, I think you'd find it pretty useless no matter how small/fast it
36 was. The only thing it's able to do is production test and
37 diagnostics for a family of PCI boards I support.
38
39 > It might be worth the effort to switch to a libc designed for the
40 > sort of task you want to accomplish. I assume you already made the
41 > effort with busybox or similar, it's much the same viewpoint.
42
43 Sort of. I'm using busybox, but the "base" of my CD is generated by a
44 shellscript that strips down a systemrescuecd ISO image to the bare
45 essesntials (basically just what's required to run a 7MB initrd image
46 containing busybox). Then I add my three or four static applications
47 to that. We used to build our own CD from scratch, but that build
48 process was fragile and hard to maintain.
49
50 The CD doesn't even have network support or drivers for any block
51 devices except a ramdisk (no SCSI, SATA, ATA, and so on). The only
52 filesystem it supports is cramfs. I ripped out USB support also, but
53 then had to put enough of it back in for the USB keyboards on some of
54 the machines where it'll be used.
55
56 It'll still bug me that those static apps are 90% bloat, but it's just
57 not worth the effort to switch to uClibc or mess with putting my own
58 dynamic libraries onto the CD.
59
60 --
61 Grant