Re: [Lazarus] Large program size - 1.8 MB for empty GUI project (uses clause in initialization vs implementation?)
Florian Klaempfl пишет: This could be simply the influence of a different memory layout of the exe. It seams that I was wrong. So. Lets do next small test. The main program is: program small_test; {$mode objfpc}{$H+} uses Unit1; begin Print_Hello_Word; end. Uni1.pas is: Unit unit1; {$mode objfpc}{$H+} Interface Uses Graphics, SysUtils; Procedure Print_Hello_Word; Implementation Procedure Print_Hello_Word; Begin WriteLN('Hello, word! Value is: '+IntToStr(23)); End; end. As you see - Graphics unit is really unused here. Compiler is called this way: #!/bin/bash ppc386 -Mfpc -CX -OpPENTIUM -TLinux -Pi386 -XX -Xs -vewnhim -Fu. -Fu/usr/share/lazarus/ideintf/units/i386-linux/ -Fu/usr/share/lazarus/lcl/units/i386-linux/ -Fu/usr/share/lazarus/lcl/units/i386-linux/gtk2/ -Fu/usr/share/lazarus/packager/units/i386-linux/ -FU/tmp/ -o/tmp/small_test "./small_test.pas" So - the code is Smart Linkable (-CX), the symbols are stripped (-Xs) and binary should be linked Smart (-XX). As a result we will see binary file with the size of 1 MB. ;) Without Graphics in Uses section we will see binary with the size of 75KB. Actually - no matter where Graphics unit is listed - the size will be 1MB both for Interface and Implementation sections. So. The conclusion is: Smart Linking process can not remove unused unit code. No matter where it is listed - ether in Interface section or in Implementation section. And we should check all our sources to cleanup unused units manually. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Large program size - 1.8 MB for empty GUI project (uses clause in initialization vs implementation?)
Vincent Snijders пишет: No, the initialization section of the graphics unit and its dependencies is used. The lesson is: you cannot smart link away initialization (and finalization) sections of a unit. Vincent But result is very understandable - if we have some unused units (with Initialization section) listed in "Uses" - our code can be 10 times bigger! IMHO - this is main question of the subject of the discussion - "Large program size - 1.8 MB for empty GUI project". So. Ones more - to reduce Lazarus-aware projects code size we shall first check and cleanup "Uses" sections to remove unused units, and next - test Initialization and Finalization sections. Do we really need them? For the Dephi times I remember that those sections were strictly optional and even deprecated. May be there are some other way to initialize global vars and structures? Regards, Alexey. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Large program size - 1.8 MB for empty GUI project (uses clause in initialization vs implementation?)
Florian Klaempfl пишет: Alexey S. Smirnov schrieb: This could be simply the influence of a different memory layout of the exe. Yes, potentially... But, please - explain - why compiler can simply detect and remove unused Unit from Implementation section and NEWER do that for Interface section? ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Large program size - 1.8 MB for empty GUI project
Graeme Geldenhuys : On Fri, Apr 3, 2009 at 3:02 AM, Paul Ishenin i...@kmiac.ru wrote: Felipe Monteiro de Carvalho wrote: And this has been debated 1 million times before, please search in the mailling list archives. This also means that problem of big executable size worries developers. Maybe we need to research more how to make our executables smaller. Especially so if you are targeting embedded devices, smartphones etc... Size matters in this case, but not so much for desktop applications. SmartLink problem is quite simple. It seems that all units, mentioned in "Interface-Uses" section will be fully linked. Only units mentioned in "Implementation-Uses" section can be checked during SmartLink. So, to enhance linking process and to reduce binary size we shell check all Interface sections of all LCL units to reduce units list. I try to do so. As a result I had received a binary with 15% less size then before. All functionality remains the same. First off all the good idea is NOT to add SysUtils unit automatically to Interface Uses section. If there (in SysUtils) are some definitions that are actual and widely used - may be it is better to split them to separate Unit. Regards, Alexey. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus