[fpc-devel] Delphi smart-linking perspective ( Language change and implementation ... )

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Jun 5 17:32:47 CEST 2009

On 31 May 2009, at 11:35, Jonas Maebe wrote:

> On 31 May 2009, at 10:38, Paul Ishenin wrote:
>> Jonas Maebe wrote:
>>> Yes, we made a refactoring and as result empty form + button  
>>> application weights 200Kb less now. Can you check, maybe now WPO  
>>> results can be more impressive?
> Still quite minimal results.

I've now added support for removing not called virtual methods  
(similar to the {$ifdef vtentry} code in the compiler, but fixed so it  
also works for the lcl/lazarus). It removes a bit more, but still not  
very much. Here are the file sizes of iterative compilations using wpo  
of the above mentioned test program and the lcl (so no recompilation  
of the rtl or fpc packages) until nothing changes anymore:

$ ls -l button-?b
-rwxr-xr-x  1 jmaebe  admin  1711656 Jun  5 17:10 button-1b
-rwxr-xr-x  1 jmaebe  admin  1687020 Jun  5 17:10 button-2b
-rwxr-xr-x  1 jmaebe  admin  1657604 Jun  5 17:10 button-3b
-rwxr-xr-x  1 jmaebe  admin  1653428 Jun  5 17:10 button-4b
-rwxr-xr-x  1 jmaebe  admin  1649280 Jun  5 17:10 button-5b
-rwxr-xr-x  1 jmaebe  admin  1648928 Jun  5 17:10 button-6b
-rwxr-xr-x  1 jmaebe  admin  1648928 Jun  5 17:10 button-7b
-rwxr-xr-x  1 jmaebe  admin  1648928 Jun  5 17:10 button-8b
-rwxr-xr-x  1 jmaebe  admin  1648924 Jun  5 17:10 button-9b

All programs are stripped. As you can see, wpo can now remove about  
61kb (before, wpo gained 8kb). Still not very much. The reason that  
you need several iterations to get all possible savings, is that the  
compiler only records calls to virtual methods from code that is  
included in the final program. So removing a method may cause some  
other methods to be no longer from anywhere, etc.

It should be possible to do this during one run by keeping the  
information per method instead of per unit, but that would increase  
the ppu size quite a bit.

For lazarus itself, it's:
$ ls -l lazarus-?b
-rwxr-xr-x  1 jmaebe  admin  9181256 Jun  5 17:13 lazarus-1b
-rwxr-xr-x  1 jmaebe  admin  9070132 Jun  5 17:13 lazarus-2b
-rwxr-xr-x  1 jmaebe  admin  9040948 Jun  5 17:13 lazarus-3b
-rwxr-xr-x  1 jmaebe  admin  9032640 Jun  5 17:13 lazarus-4b
-rwxr-xr-x  1 jmaebe  admin  9028436 Jun  5 17:13 lazarus-5b
-rwxr-xr-x  1 jmaebe  admin  9023984 Jun  5 17:13 lazarus-6b

So savings of about 153kb (before, wpo gained about 70kb).

It's not yet committed, because there are still some compiler crashes  
when recompiling units after my changes, similar to http://bugs.freepascal.org/view.php?id=13323


More information about the fpc-devel mailing list