Git development
 help / color / mirror / Atom feed
* [PATCH] Makefile: do not optimize when DEBUG=1
@ 2007-03-06 21:50 Johannes Schindelin
  2007-03-07  9:26 ` Johannes Sixt
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2007-03-06 21:50 UTC (permalink / raw)
  To: git, junkio


There is this wonderful debugger named gdb, which sometimes has severe
problems when the source is compiled with optimization. So, you have to
recompile (at least parts of the source) _without_ -O2 if you want to
have a chance to look at otherwise optimized-out variables.

You can do that now by removing just the object files containing the
code you want to debug, and saying "make DEBUG=1".

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index c3d67af..18fdc5e 100644
--- a/Makefile
+++ b/Makefile
@@ -110,6 +110,8 @@ all::
 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 # MakeMaker (e.g. using ActiveState under Cygwin).
 #
+# Define DEBUG=1 to compile without optimization.
+#
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -123,7 +125,10 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
 
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
-CFLAGS = -g -O2 -Wall
+CFLAGS = -g -Wall
+ifndef DEBUG
+	CFLAGS += -O2
+endif
 LDFLAGS =
 ALL_CFLAGS = $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
-- 
1.5.0.3.2559.g30d3b

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-07 18:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06 21:50 [PATCH] Makefile: do not optimize when DEBUG=1 Johannes Schindelin
2007-03-07  9:26 ` Johannes Sixt
2007-03-07 12:37   ` Johannes Schindelin
2007-03-07 13:41     ` [PATCH] Avoid rebuilding everything if user changes CFLAGS on the make command line Johannes Sixt
2007-03-07 18:01       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox