[Lazarus] Size of binaries etc.
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Sat Mar 24 11:03:11 CET 2012
Bernd wrote:
> 2012/3/21 Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk>:
>> On Linux x86 (Debian "Squeeze") with gtk2, freshly-created minimal project
>> with full optimisation, no debug, optimise for minimum size and smart
>> linking comes to 3,459,960 bytes.
>>
>> That's... such a disparity from what I've been told to expect that I'd
>> appreciate any suggestions as to where I should be looking for problems.
>
> You must be doing something wrong. On i386-linux/GTK2 with everything
> smart-linkable and smart-linked and stripped I get 2MB (2113600 bytes)
> for a minimal application with only one button and one label.
> (everything compiled with -g- -O3 -CX -XX -Xs)
>
> With upx the 2MB go down to 700kB, without smart-linking I get around 4MB.
I've never looked at upx, but possibly I ought. Don't think it supports
Solaris though, or SPARC.
> Make sure while you are compiling your project in Lazarus you also
> have -CX in the options of the "build lazarus" Dialog because
> otherwise when compiling your project it will automatically
> (re-)compile the LCL without smartlinking. It will always recompile
> (if necessary) the LCL and all dependent units with the settings that
> are currently active for "build lazarus" whenever you compile a
> project.
I've complained about that rebuild in the past... all of a sudden it's
starting to look useful.
> (I discovered this by accident but it is quite useful: I always
> thought I had to explicitly recompile the entire Lazarus after
> changing these options but it is enough to just change the options and
> then only recompile your project)
OK. So starting off with an FPC 2.6.0 which has been compiled with
OPT='-O3 -Os -CX -XX', I do a command-line build of Lazarus trunk as
bigide without explicit options. Output shows that compiler command
lines appear to be similar to
ppc386 -MObjFPC -Scghi -O1 -g -gl -vewnhi -l -dLCL -dLCLgtk2 -Fu ...
-di386 lazcontrols.pas
i.e. there's no explicit reference to smartlinking (should I be adding
something here, and if so how?)
I add -CX to the build options inside the IDE, set up a virgin project
and build it. Binary size is 2,161,352 bytes.
So what appears to be happening is that on Linux (and possibly other
unix) a make bigide results in an LCL etc. that isn't smartlinkable,
and the only way to get it is to insert -CX in the IDE's Tools ->
Configure "Build Lazarus" setup, despite the fact that the user isn't
intentionally rebuilding.
I wonder where that leaves somebody who is trying to build a project
with lazbuild, i.e. never using the IDE?
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the Lazarus
mailing list