[Lazarus] Strip debug info

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Strip debug info

Richard Mace
Hi,
What's the safest way of making the .exe smaller than default? Is it just to strip debug info?
How would I do this?

Thanks in advance

Richard

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Reinier Olislagers
On 28-4-2012 8:57, Richard Mace wrote:
> Hi,
> What's the safest way of making the .exe smaller than default? Is it
> just to strip debug info?
> How would I do this?
Perhaps this will give you some ideas?
http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration

... you can either not generated debug info at all or generate external
debug info (.dbg)...

Regards,
Reinier


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Richard Mace-2

On 28 April 2012 08:21, Reinier Olislagers <[hidden email]> wrote:
On 28-4-2012 8:57, Richard Mace wrote:
> Hi,
> What's the safest way of making the .exe smaller than default? Is it
> just to strip debug info?
> How would I do this?
Perhaps this will give you some ideas?
http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration

... you can either not generated debug info at all or generate external
debug info (.dbg)...

Regards,
Reinier

Thanks, I'll try with the -Xg switch

Richard

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

John Landmesser
In reply to this post by Richard Mace
On 28.04.2012 08:57, Richard Mace wrote:
Hi,
What's the safest way of making the .exe smaller than default? Is it just to strip debug info?
How would I do this?

Thanks in advance

Richard


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


my DAU method is in terminal on linux

strip --strip-all ./MyApplication

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

John Landmesser
In reply to this post by Richard Mace
On 28.04.2012 08:57, Richard Mace wrote:
Hi,
What's the safest way of making the .exe smaller than default? Is it just to strip debug info?
How would I do this?

Thanks in advance

Richard


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


my DAU method is in terminal on linux

strip --strip-all ./MyApplication

strip.exe for Win is part of your fpc bin directory:

/lazarus/fpc/2.5.1/bin/i386-win32/strip.exe


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Attached Message Part (177 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Richard Mace-2


On 28 April 2012 11:03, John Landmesser <[hidden email]> wrote:
On 28.04.2012 08:57, Richard Mace wrote:
Hi,
What's the safest way of making the .exe smaller than default? Is it just to strip debug info?
How would I do this?

Thanks in advance

Richard


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


my DAU method is in terminal on linux

strip --strip-all ./MyApplication

strip.exe for Win is part of your fpc bin directory:

/lazarus/fpc/2.5.1/bin/i386-win32/strip.exe


Would this be instead of the -Xg switch or as well as? Or does it do the same thing?

Richard

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Richard Mace-2
In reply to this post by Reinier Olislagers


On 28 April 2012 08:21, Reinier Olislagers <[hidden email]> wrote:
On 28-4-2012 8:57, Richard Mace wrote:
> Hi,
> What's the safest way of making the .exe smaller than default? Is it
> just to strip debug info?
> How would I do this?
Perhaps this will give you some ideas?
http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration

... you can either not generated debug info at all or generate external
debug info (.dbg)...


Is there any reason why the -Xg flag is not on at default? What's the disadvantage of using this flag? The reason I say is because there is a "massive" reduction in .exe size?

Richard

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Jürgen Hestermann


Richard Mace schrieb:
>
>     ... you can either not generated debug info at all or generate
>     external debug info (.dbg)...
>
>
> Is there any reason why the -Xg flag is not on at default? What's the
> disadvantage of using this flag? The reason I say is because there is
> a "massive" reduction in .exe size?
>
Yes, that's what I wondered about too.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Florian Klämpfl
In reply to this post by Richard Mace-2
Am 28.04.2012 21:19, schrieb Richard Mace:

>
>
> On 28 April 2012 08:21, Reinier Olislagers <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     On 28-4-2012 8:57, Richard Mace wrote:
>     > Hi,
>     > What's the safest way of making the .exe smaller than default? Is it
>     > just to strip debug info?
>     > How would I do this?
>     Perhaps this will give you some ideas?
>     http://wiki.lazarus.freepascal.org/Size_Matters#Incorrect_compiler_configuration
>
>     ... you can either not generated debug info at all or generate external
>     debug info (.dbg)...
>
>
> Is there any reason why the -Xg flag is not on at default? What's the
> disadvantage of using this flag? The reason I say is because there is a
> "massive" reduction in .exe size?

What's the problem with the .exe size when compiling with debug info? If
one compiles with debug settings, one usually wants to have the debug
info? If not, don't use debug settings.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Jürgen Hestermann
Florian Klämpfl schrieb:
 > What's the problem with the .exe size when compiling with debug info? If
 > one compiles with debug settings, one usually wants to have the debug
 > info? If not, don't use debug settings.

Well, the problem is the size of the exe file. ;-)
When I am working on a project I usually want to generate debug
information for debugging.
But when I give the generated file to someone else I surely do not need
this information in the exe file anymore.
So why should I be forced to search for ways to delete this information
from the exe if there could be a way to avoid this hassle?


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Florian Klämpfl
Am 29.04.2012 11:12, schrieb Jürgen Hestermann:

