Recent

Author Topic: Sugestion for compiling only parts of units.  (Read 5181 times)

Danail

  • Full Member
  • ***
  • Posts: 151
Sugestion for compiling only parts of units.
« on: March 14, 2007, 08:49:06 pm »
I recently red an old book about the language Modula 2. In it you can declare which exactly functions and procedures will use and only they will be aded in the compiled code, except of the whole file. On that way the program becomes smaller. As far as I know the pascal languages include all of the text in the files listed in the section Uses. It will be a nice thing there to be an option or aplication comming with Lazarus that to compile only the functions and procedures that are used from the code, not all.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
RE: Sugestion for compiling only parts of units.
« Reply #1 on: March 14, 2007, 09:36:36 pm »
That is not really true. Smartlinking is possible for quite some time now. Only it isn´t as efficient as we would like.

AFAIK the implentation isn´t about single functions, but about code chunks, which can or not be added to the final executables, depending if they are used. A code chunk is a amount of code smaller then a unit, but may contain several functions. But then the compiler developers should know more about this then I.... for more low-level details it´s probably better to ask on the fpc mailling list.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Sugestion for compiling only parts of units.
« Reply #2 on: March 14, 2007, 11:01:02 pm »
In fpc, if you use the smartlinking option, and don't use a functionm or procedure from a unit, it will not be included.

Keep in mind intializations sections are always used and that there might be some limitation about the smartlinking of virtual methods.

Danail

  • Full Member
  • ***
  • Posts: 151
Sugestion for compiling only parts of units.
« Reply #3 on: March 17, 2007, 06:42:28 pm »
I still didn't understand if I add a unit with 10 functions in my code, and use for example 4 of them, when I compile the project will the 10 functions be aded in the executable or only the 4 that I use.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Sugestion for compiling only parts of units.
« Reply #4 on: March 17, 2007, 08:08:20 pm »
Only the four that you use, if smartlinking is enabled (default on windows).

 

TinyPortal © 2005-2018