Tell the ignorant folks (like me) about smartlinked LCL.
If you're working with Lazarus on Windows, you might try some real-world tests on your own code by compiling from a batch file rather than the IDE and do the following 3 things:
- Don't use -gl switch with FPC.
- Use the new internal linker (-Xi switch).
- Use the -vx switch so the compiler displays the amount of code generated (like Delphi does).
Here's my results:
Example 1. Console app, over 20,000 lines of code:
Delphi 7: Compile and link time: Less than 1 sec.
FPC: Compile and link time: About 2 secs. Link only: 0.5 sec. [These are huge improvements over the external GNU linker.]
Delphi 7 code: 260K
FPC code: 304K
Delphi 7 .exe: 286K
FPC .exe: 296K
[When zipped (to simulate the way software is distributed) the difference in file size is only about 25K.]
No hacks, no rebuilding of Laz, no strip, no UPX, just using FPC properly.
Example 2: GUI app, over 100,000 lines of code.
Delphi 7: Compile and link time: less than 1 sec.
FPC: Compile and link time: 6 secs. Link only: Only 2 secs!
Delphi 7 code: 1,220K
FPC code: 1,549K
Delphi 7 .exe size: 1,554,432
FPC .exe size: 2,248,300
What can be concluded from these examples?
(1) It's not really a problem with the compiler, but with the external linker. If the internal linker becomes available for all platforms, speed and code size will be improved dramatically overnight.
(2) Since LCL is structured differently (multiple layers) than Delphi's VCL in order to be cross-platform, it shouldn't be surprising that more code gets dragged into the app. Offhand it looks like an LCL app adds about 200-300K more code (not .exe file size) over VCL. With non-trivial apps, this doesn't strike me as anything to worry about.
(3) Perhaps a better measure than code or .exe size would be the memory footprint of the app. FPC compares fairly well here too:
Example 2 above, started but no other activities performed by user:
Delphi 7 version: 5,652K footprint (according to Task Manager)
FPC version: 6,952K footprint
So about 1.3MB larger memory footprint for the LCL app. It's hard to say exactly what causes the difference since so many things can affect an app's memory use, but on my machine I have 1 GB RAM so this difference again seems almost trivial.
Compare the results above with, say, a good sized app compiled with GCC (GNU Compiler Collection), where compile and link times are so slow that you can get in a nap between builds.