Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-10

Deep exe strip :)

17 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

I did some tests with linking options. Tested on CodeTyphon 2.90, Linux mint GTK2 64bit. Empty form:

1. Project options:
- smart linking (-CX),
- optimization level 3,
- unchecked "create debugger information"
- clear debug symbolx (-Xs)
- smart linking (-XX)

Result: 5 MB

2. Same project options, but IDE rebuild with -CX and -XX options

Result: 2.9 MB

3. Same options but added VirtualTreeView control from additional package

Result: 3.8 MB

3. Same options but rebuild VirtualTreeView package with unchecked option "create debugger information"

Result: 3.6 MB

My question is: Is exists any global strip to get the smallest possible exe size? Why when I have configured "release" build mode in my project with all "striping" and smart linking, requied packages still have debuger informations and I must uncheck and rebuild it manually? I'm not complaining, I'm just curious :) . For example rebuild 4 requied packages with unchecked "create debugger info" in my project, I get exe smaller by 1MB

Regards.

Reply by email

Kostas Michalopoulos
to Krzysztof

Does the size change if you do a

strip --strip-all executable

in one of the large versions down to the small version?

Krzysztof wrote 43 lines
Hi, I did some tests with linking options. Tested on CodeTyphon 2.90, Linux mint GTK2 64bit. Empty form: 1. Project options: - smart linking (-CX), - optimization level 3, - unchecked "create debugger information" - clear debug symbolx (-Xs) - smart linking (-XX) Result: 5 MB 2. Same project options, but IDE rebuild with -CX and -XX options Result: 2.9 MB 3. Same options but added VirtualTreeView control from additional package Result: 3.8 MB 3. Same options but rebuild VirtualTreeView package with unchecked option "create debugger information" Result: 3.6 MB My question is: Is exists any global strip to get the smallest possible exe size? Why when I have configured "release" build mode in my project with all "striping" and smart linking, requied packages still have debuger informations and I must uncheck and rebuild it manually? I'm not complaining, I'm just curious :) . For example rebuild 4 requied packages with unchecked "create debugger info" in my project, I get exe smaller by 1MB Regards. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Bernd
to Krzysztof: I did some tests with linking options. Tested on CodeTyphon 2.90, Linux mint GTK2 64bit.…

2012/10/24 Krzysztof :

2. Same project options, but IDE rebuild with -CX and -XX options

Note that you do not actually need to rebuild the IDE, it is enough to just change the IDE build options, save and then rebuild your project. It will then rebuild on demand only those parts of the LCL and packages for your project that are actually needed by your project and not the entire IDE.

Reply by email

Krzysztof
to Bernd
Show quoted text 5 lines
Does the size change if you do a strip --strip-all executable in one of the large versions down to the small version?

With strip-all I can't get the smallest exe which I get with lazarus switchers - 3.7 MB

Show quoted text 5 lines
Note that you do not actually need to rebuild the IDE, it is enough to just change the IDE build options, save and then rebuild your project. It will then rebuild on demand only those parts of the LCL and packages for your project that are actually needed by your project and not the entire IDE.

Thanks, I didn't know that. But why I must uncheck "create debug info" in each project required package when I have this option disabled in project options?

Reply by email

Martin
to Krzysztof
Krzysztof wrote 8 lines
> Does the size change if you do a > > strip --strip-all executable > > in one of the large versions down to the small version? With strip-all I can't get the smallest exe which I get with lazarus switchers - 3.7 MB

strip and smart-linking/linkable are not related.
- strip can and will only remove debug info.
- Smart link can remove unused code.

And you can go further and try
http://wiki.freepascal.org/Whole_Program_Optimization

Reply by email

Kostas Michalopoulos
to Martin

I think there should be a one checkbox solution in project settings that builds (and rebuilds) stuff with the proper settings to make things compact. From what i understand the current situation is way too complex.

Martin wrote 26 lines
On 25/10/2012 11:50, Krzysztof wrote: >> >> Does the size change if you do a >> >> strip --strip-all executable >> >> in one of the large versions down to the small version? > > With strip-all I can't get the smallest exe which I get with lazarus > switchers - 3.7 MB > strip and smart-linking/linkable are not related. - strip can and will only remove debug info. - Smart link can remove unused code. And you can go further and try http://wiki.freepascal.org/Whole_Program_Optimization -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

