Recent

Author Topic: Which options do you use when compiling release binary?  (Read 2398 times)

guest64953

  • Guest
Which options do you use when compiling release binary?
« on: December 03, 2019, 01:06:40 pm »
I'm only know -O3  :-[

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Which options do you use when compiling release binary?
« Reply #1 on: December 03, 2019, 01:41:37 pm »
I'm a Lazarus user not (direct) FPC user. For release binary, I usually choose:

-O3 (slow optiomization)
-CX (smart linkable)
-XX (link smart)
-Xs (strip symbols from executable)

Honestly I don't know the different between "smart linkable" and "link smart". But both sound good, so I enable them all.  :)
« Last Edit: December 03, 2019, 01:50:01 pm by Handoko »

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Which options do you use when compiling release binary?
« Reply #2 on: December 03, 2019, 01:48:16 pm »
-CX -XXs -O3  (but -O4 should also be OK) And processor optimizations on certain platforms.
Specialize a type, not a var.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Which options do you use when compiling release binary?
« Reply #3 on: December 03, 2019, 02:23:42 pm »
Honestly I don't know the different between "smart linkable" and "link smart".

"Smart linkable" compiles the units so that thay can be smart-linked if desired. "Link smart" then links the program "smartly", linking only the code actually used.

They are complementary: if you don't make the units "smart-linkable" then they can't be "smart-linked", and viceversa: if you don't smart-link then it doesn't matter whether they are "smart-linkable" or not.

HTH
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

guest64953

  • Guest
Re: Which options do you use when compiling release binary?
« Reply #4 on: December 03, 2019, 03:14:34 pm »
Could you explain the options used on Akira1364's post?

https://forum.lazarus.freepascal.org/index.php?topic=32642.30

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Which options do you use when compiling release binary?
« Reply #5 on: December 03, 2019, 04:07:52 pm »
They are complementary: if you don't make the units "smart-linkable" then they can't be "smart-linked", and viceversa: if you don't smart-link then it doesn't matter whether they are "smart-linkable" or not.
HTH

So why not just merge them into one single option?

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Which options do you use when compiling release binary?
« Reply #6 on: December 03, 2019, 04:28:57 pm »
So why not just merge them into one single option?

I have another question, what is linking? It is for debugging?

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Which options do you use when compiling release binary?
« Reply #7 on: December 03, 2019, 04:51:25 pm »
I remember in the old DOS days, when I learned Clipper, there was a utility called BLinker. Not sure what exactly it did but I guess Clipper compiles the source code to obj and the linker converts (or merge several objs) to an executable binary.

https://en.wikipedia.org/wiki/Linker_%28computing%29

I tried to imagine the obj files are something similar to Turbo Pascal TPUs, or later DCUs, ...
« Last Edit: December 03, 2019, 05:02:03 pm by Handoko »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Which options do you use when compiling release binary?
« Reply #8 on: December 03, 2019, 05:10:52 pm »
They are complementary: if you don't make the units "smart-linkable" then they can't be "smart-linked", and viceversa: if you don't smart-link then it doesn't matter whether they are "smart-linkable" or not.
HTH

So why not just merge them into one single option?

Because they are, conceptually, different operations: one happens when compiling and adds some overhead into the object files. The other happens when linking and it may not always be desirable (e.g. for debugging/profiling purposes).

I have another question, what is linking? It is for debugging?

When compiling a program each unit is compiled to its own .o/.ppu files. Once that is done for everything all those bits and pieces have to be "joined" together to create the executable program: that proces is called linking. That allows you, for example, to use the same unit (like say, System, SysUtils, etc.) without having to recompile all of them every time.

I tried to imagine the obj files are something similar to Turbo Pascal TPUs, or later DCUs, ...

The equivalent to a TPU or DCU in Free Pascal is the combination of the object file and the unit description file (.ppu).

Having a "TPU/DCU" divided in two files has some advantages; for example, it allows you to use a standard linker, like ld, instead of having to rely on (and build!) a dedicated one embedded in the compiler, as happens with Borland's Pascals
« Last Edit: December 03, 2019, 05:23:15 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

guest64953

  • Guest
Re: Which options do you use when compiling release binary?
« Reply #9 on: December 04, 2019, 04:53:22 pm »
Could you explain the options used on Akira1364's post?

https://forum.lazarus.freepascal.org/index.php?topic=32642.30

Did anyone notice this post?  :D

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Which options do you use when compiling release binary?
« Reply #10 on: December 04, 2019, 06:41:09 pm »
Could you explain the options used on Akira1364's post?

https://forum.lazarus.freepascal.org/index.php?topic=32642.30

Did anyone notice this post?  :D

How about typing:
Code: [Select]
fpc -?in your console and reading the result?  ;D

Most of them are also explained (though somewhat sketchily) in the User's Guide.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Which options do you use when compiling release binary?
« Reply #11 on: December 04, 2019, 07:25:12 pm »
I found this page, seems to be useful:
https://www.freepascal.org/docs-html/user/userap1.html

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Which options do you use when compiling release binary?
« Reply #12 on: December 04, 2019, 08:03:43 pm »
I found this page, seems to be useful:
https://www.freepascal.org/docs-html/user/userap1.html

Yeah, that's the one I meant. It seems to be just the output of "fpc -h".
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Which options do you use when compiling release binary?
« Reply #13 on: December 07, 2019, 08:36:48 am »
I remember in the old DOS days, when I learned Clipper, there was a utility called BLinker. Not sure what exactly it did
BLinker was a better solution for CA-Clipper than the standard RTLink, because it was faster, it allowed to access more memory beyond the limit of 640kb up to 16mb of physical memory and 64mb of virtual memory and it generated compressed binaries among other professional features for that time.

Quote
but I guess Clipper compiles the source code to obj and the linker converts (or merge several objs) to an executable binary.
Correct. There were three main commands: clipper, rtlink (among many other alternatives being BLinker the most famous) and make.
"Clipper" to preprocess (PPO) the sources files (PRG) from xBase to the real language (very similar to C, AFAICR) and to generate the OBJ files;
Then "rtlink" to build the binaries (EXE) or libraries (LIB);
And finally "rmake" to govern the process for bigger projects (LNK and RMK).

Quote
https://en.wikipedia.org/wiki/Linker_%28computing%29
I tried to imagine the obj files are something similar to Turbo Pascal TPUs, or later DCUs, ...
Sort of. Since Clipper was developed in C, the compiling process was much more similar to C, than to Pascal.

 

TinyPortal © 2005-2018