* [PATCH] Makefile: do not compile git with debugging symbols by default
@ 2015-01-22 12:50 Alexander Kuleshov
2015-01-22 13:00 ` Jeff King
0 siblings, 1 reply; 9+ messages in thread
From: Alexander Kuleshov @ 2015-01-22 12:50 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Alexander Kuleshov
Standard user has no need in debugging information. This patch adds
DEBUG=1 option to compile git with debugging symbols and compile without
it by default.
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
Makefile | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b5b4cee..83ff691 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,8 @@ all::
# Define V=1 to have a more verbose compile.
#
+# Define DEBUG=1 to compile git with debugging symbols.
+#
# Define SHELL_PATH to a POSIX shell if your /bin/sh is broken.
#
# Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
@@ -363,8 +365,13 @@ GIT-VERSION-FILE: FORCE
-include GIT-VERSION-FILE
# CFLAGS and LDFLAGS are for the users to override from the command line.
+DEBUG_CFLAGS=
+
+ifdef DEBUG
+ DEBUG_CFLAGS = -g
+endif
-CFLAGS = -g -O2 -Wall
+CFLAGS = $(DEBUG_CFLAGS) -O2 -Wall
LDFLAGS =
ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
--
2.3.0.rc1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 12:50 [PATCH] Makefile: do not compile git with debugging symbols by default Alexander Kuleshov
@ 2015-01-22 13:00 ` Jeff King
2015-01-22 15:09 ` Mike Hommey
2015-01-22 16:51 ` Alexander Kuleshov
0 siblings, 2 replies; 9+ messages in thread
From: Jeff King @ 2015-01-22 13:00 UTC (permalink / raw)
To: Alexander Kuleshov; +Cc: Junio C Hamano, git
On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:
> Standard user has no need in debugging information. This patch adds
> DEBUG=1 option to compile git with debugging symbols and compile without
> it by default.
This explanation is missing why it is beneficial _not_ to have the
debugging information.
I expect the answer is "it makes the executable smaller". And that is
true, but it gets smaller still if you run "strip" on the result:
$ make CFLAGS= >/dev/null 2>&1 && wc -c <git
2424248
$ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git
4500816
$ strip git && wc -c <git
2109200
So I am not sure who this is helping. If you are size-conscious, you
should use strip, in which case the "-g" flag does not matter (and we
even have "make strip" to help you).
Is there some other reason to avoid the debugging information?
-Peff
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 13:00 ` Jeff King
@ 2015-01-22 15:09 ` Mike Hommey
2015-01-22 16:51 ` Alexander Kuleshov
1 sibling, 0 replies; 9+ messages in thread
From: Mike Hommey @ 2015-01-22 15:09 UTC (permalink / raw)
To: Jeff King; +Cc: Alexander Kuleshov, Junio C Hamano, git
On Thu, Jan 22, 2015 at 08:00:36AM -0500, Jeff King wrote:
> On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:
>
> > Standard user has no need in debugging information. This patch adds
> > DEBUG=1 option to compile git with debugging symbols and compile without
> > it by default.
>
> This explanation is missing why it is beneficial _not_ to have the
> debugging information.
>
> I expect the answer is "it makes the executable smaller". And that is
> true, but it gets smaller still if you run "strip" on the result:
>
> $ make CFLAGS= >/dev/null 2>&1 && wc -c <git
> 2424248
>
> $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git
> 4500816
>
> $ strip git && wc -c <git
> 2109200
>
> So I am not sure who this is helping. If you are size-conscious, you
> should use strip, in which case the "-g" flag does not matter (and we
> even have "make strip" to help you).
>
> Is there some other reason to avoid the debugging information?
Maybe this comes from the misconception that debugging information
changes the generated code, which, in fact, it doesn't.
$ make CFLAGS=-g LDFLAGS=-Wl,--build-id=none >/dev/null 2>&1 && wc -c <git
4432768
$ strip --strip-debug git && wc -c < git
2391120
$ cp git git_
$ make -j4 CFLAGS= LDFLAGS=-Wl,--build-id=none >/dev/null 2>&1 && wc -c <git
2400192
$ strip --strip-debug git && wc -c < git
2391120
$ diff -s git git_
Files git and git_ are identical
LDFLAGS=-Wl,--build-id=none just avoids creating a .note.gnu.build-id
section containing a uuid that varies between builds. The 9k difference
between unstripped vs stripped for the no-debug-info case comes from the
removal of the few symbols for source file names (all the symbols from
readelf -s git | grep ABS).
Mike
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 13:00 ` Jeff King
2015-01-22 15:09 ` Mike Hommey
@ 2015-01-22 16:51 ` Alexander Kuleshov
2015-01-22 16:53 ` Alexander Kuleshov
2015-01-22 17:36 ` Matthieu Moy
1 sibling, 2 replies; 9+ messages in thread
From: Alexander Kuleshov @ 2015-01-22 16:51 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git@vger.kernel.org
Hello Jeff,
Yes, main point is size of executable. I'm sorry, didn't see 'strip' target.
What if we will strip git and other executable files by default and
add -g option and don't strip it if DEBUG=1 passed to make. Something
like this:
git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \
$(BUILTIN_OBJS) $(LIBS)
ifneq ($(DEBUG),1)
$(MAKE) strip
endif
Thank you.
2015-01-22 19:00 GMT+06:00 Jeff King <peff@peff.net>:
> On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:
>
>> Standard user has no need in debugging information. This patch adds
>> DEBUG=1 option to compile git with debugging symbols and compile without
>> it by default.
>
> This explanation is missing why it is beneficial _not_ to have the
> debugging information.
>
> I expect the answer is "it makes the executable smaller". And that is
> true, but it gets smaller still if you run "strip" on the result:
>
> $ make CFLAGS= >/dev/null 2>&1 && wc -c <git
> 2424248
>
> $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git
> 4500816
>
> $ strip git && wc -c <git
> 2109200
>
> So I am not sure who this is helping. If you are size-conscious, you
> should use strip, in which case the "-g" flag does not matter (and we
> even have "make strip" to help you).
>
> Is there some other reason to avoid the debugging information?
>
> -Peff
--
_________________________
0xAX
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 16:51 ` Alexander Kuleshov
@ 2015-01-22 16:53 ` Alexander Kuleshov
2015-01-22 17:36 ` Matthieu Moy
1 sibling, 0 replies; 9+ messages in thread
From: Alexander Kuleshov @ 2015-01-22 16:53 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git@vger.kernel.org
Or even still -g as it now, because anyway debugging info will be
removed with stripping
2015-01-22 22:51 GMT+06:00 Alexander Kuleshov <kuleshovmail@gmail.com>:
> Hello Jeff,
>
> Yes, main point is size of executable. I'm sorry, didn't see 'strip' target.
>
> What if we will strip git and other executable files by default and
> add -g option and don't strip it if DEBUG=1 passed to make. Something
> like this:
>
> git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
>
> $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \
>
> $(BUILTIN_OBJS) $(LIBS)
>
> ifneq ($(DEBUG),1)
>
> $(MAKE) strip
>
> endif
>
>
> Thank you.
>
> 2015-01-22 19:00 GMT+06:00 Jeff King <peff@peff.net>:
>> On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:
>>
>>> Standard user has no need in debugging information. This patch adds
>>> DEBUG=1 option to compile git with debugging symbols and compile without
>>> it by default.
>>
>> This explanation is missing why it is beneficial _not_ to have the
>> debugging information.
>>
>> I expect the answer is "it makes the executable smaller". And that is
>> true, but it gets smaller still if you run "strip" on the result:
>>
>> $ make CFLAGS= >/dev/null 2>&1 && wc -c <git
>> 2424248
>>
>> $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git
>> 4500816
>>
>> $ strip git && wc -c <git
>> 2109200
>>
>> So I am not sure who this is helping. If you are size-conscious, you
>> should use strip, in which case the "-g" flag does not matter (and we
>> even have "make strip" to help you).
>>
>> Is there some other reason to avoid the debugging information?
>>
>> -Peff
>
>
>
> --
> _________________________
> 0xAX
--
_________________________
0xAX
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 16:51 ` Alexander Kuleshov
2015-01-22 16:53 ` Alexander Kuleshov
@ 2015-01-22 17:36 ` Matthieu Moy
2015-01-22 18:35 ` Jeff King
1 sibling, 1 reply; 9+ messages in thread
From: Matthieu Moy @ 2015-01-22 17:36 UTC (permalink / raw)
To: Alexander Kuleshov; +Cc: Jeff King, Junio C Hamano, git@vger.kernel.org
Alexander Kuleshov <kuleshovmail@gmail.com> writes:
> Hello Jeff,
>
> Yes, main point is size of executable.
The Git executable is a few megabytes, i.e. 0.001% the size of a really
small hard disk. The benefit seems really negligible to me.
OTOH, debug information allow users to do better bug reports in case of
crash (gdb, valgrind), which outweights by far the benefit of saving a
handfull of megabytes IMHO.
On a side note, I find it very frustrating when a program I use
crashes, opens a bug report wizard, and end up telling me "sorry, your
distro removed the debug symbols, recompile everything if you want to
report a bug".
I understand that for a few users, the size of executable matters. But
this category of users should be able to find the "strip" target or
something equivalent.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 17:36 ` Matthieu Moy
@ 2015-01-22 18:35 ` Jeff King
2015-01-22 22:55 ` Mike Hommey
0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2015-01-22 18:35 UTC (permalink / raw)
To: Matthieu Moy; +Cc: Alexander Kuleshov, Junio C Hamano, git@vger.kernel.org
On Thu, Jan 22, 2015 at 06:36:41PM +0100, Matthieu Moy wrote:
> > Yes, main point is size of executable.
>
> The Git executable is a few megabytes, i.e. 0.001% the size of a really
> small hard disk. The benefit seems really negligible to me.
I don't know the layout of the symbols with respect to the code, or
whether the stripped version might reduce memory pressure. So in theory
it could have a performance impact.
But...
> OTOH, debug information allow users to do better bug reports in case of
> crash (gdb, valgrind), which outweights by far the benefit of saving a
> handfull of megabytes IMHO.
Me too. Especially for people who are building git themselves, I feel
like leaving the symbols is a sane default. Package builders are already
using "make strip", or some feature of their package-build system (e.g.,
"dh_strip") to take care of this for the "normal" users. But
fundamentally this is a packaging issue, not a build issue.
-Peff
PS We could still add a "DEBUG" knob to the Makefile and default it to
off. But I do not see much point. If you want to change the CFLAGS,
then change the CFLAGS knob. It's much more flexible.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 18:35 ` Jeff King
@ 2015-01-22 22:55 ` Mike Hommey
2015-01-27 8:43 ` David Aguilar
0 siblings, 1 reply; 9+ messages in thread
From: Mike Hommey @ 2015-01-22 22:55 UTC (permalink / raw)
To: Jeff King
Cc: Matthieu Moy, Alexander Kuleshov, Junio C Hamano,
git@vger.kernel.org
On Thu, Jan 22, 2015 at 01:35:38PM -0500, Jeff King wrote:
> On Thu, Jan 22, 2015 at 06:36:41PM +0100, Matthieu Moy wrote:
>
> > > Yes, main point is size of executable.
> >
> > The Git executable is a few megabytes, i.e. 0.001% the size of a really
> > small hard disk. The benefit seems really negligible to me.
>
> I don't know the layout of the symbols with respect to the code, or
> whether the stripped version might reduce memory pressure. So in theory
> it could have a performance impact.
It doesn't. Debugging info is in a part of the file that is not mapped
in memory, and in a part that can be removed without affecting the rest
of the file, so it's more or less at the end.
Mike
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Makefile: do not compile git with debugging symbols by default
2015-01-22 22:55 ` Mike Hommey
@ 2015-01-27 8:43 ` David Aguilar
0 siblings, 0 replies; 9+ messages in thread
From: David Aguilar @ 2015-01-27 8:43 UTC (permalink / raw)
To: Mike Hommey
Cc: Jeff King, Matthieu Moy, Alexander Kuleshov, Junio C Hamano,
git@vger.kernel.org
On Fri, Jan 23, 2015 at 07:55:17AM +0900, Mike Hommey wrote:
> On Thu, Jan 22, 2015 at 01:35:38PM -0500, Jeff King wrote:
> > On Thu, Jan 22, 2015 at 06:36:41PM +0100, Matthieu Moy wrote:
> >
> > > > Yes, main point is size of executable.
> > >
> > > The Git executable is a few megabytes, i.e. 0.001% the size of a really
> > > small hard disk. The benefit seems really negligible to me.
> >
> > I don't know the layout of the symbols with respect to the code, or
> > whether the stripped version might reduce memory pressure. So in theory
> > it could have a performance impact.
>
> It doesn't. Debugging info is in a part of the file that is not mapped
> in memory, and in a part that can be removed without affecting the rest
> of the file, so it's more or less at the end.
It goes even further. These days Fedora systems strip debug
info out into separate files and packages while creating rpms
debuginfo packages are created automatically and provide
debuginfo files under /usr/lib/debug, where gdb knows to look by
default.
Alexander, one nice thing about the Makefile is that it supports
you creating a file in your Git worktree called "config.mak"
with the following content:
CFLAGS = -O2 -Wall
If you do that then git will build without debug info and you
won't have to specify CFLAGS when invoking "make".
Hopefully that's easy and convenient enough.
cheers,
--
David
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-01-27 8:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22 12:50 [PATCH] Makefile: do not compile git with debugging symbols by default Alexander Kuleshov
2015-01-22 13:00 ` Jeff King
2015-01-22 15:09 ` Mike Hommey
2015-01-22 16:51 ` Alexander Kuleshov
2015-01-22 16:53 ` Alexander Kuleshov
2015-01-22 17:36 ` Matthieu Moy
2015-01-22 18:35 ` Jeff King
2015-01-22 22:55 ` Mike Hommey
2015-01-27 8:43 ` David Aguilar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).