From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <990bf6d77ac4862d05e894abb314ebc7@hamnavoe.com> To: 9fans@cse.psu.edu Subject: Re: [9fans] Install from CD fails From: Richard Miller <9fans@hamnavoe.com> Date: Tue, 18 Apr 2006 21:21:34 +0100 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 3d0b5b50-ead1-11e9-9d60-3106f5b1d025 >> There were linkers written, long ago, that would extract only the code >> from a library that was used by a program, and the binary got pretty > > we do that in inferno's 5l. richard miller implemented it originally in 5l There may be a small misunderstanding here. The change I made in 5l was to discard all unreachable code, whether it came from a library object file or from the main program. It was mostly useful for tidying up programs which had been evolving for a while, when the authors hadn't bothered to delete functions which were no longer used. But that wouldn't help with what Russ described: > Much of the bloat is from library routines > that don't actually get called in practice > but end up linked into every binary anyway > (like the formatters for %e, %f, and %g). The floating point format routines are always reachable if you use any functions of the print() family, because they're in the list of built-in formats (/sys/src/libc/fmt/fmt.c:39,41). There's no way to determine statically at link time that they won't be called at runtime, because format strings might be constructed dynamically or even read in. There was a hack in some early Unixes to solve this particular instance of the problem: the C compiler would generate an external reference to pull in a "special" version of printf from the library -- the one with calls to floating-point conversion routines -- if any floating-point instructions were generated during the compilation. If none of your program's object files contained this reference, then you would get the integer-only printf. This was in 1978 or so when memory footprint really made a difference -- e.g. we ran a timesharing lab with 7 terminals on an Interdata minicomputer with 192 kilobytes of RAM and two 5-megabyte hard disks. -- Richard