> > Yes, I speak about static linking, because It is what we have in > > sbase, so dynamic linking is outside of this discussion (ant it is > > not suckless :P). And maybe compilers are smarters, but the link > > process is the same. Try it and you will see it. Even if you find > > some too much smart linker that does it, you are doing something > > wrong and requiring a more complex toolchain. I hope we will > > not have to implement this kind of linkers some day ;). > > > > Again, try it. > > just for the record, as discussed in IRC you are right about it. > Apparently, compilers are not as smart as I had in mind previously. > Going the separate approach is a good thing, so I welcome this > suggestion!
I can't speak for all compilers, but afaik gcc does support the optimization I think you are talking about: take a look at gcc's -fdata-sections and -ffunction-sections as well as ld's --gc-sections. At least I remember that some time ago I tested this and only functions used were actually linked in. Kind regards Julian