Re: [Lazarus] Large program size - 1.8 MB for empty GUI project

2009-04-08 Thread Graeme Geldenhuys
On Tue, Apr 7, 2009 at 5:13 PM, Marc Weustink m...@dommelstein.net wrote:

 No, but the problem is caused by the way fpc stores info in the .ppu
 Somehow it is possible that the checksum of the interface part stored in
 the .ppu is affected by the implementation section.

Since I started using Lazarus (4+ years ago), I have only two had a
checksum issue compiling lazarus. A simple 'make clean' and then
recompile resolved the problem. But I actually think the issue was
caused due to a FPC upgrade - I can't remember exactly, but am pretty
sure.


 To avoid this and to make the LCL usabole as library, most unit circles
 were removed. One way to ensure that is by putting all uses in the
 interface section.

OK I'm confused. How does solving circular reference get resolved by
putting everything in the Interface section? Doing that is what causes
circular reference problems??  Maybe I understand circular reference
problems differently to you... this is what I mean:


{ this defines TClass1 }
unit Unit1;

uses
  unit2;

type
   TClass1 = class(TObject)
   private
  FRef: TClass2;
end;




{ this defines TClass2 }
unit Unit2;

uses
  unit1;

type
   TClass2 = class(TObject)
   private
  FRef: TClass1;
end;


=

Both classes require each other and can't be compiled. This is what I
understand as circular unit references.  To solve this you can lump
both class definitions in a single unit and add a 'forward
declaration' at the top.


 any issues. I limit the usage of interface uses clause as much as
 possible. I believed that is why the smartlinking works so well with
 fpGUI - I can create a GUI application that is only 340KB in size.

 Anyway, back to the subject, I cannot imagine why FPC when smartlinking
 makes a difference between interface and implementation uses. Especially
 if you use an external linker, like on linux.

OK, I worded that wrong. For smartlinking there shouldn't be any
difference if the unit is in the Interface or Implementation section.
What is important is if the unit is used or not. I think the reason I
can get such small executables, is because every gui component lives
in it's own unit. fpGUI doesn't have a StdCtrls or ComCtrls unit which
lumps a whole bunch of classes together. And when I create
applications I only add the units I really need. This is obviously
key.


Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
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

2009-04-08 Thread Bogusław Brandys
Sergei Gorelkin wrote:
 Mattias Gaertner wrote:
 
 Btw a little different question : what is needed to allow lineinfo 
 reading stack trace from external file (in case of exception) for 
 example of the name corresponding to exe name but with different 
 extension. FPC can now dump debug info into such separate file. Such 
 feature would be very useful as compilation option for example.
 Write a lineinfo unit that supports the external file.

 Isn't it already written? It looks like exeinfo.pp (unit shared by 
 lineinfo and lnfodwrf) supports this feature. Didn't test it though.
 However, it gets the name of debug info file from the debug section of 
 the executable, so the executable shouln't be stripped in this case.
 
 Regards,
 Sergei

That's great! Maybe it could be changed so if debug info filename is not 
found in debug section of executable then it tries to open a separate 
debug file generated by fpc (which can be of the same name as executable 
but different extension).

I must investigate this option.

Best regards
Boguslaw
___
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

2009-04-08 Thread Hans-Peter Diettrich
Graeme Geldenhuys schrieb:

 I thought this was known:
 http://wiki.lazarus.freepascal.org/DesignGuidelines
 
 This is the first I here of this.

Me 2.


 I have used FPC since 2.0.2 under Linux and Windows and haven't had
 any issues. I limit the usage of interface uses clause as much as
 possible. I believed that is why the smartlinking works so well with
 fpGUI - I can create a GUI application that is only 340KB in size.

Smartlinking is not directly affected by Uses. Instead it's most often 
the code in used unit Initzialization sections, that makes all related 
code part of the executable. E.g. when initialization code creates 
objects or references subroutines, that are not otherwise used by the 
application code, a smart linker cannot exclude that definitely 
referenced code.

Similarly virtual methods: they are referenced in the VMT, which again 
is referenced in every instance of the class. Consequently virtual 
methods must become part of the executable, as soon as a class typename 
is used in any way in an application. Static methods, in contrast, can 
be safely omitted when not referenced anywhere else. IMO.

DoDi

___
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

2009-04-08 Thread Paul Ishenin
Marco van de Voort wrote:
 How recently was this all validated to still be a problem? I know FPC didn't
 performed the (apparantly long due) unit system rewrite yet, but not that
 much problems in that realm are reported in mantis anymore, even for the
 current implementation.
   