> Florian Klämpfl schrieb:
>> What's the problem with the .exe size when compiling with debug info? If
>> one compiles with debug settings, one usually wants to have the debug
>> info? If not, don't use debug settings.
>
> Well, the problem is the size of the exe file. ;-)
> When I am working on a project I usually want to generate debug
> information for debugging.
> But when I give the generated file to someone else I surely do not need
> this information in the exe file anymore.
> So why should I be forced to search for ways to delete this information
> from the exe if there could be a way to avoid this hassle?

There is no need to search for ways to delete this information, you need
only a proper workflow: exes compiled for distribution shall be compiled
with release settings which means:
- no debug info
- symbols fully stripped
- full optimization (which would make debugging harder)
- asserts ignored
- custom debug code ignored
- ...
Using debug and release settings is something very basic when working on
software being deployed to others.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Graeme Geldenhuys
On 29 April 2012 11:21, Florian Klämpfl <[hidden email]> wrote:
> Using debug and release settings is something very basic when working on
> software being deployed to others.

I fully agree. MSEide has project setting groups where you can define
debug and release settings. Lazarus IDE I believe now has such
functionality too in Trunk. This is even possible from the command
line using something like:

   fpc @debug.cfg myproject.pas
   fpc @release.cfg myproject.pas

The 'debug.cfg' and 'release.cfg' are simply text files with compiler
settings (one per line).


--
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Martin Frb
In reply to this post by Jürgen Hestermann
On 29/04/2012 09:56, Jürgen Hestermann wrote:

>
> Richard Mace schrieb:
>>
>>     ... you can either not generated debug info at all or generate
>>     external debug info (.dbg)...
>>
>>
>> Is there any reason why the -Xg flag is not on at default? What's the
>> disadvantage of using this flag? The reason I say is because there is
>> a "massive" reduction in .exe size?
>>
> Yes, that's what I wondered about too.

Probably it is simple less tested, and therefore it is unknown if in
works in all situations.

Also, I guess it is more error prone. Compile with external debug, then
make changes, recompile but with release settings. Then you have an
outdated debug info file, and if you happen to run that in the debugger,
you get a lot of strange things....

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Martin Frb
In reply to this post by Jürgen Hestermann
On 29/04/2012 10:12, Jürgen Hestermann wrote:

> Florian Klämpfl schrieb:
> > What's the problem with the .exe size when compiling with debug
> info? If
> > one compiles with debug settings, one usually wants to have the debug
> > info? If not, don't use debug settings.
>
> Well, the problem is the size of the exe file. ;-)
> When I am working on a project I usually want to generate debug
> information for debugging.
> But when I give the generated file to someone else I surely do not
> need this information in the exe file anymore.
> So why should I be forced to search for ways to delete this
> information from the exe if there could be a way to avoid this hassle?
>

Well, most people need 2 build profiles anyway.

For when I debug I have -Crio -O1, heap trc and other flags.
On release I have -O2, and no -C...., no heaptrc...

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Hans-Peter Diettrich
In reply to this post by Martin Frb
Martin schrieb:
> On 29/04/2012 09:56, Jürgen Hestermann wrote:

> Also, I guess it is more error prone. Compile with external debug, then
> make changes, recompile but with release settings. Then you have an
> outdated debug info file, and if you happen to run that in the debugger,
> you get a lot of strange things....

Give the executable different names. When debugging, the exe name is
irrelevant since the application will be started by F9.

DoDi


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Martin Frb
On 29/04/2012 13:00, Hans-Peter Diettrich wrote:

> Martin schrieb:
>> On 29/04/2012 09:56, Jürgen Hestermann wrote:
>
>> Also, I guess it is more error prone. Compile with external debug,
>> then make changes, recompile but with release settings. Then you have
>> an outdated debug info file, and if you happen to run that in the
>> debugger, you get a lot of strange things....
>
> Give the executable different names. When debugging, the exe name is
> irrelevant since the application will be started by F9.

