Re: dead-code stripping, is it possible?
Re: dead-code stripping, is it possible?
- Subject: Re: dead-code stripping, is it possible?
- From: Ken Turkowski <email@hidden>
- Date: Wed, 2 Jun 2004 10:04:38 -0700
On Jun 2, 2004, at 8:49 AM, Jim Ingham <email@hidden> wrote:
On Jun 1, 2004, at 4:17 PM, Marshall Clow wrote:
Is it possible to have the linker strip dead code? Is there an
option to enable this?
Usually, there isn't any dead code to strip.
I believe you are mistaken.
As people build up libraries of useful functions, they tend to link
against these libraries. Many times they only need a small fraction
of the functions in these
libraries, and many of us, like the OP, expect(ed) the linker to
remove the unused functions from
the final binary.
This is not a comment either way about the merits of dead code
stripping, but just a clarification.
The static linker does perform "unused code stripping" on the level of
a module already. If you link a library into an app that doesn't use
any of the functions from a particular .c file, then the linker will
omit that module from the final link. So if you get used to keeping
the .c files in your libraries small and focused, then there won't be
much dead code to strip.
Of course, if you always had a linker that dead-code stripped, there
would be no motivation to do this, and so you will end up with lots of
dead code that gets included...
How can there be any advantages to NOT stripping dead code? This seems
like a real no-brainer, and is advantageous for many reasons:
(1) the disk footprint is smaller
(2) the memory footprint is smaller
(3) code runs faster because the currently running instructions all fit
in the cache.
The technique of object-oriented programming suggests that you
implement, usually in one module, all the functions that you can
possibly imagine for a particular data type, resulting in a lot of
unused functions when you link a particular application against the
library. Typically I only use 10-15% of the functions.
Why the step backwards? All of the Macintosh linkers prior to OS X
stripped dead code on a function basis, not a module basis. It's not
like this is breaking new ground in compiler technology.
-Ken Turkowski
--
Ken Turkowski email@hidden
Engineer/Scientist http://www.worldserver.com/turk/
Independent Consultant Industrial Grade Software
Computer Graphics 2D 3D Immersive Imagery
Photo-mosaicing Panoramas Computer Vision
Applied Mathematics Numerical Analysis Optimization
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.