* [PATCH] Don't optimize code in debug build
@ 2011-02-13 8:32 Piotr Krukowiecki
2011-02-13 9:36 ` Johannes Sixt
0 siblings, 1 reply; 4+ messages in thread
From: Piotr Krukowiecki @ 2011-02-13 8:32 UTC (permalink / raw)
To: git
Code optimization makes debugging harder.
Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki.news@gmail.com>
---
My first patch to this list, so please be gentle ;)
Patch fixes most important problem. There are other improvement possible:
- "-g" is not needed in normal build IMO, I'd move it to debug
- I'd add -O0 -fno-inline to debug too, but maybe it's too gccish
(OTOH there's -g already)
Makefile | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index ade7923..32d3a69 100644
--- a/Makefile
+++ b/Makefile
@@ -262,7 +262,10 @@ endif
# 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 = $(CPPFLAGS) $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
--
1.7.1
--
Piotrek
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Don't optimize code in debug build
2011-02-13 8:32 [PATCH] Don't optimize code in debug build Piotr Krukowiecki
@ 2011-02-13 9:36 ` Johannes Sixt
[not found] ` <AANLkTim6OHU8N7t5RQnt6S7x7ez48RSwp=b82McAC4Oq@mail.gmail.com>
2011-02-13 19:28 ` Junio C Hamano
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Sixt @ 2011-02-13 9:36 UTC (permalink / raw)
To: Piotr Krukowiecki; +Cc: git
On Sonntag, 13. Februar 2011, Piotr Krukowiecki wrote:
> --- a/Makefile
> +++ b/Makefile
> @@ -262,7 +262,10 @@ endif
>
> # 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 = $(CPPFLAGS) $(CFLAGS)
> ALL_LDFLAGS = $(LDFLAGS)
Instead of this, you can just write
CFLAGS = -g -Wall
in your config.mak. Is anything wrong with that?
-- Hannes
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Don't optimize code in debug build
[not found] ` <AANLkTim6OHU8N7t5RQnt6S7x7ez48RSwp=b82McAC4Oq@mail.gmail.com>
@ 2011-02-13 16:26 ` Piotr Krukowiecki
0 siblings, 0 replies; 4+ messages in thread
From: Piotr Krukowiecki @ 2011-02-13 16:26 UTC (permalink / raw)
To: git
(forgot about the list when replying)
> On Sun, Feb 13, 2011 at 10:36 AM, Johannes Sixt <j6t@kdbg.org> wrote:
>> On Sonntag, 13. Februar 2011, Piotr Krukowiecki wrote:
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -262,7 +262,10 @@ endif
>>>
>>> # 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 = $(CPPFLAGS) $(CFLAGS)
>>> ALL_LDFLAGS = $(LDFLAGS)
>>
>> Instead of this, you can just write
>>
>> CFLAGS = -g -Wall
>>
>> in your config.mak. Is anything wrong with that?
Several things: I need to know I should remove -O2, I need to keep in
sync with other default options, current default is less useful, it
requires me to do extra steps.
DEBUG is kind of standard - Makefile already uses it in Windows
specific part. I suppose we want to keep consistent.
--
Piotrek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Don't optimize code in debug build
2011-02-13 9:36 ` Johannes Sixt
[not found] ` <AANLkTim6OHU8N7t5RQnt6S7x7ez48RSwp=b82McAC4Oq@mail.gmail.com>
@ 2011-02-13 19:28 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2011-02-13 19:28 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Piotr Krukowiecki, git
Johannes Sixt <j6t@kdbg.org> writes:
>> @@ -262,7 +262,10 @@ endif
>>
>> # 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 = $(CPPFLAGS) $(CFLAGS)
>> ALL_LDFLAGS = $(LDFLAGS)
>
> Instead of this, you can just write
>
> CFLAGS = -g -Wall
>
> in your config.mak. Is anything wrong with that?
You then need to feed -O2 from the command line when you are not doing a
debugging build. On the other hand, with the current Makefile, you need
to feed "-g -O0" from the command line when you are doing a debugging
build if you and your debugger get confused when seeing an optimized
binary. So neither is a very good solution.
But having to feed DEBUG=Yes when running a debug build is not a good
solution either. A single toggle is simply too coarse-grained; the next
temptation after applying this patch would be to add
ifdef DEBUG
CFLAGS += -DDEBUG
endif
and from there everything goes downhill. That is the last thing we would
want to see happen.
So I would say the current Makefile is just fine as is.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-13 19:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-13 8:32 [PATCH] Don't optimize code in debug build Piotr Krukowiecki
2011-02-13 9:36 ` Johannes Sixt
[not found] ` <AANLkTim6OHU8N7t5RQnt6S7x7ez48RSwp=b82McAC4Oq@mail.gmail.com>
2011-02-13 16:26 ` Piotr Krukowiecki
2011-02-13 19:28 ` 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;
as well as URLs for NNTP newsgroup(s).