leledumbo
to Krzysztof: I did some tests with linking options. Tested on CodeTyphon 2.90, Linux mint GTK2 64bit.…
Is exists any global strip to get the smallest possible exe size?

Not to my knowledge, but in my version (1.1 about 1 month ago) if I change build mode then all dependencies are recompiled, with the same options I guess, because I got a slightly smaller binary.

View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Deep-exe-strip-tp4027310p4027367.html Sent from the Free Pascal - Lazarus mailing list .

Reply by email

Kostas Michalopoulos
to Martin

Build modes are something else (groups of option presets). What i'm talking about would be a checkbox that you check in your "release" build mode so that it builds the smallest executable using a "release" build of LCL with no debug info whatsoever and you have unchecked in "debug" build mode which uses a "normal" build.

I think this also needs LCL to not be rebuilt at the same place so that changing build mode wont rebuild the whole world.

Martin wrote 19 lines
On 25/10/2012 14:29, Kostas Michalopoulos wrote: > > I think there should be a one checkbox solution in project settings > that builds (and rebuilds) stuff with the proper settings to make > things compact. From what i understand the current situation is way > too complex. > It is possible. Look on the wiki for build modes. The only thing missing are preset modes -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin
to Kostas Michalopoulos
Kostas Michalopoulos wrote 9 lines
Build modes are something else (groups of option presets). What i'm talking about would be a checkbox that you check in your "release" build mode so that it builds the smallest executable using a "release" build of LCL with no debug info whatsoever and you have unchecked in "debug" build mode which uses a "normal" build. I think this also needs LCL to not be rebuilt at the same place so that changing build mode wont rebuild the whole world.

Changing the buildmode should already rebuild the LCL (if something relevant changed, compared to the previous buildmode)

So 1 buildmodes "release fastest", "release smallest" should be all you need

Reply by email

Kostas Michalopoulos
to Martin

So all the steps that Krzysztof mentioned in his initial message can be done in a buildmode?

Martin wrote 23 lines
On 26/10/2012 12:27, Kostas Michalopoulos wrote: > > Build modes are something else (groups of option presets). What i'm > talking about would be a checkbox that you check in your "release" > build mode so that it builds the smallest executable using a "release" > build of LCL with no debug info whatsoever and you have unchecked in > "debug" build mode which uses a "normal" build. > > I think this also needs LCL to not be rebuilt at the same place so > that changing build mode wont rebuild the whole world. > Changing the buildmode should already rebuild the LCL (if something relevant changed, compared to the previous buildmode) So 1 buildmodes "release fastest", "release smallest" should be all you need -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin
to Kostas Michalopoulos
Kostas Michalopoulos wrote
So all the steps that Krzysztof mentioned in his initial message can be done in a buildmode?

Yes, or yes they should.

That is, if they can all be set in the options dialog. If any of them can not be set there, then that is a different problem. (I believe they can, but I have not tested)
That would still NOT mean the need for one checkbox named "create smallest executable".
It would mean, that this particular setting would need to be added to the project-compiler-settings.

So if we have all the individual settings avail there, then it can be done with a build mode.