And this one: http://bugs.freepascal.org/view.php?id=13478

Best regards,
Paul Ishenin.
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] USB Commincation with Lazarus and libusb library

2009-04-08 Thread Henry Vermaak
2009/4/8 Henry Vermaak henry.verm...@gmail.com:
 2009/4/8 Sébastien FLOURETTE sebastien.floure...@gmail.com:
 I try that you tell me but the result is not good.

 so what was the result of the libusb test program in c?  do you have
 permissions to use the device?


 Have you got an example of use libusb on Lazarus. Perhaps I have a
 parameters or other is not good.
 If you have can you send me it.

 i already pasted the relevant code, there's nothing else that's
 different in my code.  it works for me in linux.

 you might have to make a test program in c and ask for help on the libusb 
 list.

 henry


___
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

2009-04-08 Thread Bogusław Brandys
Paul Ishenin wrote:
 Bogusław Brandys wrote:
 That's great! Maybe it could be changed so if debug info filename is not 
 found in debug section of executable then it tries to open a separate 
 debug file generated by fpc (which can be of the same name as executable 
 but different extension)
 What for? If you want a separate debug info file (-Xg) then your 
 executable will contain a section with that file name. As result you 
 have a small executable. If you distribute that executable without debug 
 file it will work fine but without line info. If you distribute with 
 debug file then you will have lineinfo. What do you need more?
 
 Best regards,
 Paul Ishenin.
 ___

Wow,this is exactly what I want.Thank you.Is that really working ? I 
remember having problems with it - no source line info in stack trace 
output in case of external debug file.

Does stabs need to be loaded at program startup ? I would like it to 
work without need to loading debug info from this separate file at 
program start because this is a huge slowdown especially when antivirus 
is scanning file.Ideally it should load stabs only in case of exception 
or stack trace request.

Regards
Boguslaw
___
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

2009-04-08 Thread Reenen Laurie
2009/4/8 Alexey S. Smirnov betates...@rambler.ru:
 The Smart Link process should check what variables/functions/definitions are
 used in your project to cut off unused code. It is really simple to do so,
 if some units are listed in Implementation section - linker will only add
 unit functions that are mentioned in you code, not more.
 If units are listed in Interface section - it mean that potentially all
 code  from that particular unit should be included. Because your global
 variable/class should have access to all provided
 code/procedures/properties.

Marc Weustink (i think wrote):
 Just a note: some people think that units can be compiled in one pass -
 this is not true. The compiler must stop on every Uses clause, and

So .exe's should be (much) smaller if your uses units are put mostly
in implementation (not easy to find circular references), but we say
rather put it in interface?

If we have to do multipass why is it necessary to have a distinction
at all?  (Ok, because writing compilers isn't exactly a walk in the
park)...

___
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?)

2009-04-08 Thread Florian Klaempfl
Alexey S. Smirnov schrieb:
 Martin Friebe пишет:
 Is this documented somewhere? I can't follow the logic anyway, the scope 
 how much my code uses of another unit can not be predicted, simply by 
 where I include the other code?

 Actually, I do believe I have seen examples where code form units used 
 in the interface was successfully smart-linked.

 However there is a differentiation what can be smart linked and what 
 not. If a class has RTTI information, then methods from it can not be 
 removed by smart-linking. Classes with RTTI (afaik) are either included 
 as a whole or not at all. (And that make sense, because RTTI allows to 
 access any method by finding it from a resource or literal string; which 
 are both not parsed by the compiler, and therefore not determinable)

 Best Regards
 Martin

   
 
 May the problem will become understandable, if we will do a little
 experiment. So. Let's test the Interface/Implementation Uses sections of
 /lazarus/lcl/graphics.pp. This section for Lazarus 0.9.26 was that:
 |interface
 uses
   SysUtils, Math, Types, Classes, Contnrs, FPCAdds,
   FileUtil,
   FPImgCmn, FPImage, FPCanvas,
   FPReadPNG, FPWritePNG, PNGComn,  // png support
   FPReadBMP, FPWriteBMP,   // bmp support
   FPReadPNM, FPWritePNM,   // png support
   FPReadJpeg, FPWriteJpeg, // jpg support
   IntfGraphics,
   AvgLvlTree,
   LCLStrConsts, LCLType, LCLProc, LMessages, LCLIntf, LResources,
 LCLResCache,
   GraphType, IcnsTypes, GraphMath, InterfaceBase, WSReferences;|
 |
 implementation
 uses
   SyncObjs;|
 
 It was cleanup by me and now looks like that:
 |Interface
 uses
   SysUtils, Types,   Classes,
   FPImgCmn, FPImage, FPCanvas,
   FPReadJpeg,FPWriteJpeg, // jpg support
   IntfGraphics,  AvgLvlTree,
   LCLType,   LMessages, LResources,LCLResCache,
   GraphType, IcnsTypes, GraphMath, InterfaceBase, WSReferences;|
 
 
 |implementation
 uses
  {FPReadPNG,} FPWritePNG,PNGComn,  // png support
  {FPReadBMP,} FPWriteBMP,   // bmp support
  FPReadPNM,   FPWritePNM,   // png support
  LCLStrConsts,LCLProc,LCLIntf,
  FileUtil, FPCAdds, Math,
  SyncObjs;
 
 |So, previously we have 33 Units mentioned in Interface section and 1 in
 Implementation section. After cleanup we have 19 Units in Interface
 section and 12 in Implementation. 3 Units from Interface section was
 completely removed. ;)
 
 Both Lazarus and all connected apps and projects are working fine with
 this cleanup.  And if you do the same thing - you will see that that
 size of Lazarus will be 15-20 KB less. May be - because of such
 optimization, may be - because of removing unused units from *Interface*
 section

