On 12/22/2011 12:14 AM, Jonathan M Davis wrote:
On Thursday, December 22, 2011 00:05:58 Walter Bright wrote:
We must deal with our imperfect tools as they are. For example, I am not
going to rewrite the Linux ld linker, and the OSX linker, and the FreeBSD
linker, etc.
If the compiler and/or linker don't strip unused symbols, then how on earth is
importing the module _not_ going to pull in everything in it save for
uninitialized templates?
There are data that needs to be there, but is never symbolically referenced, for
example, the exception handler tables. The compiler does the best it can, like
emitting one object file per function, but it always must behave conservatively.
The elf object file format isn't going to change, we aren't going to rewrite the
gnu linker, nor will we rewrite the back ends of gcc and lcc.
There isn't any one simple rule to avoid unnecessary bloat, the only way is to
get somewhat familiar with how things work. For example, using 'class' as a
namespace generates a useless vtbl[] and a typeinfo instance, and in the future
will generate useless reflection data. It's better to use a module as a
namespace, as that is what it is designed for.
The most important thing is to design the boxes around the various units of
functionality such that there are minimal lines between those boxes. For
example, if I want to see if one file is newer than another (like for a make
program), it should not pull in timezone processing or date formatting code.