I have not tested if they are there (note that a lot can be done by adding custom compiler options ("other" tab) too.

And there are build macros, which can also be used. I have in the past used them, to use the same package across several projects, but build with different settings. This definitely works. (And recompiles used packages, if needed)

Show quoted text 28 lines
On Fri, Oct 26, 2012 at 2:25 PM, Martin wrote: > On 26/10/2012 12:27, Kostas Michalopoulos wrote: >> Build modes are something else (groups of option presets). What i'm >> talking about would be a checkbox that you check in your "release" >> build mode so that it builds the smallest executable using a "release" >> build of LCL with no debug info whatsoever and you have unchecked in >> "debug" build mode which uses a "normal" build. >> >> I think this also needs LCL to not be rebuilt at the same place so >> that changing build mode wont rebuild the whole world. >> > Changing the buildmode should already rebuild the LCL (if something relevant > changed, compared to the previous buildmode) > > So 1 buildmodes "release fastest", "release smallest" should be all you need > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Bernd
to Martin: Changing the buildmode should already rebuild the LCL (if something relevant changed,…

2012/10/26 Martin :

Changing the buildmode should already rebuild the LCL (if something relevant changed, compared to the previous buildmode)

Is this in trunk (1.1) because I cannot observe the behavior you describe in 1.0.3, no matter what compiler or linker settings I set in my project options, they will only affect the project itself, I could not find a way to have the LCL compiled with any different settings than what is defined in the "Build Lazarus" -Settings. I think what the OP is missing (and I think it would be useful too) would be an option in the project settings, someting like:

[x] ignore "build lazarus"-settings and compile LCL and other dependent packages with project settings.

Reply by email

Martin
to Bernd
Bernd wrote 14 lines
2012/10/26 Martin : > Changing the buildmode should already rebuild the LCL (if something relevant > changed, compared to the previous buildmode) Is this in trunk (1.1) because I cannot observe the behavior you describe in 1.0.3, no matter what compiler or linker settings I set in my project options, they will only affect the project itself, I could not find a way to have the LCL compiled with any different settings than what is defined in the "Build Lazarus" -Settings. I think what the OP is missing (and I think it would be useful too) would be an option in the project settings, someting like: [x] ignore "build lazarus"-settings and compile LCL and other dependent packages with project settings.

It depends on the setting, I thing it only applies to build macros. But they can be used to change settings in other packages.

Anyway, the initial statement (that was even before the question of how to recompile packages) was "do we need a checkbox, to build smallest?". And I still say no. It can be done via build modes.
- It may not be And there may be a case for a pre-defined build mode.
- But there is no case for the "build smallest" checkbox.

There may be a need to make certain setup tasks easier or more obvious. But that was not part of my original answer.

Put
$(MyProjectOpts)
in each of your packages "tab: Other" > "Custom Options"

Then in your Project define under "IDE Macro Values" (for the desired build mode)
Macro Name: MyProjectOpts
Macro Value: -g- -O3 -XX -CX -Xs

and that should do.

Reply by email

patspiper
to Martin: Yes, or yes they should. That is, if they can all be set in the options dialog. If any of…
Martin wrote 23 lines
On 26/10/2012 15:05, Kostas Michalopoulos wrote: > So all the steps that Krzysztof mentioned in his initial message can > be done in a buildmode? Yes, or yes they should. That is, if they can all be set in the options dialog. If any of them can not be set there, then that is a different problem. (I believe they can, but I have not tested) That would still NOT mean the need for one checkbox named "create smallest executable". It would mean, that this particular setting would need to be added to the project-compiler-settings. So if we have all the individual settings avail there, then it can be done with a build mode. I have not tested if they are there (note that a lot can be done by adding custom compiler options ("other" tab) too. And there are build macros, which can also be used. I have in the past used them, to use the same package across several projects, but build with different settings. This definitely works. (And recompiles used packages, if needed)

A more complex situation can arise when cross-compiling:
- Win32 debug
- Win32 release
- Linux debug
- Linux release
and that is assuming default/common widgetsets.

What is needed is something like buildmode modifiers.

Stephano

Reply by email

Martin
to Martin: It depends on the setting, I thing it only applies to build macros. But they can be used…
Martin wrote 10 lines
Put $(MyProjectOpts) in each of your packages "tab: Other" > "Custom Options" Then in your Project define under "IDE Macro Values" (for the desired build mode) Macro Name: MyProjectOpts Macro Value: -g- -O3 -XX -CX -Xs

And to clarify.

I an saying:
- It is possible with build modes
- It should be done with buildmodes
- This is one way
- Mos of all: it does not need a chekbox "smallest build" or any check box, that is a just a preset for a combination of existing checkboxes

I am **NOT** saying:
- This is the easiest way
- If or if not there is a way, that is wore self explaining.
- If or if not it could or should be made easier by adding other ways of forcing settings for packages

Reply by email

Martin
to Bernd: 2012/10/26 Martin : Is this in trunk (1.1) because I cannot observe the behavior you…
Bernd wrote
[x] ignore "build lazarus"-settings and compile LCL and other dependent packages with project settings.

You are aware, that not all packages follow the "build lazarus" settings? Only packages that use (or depend on) $(IDEBuildOptions)

That is usually packages that have $(IDEBuildOptions) in their own Other/Custom Options
Or packages that depend an a package that has $(IDEBuildOptions) in **Usage**/Custom

Reply by email