[fpc-pascal]General Question on code optimization...

Peter Vreman peter at freepascal.org
Tue Oct 7 18:11:28 CEST 2003


>
> Shouldn't FreePascal automatically skip all code which is not
> required/used?
> Especially in a procedural environment it should be relatively easy to
> find
> out at compile time, which functions/procedures are used or not.
> So the compiler should be able -- especially when the unit source is
> present
> -- to build code which only contains that what is really used. Isn't it?

This is done by the linker which is external. We can only create libraries
that contain an object file for each procedure and variable

>
> Instead, the compiler/linker/whatever seems to process the whole unit,
> regardless if portions of it are not used, and something drops over a
> problematic procedure even if this is not used at all! :-/
>
> Does FPC include a whole unit with hundreds of procedures if I use only
> one
> (or none) of them? This would not be very smart!

There is smartlinking to create libraries that contain small object files.
You can create the libraries with -CX. And you tell fpc to pass them to
the linker with -XX






More information about the fpc-pascal mailing list