Recent

Author Topic: Whole Program Optimization  (Read 3585 times)

Josh

  • Hero Member
  • *****
  • Posts: 1455
Whole Program Optimization
« on: October 13, 2022, 05:30:06 pm »
Hi

On following the page for Lazarus Project Optimization
https://wiki.freepascal.org/Whole_Program_Optimization
I am getting odd results, so either its me, or something is missing.

I have set up 2 xtra build modes for my project pass 1 and pass 2, according to the above document.
After I compile with Pass 1 then Pass 2, my project is 56MB where as my project with just O2 Smart Link etc, comes out at just 15MB.

I suspect I have missed something. I do note that the fpc example has an extra step...

Any thoughts...

EDIT Just Noticed 4 digit posts..
« Last Edit: October 13, 2022, 05:54:03 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

BrunoK

  • Hero Member
  • *****
  • Posts: 766
  • Retired programmer
Re: Whole Program Optimization
« Reply #1 on: October 13, 2022, 05:37:11 pm »
Debug info ?

Josh

  • Hero Member
  • *****
  • Posts: 1455
Re: Whole Program Optimization
« Reply #2 on: October 13, 2022, 05:51:09 pm »
Hi

Pass 1, Pass 2, MyRelease Build modes do not have any debug info included, the Pass 1 and Pass 2 are copies of MyRelease Build mode with the addition of

Pass 1
Quote
-FWtempwindows.wpo
-CX
-XX
-Xs-
-OWDEVIRTCALLS
-OWOPTVMTS

Pass2
Quote
-Fwtempwindows.wpo
-CX
-XX
-Xs-
-OwDEVIRTCALLS
-OwOPTVMTS
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12863
  • FPC developer.
Re: Whole Program Optimization
« Reply #3 on: October 13, 2022, 05:54:59 pm »
The collection phase should not have stripping enabled according to the wiki?

Josh

  • Hero Member
  • *****
  • Posts: 1455
Re: Whole Program Optimization
« Reply #4 on: October 13, 2022, 06:14:09 pm »
Hi

I unchecked the strip in both Pass 1 and Pass 2, The exe is still 56MB

I created a Third Mode Release WPO Final and put
Quote
-Fwtempwindows.wpo
-CX
-XX
-OwDEVIRTCALLS
-OwOPTVMTS

When I run this after Pass 1 and Pass 2 My Exe is 13.6MB

Observation note, if your active build is pass 2, and you build many with pass 1and pass 2 in that order, because pass 2 is active mode, this is compiled first...
« Last Edit: October 13, 2022, 06:16:48 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3923
    • StrumPract is the musicians best friend
Re: Whole Program Optimization
« Reply #5 on: October 13, 2022, 06:39:20 pm »
Hello.

Did you try with and without -B ?
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Josh

  • Hero Member
  • *****
  • Posts: 1455
Re: Whole Program Optimization
« Reply #6 on: October 13, 2022, 06:47:20 pm »
Hi Fred

I cannot compile for all Build Modes, as I have Build for Win32,Win64,Carbon,Cocoa, each has a debug and release mode.
I was having issues with crosscompiling, so I have a Lazarus 32 Installation and Seperate 64 Installation, and The Mac Build options are for Actual Mac Installation on an old snowleopard system, and MacMini M1 on Monterey,
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3923
    • StrumPract is the musicians best friend
Re: Whole Program Optimization
« Reply #7 on: October 13, 2022, 06:55:41 pm »
Hello Josh.

OK, i do also cross-compilation but I noted that, sometime, if compiling without -B parameter (build all) there was strange result.

So now, to avoid problems, I always use -B (even if it will rebuild all the units and take more time).
That said, maybe it is not related to your problem but, in case of...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Josh

  • Hero Member
  • *****
  • Posts: 1455
Re: Whole Program Optimization
« Reply #8 on: October 13, 2022, 07:06:24 pm »
Hi Fred,

I agree, before doing any 'Final Build' I go to Run/Clean Up and Build, and just delete the files. Then I build

I have Done this with this, but Pass 1 and Pass 2 endup with large file.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3923
    • StrumPract is the musicians best friend
Re: Whole Program Optimization
« Reply #9 on: October 13, 2022, 07:13:17 pm »
Not sure about your parameter -Xs- ( the - at end ).
I use this to strip:

Code: [Select]
-XX -CX -Xs
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Josh

  • Hero Member
  • *****
  • Posts: 1455
Re: Whole Program Optimization
« Reply #10 on: October 13, 2022, 07:17:59 pm »
Hi Fred vS

The options are put in using,  Project Option, Custom Option, AllOptions, then scrolling and enabling the relevent paramters to add
 
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3923
    • StrumPract is the musicians best friend
Re: Whole Program Optimization
« Reply #11 on: October 13, 2022, 07:30:23 pm »
Hello Josh.

I just try with a demo console program in Linux 64 bit:

Code: Pascal  [Select][+][-]
  1. fpc -XX -CX -Xs- test.pas

Result: 2.1 megas.

Then the same with -Xs (without - at end):

Code: Pascal  [Select][+][-]
  1. fpc -XX -CX -Xs test.pas

Result: 0.9 mega.
« Last Edit: October 13, 2022, 07:49:48 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3923
    • StrumPract is the musicians best friend
Re: Whole Program Optimization
« Reply #12 on: October 13, 2022, 07:49:17 pm »
Hi Fred vS

The options are put in using,  Project Option, Custom Option, AllOptions, then scrolling and enabling the relevent paramters to add

Here with Lazarus 2.2.4 when selecting -Xs, it does not add a "-" at end.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Josh

  • Hero Member
  • *****
  • Posts: 1455
Re: Whole Program Optimization
« Reply #13 on: October 13, 2022, 09:24:29 pm »
Hi Fred vS,

Confirmed if I remove the trailing - from the -Xs-, then it works correctly. :) :)

Looks like the Wiki Needs Checking/Changing.
Where I got my info from https://wiki.freepascal.org/Whole_Program_Optimization
for both FPC and Lazarus
« Last Edit: October 13, 2022, 09:27:01 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Fred vS

  • Hero Member
  • *****
  • Posts: 3923
    • StrumPract is the musicians best friend
Re: Whole Program Optimization
« Reply #14 on: October 13, 2022, 09:29:32 pm »
Looks like the Wiki Needs Checking/Changing.
Where I got my info from https://wiki.freepascal.org/Whole_Program_Optimization
for both FPC and Lazarus

Hum, indeed that picture:
https://wiki.freepascal.org/File:02_Linux_WPO_Pass1.png

Needs some work with LazPaint.  ;)

I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018