Then you can always generate 2 exe too. One with and one without dbg info...
If you generate, the 2 exe individually, people may debug their latest
changes, and then ship the release exe, from the day before....

I am not saying, that external debug info could not be made default. And
neither do I say, that the current solution has no problems (it
obviously has)

In fact I think it would be great if it could be changed to use external
dbg info (assuming it is done right).

Just pointing out, it is probably not as easy, as just a new default for
that checkbox.
- Test it on various platforms, cross compile, remote debug, ....
(ideally add to the debugger test suit)
- Test it for projects with starter/host application (debug libraries
with external info)
- different gdb versions (at least 7.0 to 7.4 / 6.3.50 on Mac)
- implement checks in the IDE so no old file will be used accidental
(different name; or remove/rename old dbg info file)

Maybe other things I haven't thought of.

In any case, while nice to have, it is nothing I am going to bother
about. There is plenty other, that I find more important.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Jürgen Hestermann
In reply to this post by Martin Frb
Martin schrieb:
 >>> Is there any reason why the -Xg flag is not on at default? What's
the disadvantage of using this flag? The reason I say is because there
is a "massive" reduction in .exe size?
 >>>
 >> Yes, that's what I wondered about too.
 >
 > Also, I guess it is more error prone. Compile with external debug,
then make changes,
 > recompile but with release settings. Then you have an outdated debug
info file, and
 > if you happen to run that in the debugger, you get a lot of strange
things....
 >

Realy? If you compile without (external) debug info can you still run
the debugger from the IDE?
If yes, this has to be disabled of course.
If not, then there is no danger that an outdated debug info file can be
used.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Martin Frb
On 29/04/2012 16:54, Jürgen Hestermann wrote:

> Martin schrieb:
> >>> Is there any reason why the -Xg flag is not on at default? What's
> the disadvantage of using this flag? The reason I say is because there
> is a "massive" reduction in .exe size?
> >>>
> >> Yes, that's what I wondered about too.
> >
> > Also, I guess it is more error prone. Compile with external debug,
> then make changes,
> > recompile but with release settings. Then you have an outdated debug
> info file, and
> > if you happen to run that in the debugger, you get a lot of strange
> things....
> >
>
> Realy? If you compile without (external) debug info can you still run
> the debugger from the IDE?
> If yes, this has to be disabled of course.
> If not, then there is no danger that an outdated debug info file can
> be used.

Again, not that simple.

Currently, I can start the app (without debug info) by pressing F9. Just
as a way to run it. Not to debug it.
So if that was no longer possible, then alternate means need to be
created, to just run (there is a feature request for that already)


But *IF* such a check would be added.....
the appropriate way for the IDE to check is not to see, if the last
compile did have dbg info. It is to check, if the debug info is available.

Example: I often use the "Run Param" > "Host App" to debug a different
version of the executable. It works perfect. Of course that still works,
even if the last compiled exe has no debug info.

And one can also compile the project outside the IDE, and debug it in
the IDE .....

And, of course that makes it even more complicated: because if I debug a
dll, I might have a project loaded that does uses the dll. I would have
to test, if the debugger can use the dll's debug info, if the host app
has no debug info.... (I do not know)

-----------
Again, yes the situation can (and need/should) be improved.
But again: not that simple.



--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Alexander Klenin
While I am personally ambivalent about the default state of -Xg switch,
I'd like to point out another use case where it matters:
compiling on Windows on slow machine with antivirus installed.

When I tried to persuade my students to switch to Lazarus from Delphi,
I've got many complaints about Lazarus being too slow.
About a third of these complaints were fixed by either excluding
Lazarus directory from AV's monitoring list, or turning -Xg on.

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strip debug info

Richard Mace-2

On 30 April 2012 04:49, Alexander Klenin <[hidden email]> wrote:
While I am personally ambivalent about the default state of -Xg switch,
I'd like to point out another use case where it matters:
compiling on Windows on slow machine with antivirus installed.

When I tried to persuade my students to switch to Lazarus from Delphi,
I've got many complaints about Lazarus being too slow.
About a third of these complaints were fixed by either excluding
Lazarus directory from AV's monitoring list, or turning -Xg on.


Sorry, I might have missed this, but what would be the main disadvantage for a newbie of having the -Xg switch on at default.
I don't really understand about the difference between having the debug info internal to the .exe or external, and I am guessing that the majority of people coming to Lazarus won't either. I just think the more people will be complaining about the default size of the .exe as apposed to having the debug info stored externally, unless I am really missing the point (quite possibly).

Richard

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
12