This could be simply the influence of a different memory layout of the exe.
___
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?)

2009-04-08 Thread Alexey S. Smirnov




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] OT: Namespaces?

2009-04-08 Thread Tom Miller
This isn't name spacing, but aliases.

Hans-Peter Diettrich wrote:
  From a discussion I want to present this idea:

 FPC (and Delphi) could extend the Uses syntax to
USES unitname [IN filename] [AS identifier]

 The optional AS part would allow to create an alias (shortcut...) for 
 units of possibly conflicting (same) name. IMO a simple implementation 
 of the most important benefits of namespaces, that does not require the 
 introduction of orthogonal namespaces in addition to units.

 While this suggestion is not related to Lazarus, I still would 
 appreciate comments from the community.

 DoDi

 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

   

___
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

2009-04-08 Thread Marco van de Voort
On Wed, Apr 08, 2009 at 03:55:54PM +0200, Marc Weustink wrote:
  How recently was this all validated to still be a problem? I know FPC didn't
  performed the (apparantly long due) unit system rewrite yet, but not that
  much problems in that realm are reported in mantis anymore, even for the
  current implementation.
 
 The only thing I know was that this only could be solved by the unit 
 rewrite. Since it is not rewriten yet, I assume it is not fixed.

Afaik the rewrite had as an objective to make these errors rarer, and maybe
easier to detect (just like 2.0 fixed the constantly broken optimizer).

However that doesn't necessarily means that 2.2.x (and maybe the branch
based on 2.3.x if it doesn't receive the rewrite anymore) is a totally lost
case. Maybe some things (like relating cross units inlines) are a lost case,
but at least blatant problems should be reported.

If Lazarus as the most major user starts avoid these problems instead of
reporting them, that is worrying. Paul more or less proves the point with 2
bugs in a version cycle of which one is inlining related.
___
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

2009-04-08 Thread Marc Weustink
Marco van de Voort wrote:
 If Lazarus as the most major user starts avoid these problems instead of
 reporting them, that is worrying. Paul more or less proves the point with 2
 bugs in a version cycle of which one is inlining related.

For me, when developing it is the difference between a make and a 
make clean all on every compilation. (and I compile a lot of times 
when refactoring). The first is doable, in case of the latter I quit 
development.

Marc

___
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

2009-04-08 Thread Hans-Peter Diettrich
Reenen Laurie schrieb:

 Just a note: some people think that units can be compiled in one pass -
 this is not true. The compiler must stop on every Uses clause, and
 
 So .exe's should be (much) smaller if your uses units are put mostly
 in implementation

No, that's not related at all.


 If we have to do multipass why is it necessary to have a distinction
 at all?

The compiler must know where to stop pass 1 - and that place is the 
begin of the implementation section. When the interface section uses 
definitions from other units, all these units must become part of the 
interface uses clause, so that the compiler can compile these units before.

The distinction between interface and implementation also allows to 
recompile only selected units. When only the implementation section of a 
unit changes, it's sufficient to recompile only that unit. When the 
interface part changes, also all those units must be recompiled, which 
use that unit.

DoDi

___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus