{"thread":{"id":"38431","subject":"[PATCH] Makefile: do not compile git with debugging symbols by default","startedAt":"2015-01-22T12:50:37Z","lastAt":"2015-01-27T08:43:39Z","messageCount":9,"participants":["Alexander Kuleshov","Jeff King","Mike Hommey","Matthieu Moy","David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"255088","messageId":"1421931037-21368-1-git-send-email-kuleshovmail@gmail.com","threadId":"38431","inReplyTo":null,"subject":"[PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-01-22T12:50:37Z","receivedAt":"2015-01-22T12:50:37Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"Standard user has no need in debugging information. This patch adds\nDEBUG=1 option to compile git with debugging symbols and compile without\nit by default.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n Makefile | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex b5b4cee..83ff691 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3,6 +3,8 @@ all::\n \n # Define V=1 to have a more verbose compile.\n #\n+# Define DEBUG=1 to compile git with debugging symbols.\n+#\n # Define SHELL_PATH to a POSIX shell if your /bin/sh is broken.\n #\n # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend\n@@ -363,8 +365,13 @@ GIT-VERSION-FILE: FORCE\n -include GIT-VERSION-FILE\n \n # CFLAGS and LDFLAGS are for the users to override from the command line.\n+DEBUG_CFLAGS=\n+\n+ifdef DEBUG\n+\tDEBUG_CFLAGS = -g\n+endif\n \n-CFLAGS = -g -O2 -Wall\n+CFLAGS = $(DEBUG_CFLAGS) -O2 -Wall\n LDFLAGS =\n ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)\n ALL_LDFLAGS = $(LDFLAGS)\n-- \n2.3.0.rc1\n"},{"id":"255091","messageId":"20150122130036.GC19681@peff.net","threadId":"38431","inReplyTo":"1421931037-21368-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-01-22T13:00:36Z","receivedAt":"2015-01-22T13:00:36Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:\n\n> Standard user has no need in debugging information. This patch adds\n> DEBUG=1 option to compile git with debugging symbols and compile without\n> it by default.\n\nThis explanation is missing why it is beneficial _not_ to have the\ndebugging information.\n\nI expect the answer is \"it makes the executable smaller\". And that is\ntrue, but it gets smaller still if you run \"strip\" on the result:\n\n  $ make CFLAGS= >/dev/null 2>&1 && wc -c <git\n  2424248\n\n  $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git\n  4500816\n\n  $ strip git && wc -c <git\n  2109200\n\nSo I am not sure who this is helping. If you are size-conscious, you\nshould use strip, in which case the \"-g\" flag does not matter (and we\neven have \"make strip\" to help you).\n\nIs there some other reason to avoid the debugging information?\n\n-Peff\n"},{"id":"255101","messageId":"20150122150914.GA20135@glandium.org","threadId":"38431","inReplyTo":"20150122130036.GC19681@peff.net","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2015-01-22T15:09:14Z","receivedAt":"2015-01-22T15:09:14Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Thu, Jan 22, 2015 at 08:00:36AM -0500, Jeff King wrote:\n> On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:\n> \n> > Standard user has no need in debugging information. This patch adds\n> > DEBUG=1 option to compile git with debugging symbols and compile without\n> > it by default.\n> \n> This explanation is missing why it is beneficial _not_ to have the\n> debugging information.\n> \n> I expect the answer is \"it makes the executable smaller\". And that is\n> true, but it gets smaller still if you run \"strip\" on the result:\n> \n>   $ make CFLAGS= >/dev/null 2>&1 && wc -c <git\n>   2424248\n> \n>   $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git\n>   4500816\n> \n>   $ strip git && wc -c <git\n>   2109200\n> \n> So I am not sure who this is helping. If you are size-conscious, you\n> should use strip, in which case the \"-g\" flag does not matter (and we\n> even have \"make strip\" to help you).\n> \n> Is there some other reason to avoid the debugging information?\n\nMaybe this comes from the misconception that debugging information\nchanges the generated code, which, in fact, it doesn't.\n\n  $ make CFLAGS=-g LDFLAGS=-Wl,--build-id=none >/dev/null 2>&1 && wc -c <git\n  4432768\n  $ strip --strip-debug git && wc -c < git\n  2391120\n  $ cp git git_\n  $ make -j4 CFLAGS= LDFLAGS=-Wl,--build-id=none >/dev/null 2>&1 && wc -c <git\n  2400192\n  $ strip --strip-debug git && wc -c < git\n  2391120\n  $ diff -s git git_\n  Files git and git_ are identical\n\nLDFLAGS=-Wl,--build-id=none just avoids creating a .note.gnu.build-id\nsection containing a uuid that varies between builds. The 9k difference\nbetween unstripped vs stripped for the no-debug-info case comes from the\nremoval of the few symbols for source file names (all the symbols from\nreadelf -s git | grep ABS).\n\nMike\n"},{"id":"255107","messageId":"CANCZXo7ocgG27Y48NjYxurVMWOvHkvGqDrLuntkSTxHUK6hcNw@mail.gmail.com","threadId":"38431","inReplyTo":"20150122130036.GC19681@peff.net","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-01-22T16:51:55Z","receivedAt":"2015-01-22T16:51:55Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"Hello Jeff,\n\nYes, main point is size of executable. I'm sorry, didn't see 'strip' target.\n\nWhat if we will strip git and other executable files by default and\nadd -g option and don't strip it if DEBUG=1 passed to make. Something\nlike this:\n\ngit$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)\n\n    $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \\\n\n        $(BUILTIN_OBJS) $(LIBS)\n\nifneq ($(DEBUG),1)\n\n    $(MAKE) strip\n\nendif\n\n\nThank you.\n\n2015-01-22 19:00 GMT+06:00 Jeff King <peff@peff.net>:\n> On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:\n>\n>> Standard user has no need in debugging information. This patch adds\n>> DEBUG=1 option to compile git with debugging symbols and compile without\n>> it by default.\n>\n> This explanation is missing why it is beneficial _not_ to have the\n> debugging information.\n>\n> I expect the answer is \"it makes the executable smaller\". And that is\n> true, but it gets smaller still if you run \"strip\" on the result:\n>\n>   $ make CFLAGS= >/dev/null 2>&1 && wc -c <git\n>   2424248\n>\n>   $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git\n>   4500816\n>\n>   $ strip git && wc -c <git\n>   2109200\n>\n> So I am not sure who this is helping. If you are size-conscious, you\n> should use strip, in which case the \"-g\" flag does not matter (and we\n> even have \"make strip\" to help you).\n>\n> Is there some other reason to avoid the debugging information?\n>\n> -Peff\n\n\n\n-- \n_________________________\n0xAX\n"},{"id":"255108","messageId":"CANCZXo6qnfjaYLh8WN8xSocGQcoaX4UTjzFm1FhF6sg8vhng5A@mail.gmail.com","threadId":"38431","inReplyTo":"CANCZXo7ocgG27Y48NjYxurVMWOvHkvGqDrLuntkSTxHUK6hcNw@mail.gmail.com","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-01-22T16:53:21Z","receivedAt":"2015-01-22T16:53:21Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"Or even still -g as it now, because anyway debugging info will be\nremoved with stripping\n\n2015-01-22 22:51 GMT+06:00 Alexander Kuleshov <kuleshovmail@gmail.com>:\n> Hello Jeff,\n>\n> Yes, main point is size of executable. I'm sorry, didn't see 'strip' target.\n>\n> What if we will strip git and other executable files by default and\n> add -g option and don't strip it if DEBUG=1 passed to make. Something\n> like this:\n>\n> git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)\n>\n>     $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \\\n>\n>         $(BUILTIN_OBJS) $(LIBS)\n>\n> ifneq ($(DEBUG),1)\n>\n>     $(MAKE) strip\n>\n> endif\n>\n>\n> Thank you.\n>\n> 2015-01-22 19:00 GMT+06:00 Jeff King <peff@peff.net>:\n>> On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote:\n>>\n>>> Standard user has no need in debugging information. This patch adds\n>>> DEBUG=1 option to compile git with debugging symbols and compile without\n>>> it by default.\n>>\n>> This explanation is missing why it is beneficial _not_ to have the\n>> debugging information.\n>>\n>> I expect the answer is \"it makes the executable smaller\". And that is\n>> true, but it gets smaller still if you run \"strip\" on the result:\n>>\n>>   $ make CFLAGS= >/dev/null 2>&1 && wc -c <git\n>>   2424248\n>>\n>>   $ make CFLAGS=-g >/dev/null 2>&1 && wc -c <git\n>>   4500816\n>>\n>>   $ strip git && wc -c <git\n>>   2109200\n>>\n>> So I am not sure who this is helping. If you are size-conscious, you\n>> should use strip, in which case the \"-g\" flag does not matter (and we\n>> even have \"make strip\" to help you).\n>>\n>> Is there some other reason to avoid the debugging information?\n>>\n>> -Peff\n>\n>\n>\n> --\n> _________________________\n> 0xAX\n\n\n\n-- \n_________________________\n0xAX\n"},{"id":"255110","messageId":"vpqa91ahg46.fsf@anie.imag.fr","threadId":"38431","inReplyTo":"CANCZXo7ocgG27Y48NjYxurVMWOvHkvGqDrLuntkSTxHUK6hcNw@mail.gmail.com","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-01-22T17:36:41Z","receivedAt":"2015-01-22T17:36:41Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Alexander Kuleshov <kuleshovmail@gmail.com> writes:\n\n> Hello Jeff,\n>\n> Yes, main point is size of executable.\n\nThe Git executable is a few megabytes, i.e. 0.001% the size of a really\nsmall hard disk. The benefit seems really negligible to me.\n\nOTOH, debug information allow users to do better bug reports in case of\ncrash (gdb, valgrind), which outweights by far the benefit of saving a\nhandfull of megabytes IMHO.\n\nOn a side note, I find it very frustrating when a program I use\ncrashes, opens a bug report wizard, and end up telling me \"sorry, your\ndistro removed the debug symbols, recompile everything if you want to\nreport a bug\".\n\nI understand that for a few users, the size of executable matters. But\nthis category of users should be able to find the \"strip\" target or\nsomething equivalent.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"255116","messageId":"20150122183538.GA20085@peff.net","threadId":"38431","inReplyTo":"vpqa91ahg46.fsf@anie.imag.fr","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-01-22T18:35:38Z","receivedAt":"2015-01-22T18:35:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 22, 2015 at 06:36:41PM +0100, Matthieu Moy wrote:\n\n> > Yes, main point is size of executable.\n> \n> The Git executable is a few megabytes, i.e. 0.001% the size of a really\n> small hard disk. The benefit seems really negligible to me.\n\nI don't know the layout of the symbols with respect to the code, or\nwhether the stripped version might reduce memory pressure. So in theory\nit could have a performance impact.\n\nBut...\n\n> OTOH, debug information allow users to do better bug reports in case of\n> crash (gdb, valgrind), which outweights by far the benefit of saving a\n> handfull of megabytes IMHO.\n\nMe too. Especially for people who are building git themselves, I feel\nlike leaving the symbols is a sane default. Package builders are already\nusing \"make strip\", or some feature of their package-build system (e.g.,\n\"dh_strip\") to take care of this for the \"normal\" users. But\nfundamentally this is a packaging issue, not a build issue.\n\n-Peff\n\nPS We could still add a \"DEBUG\" knob to the Makefile and default it to\n   off. But I do not see much point. If you want to change the CFLAGS,\n   then change the CFLAGS knob. It's much more flexible.\n"},{"id":"255142","messageId":"20150122225517.GB31912@glandium.org","threadId":"38431","inReplyTo":"20150122183538.GA20085@peff.net","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2015-01-22T22:55:17Z","receivedAt":"2015-01-22T22:55:17Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Thu, Jan 22, 2015 at 01:35:38PM -0500, Jeff King wrote:\n> On Thu, Jan 22, 2015 at 06:36:41PM +0100, Matthieu Moy wrote:\n> \n> > > Yes, main point is size of executable.\n> > \n> > The Git executable is a few megabytes, i.e. 0.001% the size of a really\n> > small hard disk. The benefit seems really negligible to me.\n> \n> I don't know the layout of the symbols with respect to the code, or\n> whether the stripped version might reduce memory pressure. So in theory\n> it could have a performance impact.\n\nIt doesn't. Debugging info is in a part of the file that is not mapped\nin memory, and in a part that can be removed without affecting the rest\nof the file, so it's more or less at the end.\n\nMike\n"},{"id":"255320","messageId":"20150127084338.GA37443@gmail.com","threadId":"38431","inReplyTo":"20150122225517.GB31912@glandium.org","subject":"Re: [PATCH] Makefile: do not compile git with debugging symbols by default","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2015-01-27T08:43:39Z","receivedAt":"2015-01-27T08:43:39Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Fri, Jan 23, 2015 at 07:55:17AM +0900, Mike Hommey wrote:\n> On Thu, Jan 22, 2015 at 01:35:38PM -0500, Jeff King wrote:\n> > On Thu, Jan 22, 2015 at 06:36:41PM +0100, Matthieu Moy wrote:\n> > \n> > > > Yes, main point is size of executable.\n> > > \n> > > The Git executable is a few megabytes, i.e. 0.001% the size of a really\n> > > small hard disk. The benefit seems really negligible to me.\n> > \n> > I don't know the layout of the symbols with respect to the code, or\n> > whether the stripped version might reduce memory pressure. So in theory\n> > it could have a performance impact.\n> \n> It doesn't. Debugging info is in a part of the file that is not mapped\n> in memory, and in a part that can be removed without affecting the rest\n> of the file, so it's more or less at the end.\n\nIt goes even further.  These days Fedora systems strip debug\ninfo out into separate files and packages while creating rpms\ndebuginfo packages are created automatically and provide\ndebuginfo files under /usr/lib/debug, where gdb knows to look by\ndefault.\n\nAlexander, one nice thing about the Makefile is that it supports\nyou creating a file in your Git worktree called \"config.mak\"\nwith the following content:\n\nCFLAGS = -O2 -Wall\n\nIf you do that then git will build without debug info and you\nwon't have to specify CFLAGS when invoking \"make\".\nHopefully that's easy and convenient enough.\n\ncheers,\n-- \nDavid\n"}]}