Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?
От | Chao Li |
---|---|
Тема | Re: Should --enable-debug set CFLAGS to -O0 instead of -O2? |
Дата | |
Msg-id | CAEoWx2=KoWkCm2_uovt4TSkRTSEUxAmaqwXuh7O-O-n6P9ZnYA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Should --enable-debug set CFLAGS to -O0 instead of -O2? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Should --enable-debug set CFLAGS to -O0 instead of -O2?
|
Список | pgsql-hackers |
Hi Tom,
Thanks for the explanation. W.R.T the PROFILE variable, I tried:
# ./configure --enable-debug
# PROFILE="-O0" make
As a result, both "-O2" and "-O0" presented to gcc. In that case, I believe "-O0" will be ignored by gcc.
Did you mean to something else?
Chao Li (Evan)
------------------------------
HighGo Software Inc.
https://www.highgo.com/
https://www.highgo.com/
Tom Lane <tgl@sss.pgh.pa.us> 于2025年8月1日周五 11:30写道:
Chao Li <li.evan.chao@gmail.com> writes:
> I noticed that "./configure --enable-debug" will set "-O2" to CFLAGS. To
> better debug/trace the code, I have to manually change "-O2" to "-O0" in
> src/Makefile.global.
This has been intentional for decades. It is not a bug. You're
certainly welcome to use different CFLAGS locally if that suits
your habits better.
In my mind, at least, the rationale is that we don't want to
give up more performance than we have to in debug builds, nor
let the behavior deviate from what it would be in production.
It is true than in some cases it's too hard to trace the behavior of
optimized code. What I usually do if I get frustrated while debugging
is to recompile specific file(s) at -O0. The PROFILE variable is
handy for injecting that switch.
regards, tom lane
В списке pgsql-hackers по дате отправления: