Lazarus

Free Pascal => Beginners => Topic started by: guest64953 on December 03, 2019, 01:06:40 pm

Title: Which options do you use when compiling release binary?
Post by: guest64953 on December 03, 2019, 01:06:40 pm
I'm only know -O3  :-[
Title: Re: Which options do you use when compiling release binary?
Post by: Handoko 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.  :)
Title: Re: Which options do you use when compiling release binary?
Post by: Thaddy on December 03, 2019, 01:48:16 pm
-CX -XXs -O3  (but -O4 should also be OK) And processor optimizations on certain platforms.
Title: Re: Which options do you use when compiling release binary?
Post by: lucamar 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
Title: Re: Which options do you use when compiling release binary?
Post by: guest64953 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 (https://forum.lazarus.freepascal.org/index.php?topic=32642.30)
Title: Re: Which options do you use when compiling release binary?
Post by: Handoko 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?
Title: Re: Which options do you use when compiling release binary?
Post by: lainz 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?
Title: Re: Which options do you use when compiling release binary?
Post by: Handoko 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 (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, ...
Title: Re: Which options do you use when compiling release binary?
Post by: lucamar 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
Title: Re: Which options do you use when compiling release binary?
Post by: guest64953 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 (https://forum.lazarus.freepascal.org/index.php?topic=32642.30)

Did anyone notice this post?  :D
Title: Re: Which options do you use when compiling release binary?
Post by: lucamar 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 (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.
Title: Re: Which options do you use when compiling release binary?
Post by: Handoko 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
Title: Re: Which options do you use when compiling release binary?
Post by: lucamar 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".
Title: Re: Which options do you use when compiling release binary?
Post by: valdir.marcos 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 (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.