linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How can I turn off/disable -O2/-Os optimization?
@ 2012-04-01 16:31 Zhihua Che
  2012-04-01 16:49 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Zhihua Che @ 2012-04-01 16:31 UTC (permalink / raw)
  To: linux-kernel

Hi, everyone

    I'm debugging linux kernel using kgdb/qemu, but I find that the
execution order didn't math the program order usually.  I guess it was
because the compiling optimization. So I decided to remove -O options
in Makefiles.
    First I removed -Ox in variables HOSTCFLAGS/HOSTCXXFLAGS in
<src_root_dir>/Makefile around line 248 and -Ox in variable
KBUILD_CFLAGS in <src_root_dir>/arch/x86/boot/Makefile around line 55.
But it didn't work, the step execution still didn't follow the program
order. Then I found I missed -Ox in KBUILD_CFLAGS in
<src_root_dir>/Makefile around line 562, so I removed them, but this
time, the compiling failed, complaining
    rcupdate.h:917:2: error: size of unnamed array is negative
   And finally, after grep, I find there are a load of -O2 option are
assigned in a load of Makefiles. So, How could I disable -O
optimization for debugging?

   Thanks for any tips

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

* Re: How can I turn off/disable -O2/-Os optimization?
  2012-04-01 16:31 How can I turn off/disable -O2/-Os optimization? Zhihua Che
@ 2012-04-01 16:49 ` Randy Dunlap
  2012-04-02  8:44   ` Zhihua Che
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2012-04-01 16:49 UTC (permalink / raw)
  To: Zhihua Che; +Cc: linux-kernel

On 04/01/2012 09:31 AM, Zhihua Che wrote:

> Hi, everyone
> 
>     I'm debugging linux kernel using kgdb/qemu, but I find that the
> execution order didn't math the program order usually.  I guess it was
> because the compiling optimization. So I decided to remove -O options
> in Makefiles.
>     First I removed -Ox in variables HOSTCFLAGS/HOSTCXXFLAGS in
> <src_root_dir>/Makefile around line 248 and -Ox in variable
> KBUILD_CFLAGS in <src_root_dir>/arch/x86/boot/Makefile around line 55.
> But it didn't work, the step execution still didn't follow the program
> order. Then I found I missed -Ox in KBUILD_CFLAGS in
> <src_root_dir>/Makefile around line 562, so I removed them, but this
> time, the compiling failed, complaining
>     rcupdate.h:917:2: error: size of unnamed array is negative
>    And finally, after grep, I find there are a load of -O2 option are
> assigned in a load of Makefiles. So, How could I disable -O
> optimization for debugging?
> 
>    Thanks for any tips
> --


You could try the new CONFIG_READABLE_ASM patch:
  http://marc.info/?l=linux-kernel&m=133296079716268&w=2


-- 
~Randy

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

* Re: How can I turn off/disable -O2/-Os optimization?
  2012-04-01 16:49 ` Randy Dunlap
@ 2012-04-02  8:44   ` Zhihua Che
  2012-05-06  2:00     ` Renato Westphal
  0 siblings, 1 reply; 5+ messages in thread
From: Zhihua Che @ 2012-04-02  8:44 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

在 2012年4月2日 上午12:49,Randy Dunlap <rdunlap@xenotime.net> 写道:
> On 04/01/2012 09:31 AM, Zhihua Che wrote:
>
>> Hi, everyone
>>
>>     I'm debugging linux kernel using kgdb/qemu, but I find that the
>> execution order didn't math the program order usually.  I guess it was
>> because the compiling optimization. So I decided to remove -O options
>> in Makefiles.
>>     First I removed -Ox in variables HOSTCFLAGS/HOSTCXXFLAGS in
>> <src_root_dir>/Makefile around line 248 and -Ox in variable
>> KBUILD_CFLAGS in <src_root_dir>/arch/x86/boot/Makefile around line 55.
>> But it didn't work, the step execution still didn't follow the program
>> order. Then I found I missed -Ox in KBUILD_CFLAGS in
>> <src_root_dir>/Makefile around line 562, so I removed them, but this
>> time, the compiling failed, complaining
>>     rcupdate.h:917:2: error: size of unnamed array is negative
>>    And finally, after grep, I find there are a load of -O2 option are
>> assigned in a load of Makefiles. So, How could I disable -O
>> optimization for debugging?
>>
>>    Thanks for any tips
>> --
>
>
> You could try the new CONFIG_READABLE_ASM patch:
>  http://marc.info/?l=linux-kernel&m=133296079716268&w=2
>
>
> --
> ~Randy

Hi,
    I tried your patch, and it seemed not to work:-(. It still didn't
follow the program order

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

* Re: How can I turn off/disable -O2/-Os optimization?
  2012-04-02  8:44   ` Zhihua Che
@ 2012-05-06  2:00     ` Renato Westphal
  2012-05-06 13:28       ` Hagen Paul Pfeifer
  0 siblings, 1 reply; 5+ messages in thread
From: Renato Westphal @ 2012-05-06  2:00 UTC (permalink / raw)
  To: Zhihua Che; +Cc: Randy Dunlap, linux-kernel

2012/4/2 Zhihua Che <zhihua.che@gmail.com>:
> 在 2012年4月2日 上午12:49,Randy Dunlap <rdunlap@xenotime.net> 写道:
>> On 04/01/2012 09:31 AM, Zhihua Che wrote:
>>
>>> Hi, everyone
>>>
>>>     I'm debugging linux kernel using kgdb/qemu, but I find that the
>>> execution order didn't math the program order usually.  I guess it was
>>> because the compiling optimization. So I decided to remove -O options
>>> in Makefiles.
>>>     First I removed -Ox in variables HOSTCFLAGS/HOSTCXXFLAGS in
>>> <src_root_dir>/Makefile around line 248 and -Ox in variable
>>> KBUILD_CFLAGS in <src_root_dir>/arch/x86/boot/Makefile around line 55.
>>> But it didn't work, the step execution still didn't follow the program
>>> order. Then I found I missed -Ox in KBUILD_CFLAGS in
>>> <src_root_dir>/Makefile around line 562, so I removed them, but this
>>> time, the compiling failed, complaining
>>>     rcupdate.h:917:2: error: size of unnamed array is negative
>>>    And finally, after grep, I find there are a load of -O2 option are
>>> assigned in a load of Makefiles. So, How could I disable -O
>>> optimization for debugging?
>>>
>>>    Thanks for any tips
>>> --
>>
>>
>> You could try the new CONFIG_READABLE_ASM patch:
>>  http://marc.info/?l=linux-kernel&m=133296079716268&w=2
>>
>>
>> --
>> ~Randy
>
> Hi,
>    I tried your patch, and it seemed not to work:-(. It still didn't
> follow the program order


Hi Zhihua Che,

Have you found a solution for this? I'm facing the same problem with KGDB..

-- 
Renato Westphal

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

* Re: How can I turn off/disable -O2/-Os optimization?
  2012-05-06  2:00     ` Renato Westphal
@ 2012-05-06 13:28       ` Hagen Paul Pfeifer
  0 siblings, 0 replies; 5+ messages in thread
From: Hagen Paul Pfeifer @ 2012-05-06 13:28 UTC (permalink / raw)
  To: Renato Westphal
  Cc: Zhihua Che, Randy Dunlap, linux-kernel, Arnaldo Carvalho de Melo,
	Masami Hiramatsu

* Renato Westphal | 2012-05-05 23:00:48 [-0300]:

>>> You could try the new CONFIG_READABLE_ASM patch:
>>>  http://marc.info/?l=linux-kernel&m=133296079716268&w=2

Maybe remove "-Os" on a global basis is not wanted nor required. Maybe a per
directory, per file or per function basis may superior!

make DISABLE_OPTIMIZATION=net/sched/sch_api.c

But still all core constructs defined in top level header files must be
compatible for directory/file basis to be build with no optimization at all.

One way to un-optmize fine-granular is GCC's optmize pragma [1].

Hagen

PS: such a functionality may be convenient for perf probe too! (to hook into
probepoints which are currently optimized out)


[1] http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html

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

end of thread, other threads:[~2012-05-06 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-01 16:31 How can I turn off/disable -O2/-Os optimization? Zhihua Che
2012-04-01 16:49 ` Randy Dunlap
2012-04-02  8:44   ` Zhihua Che
2012-05-06  2:00     ` Renato Westphal
2012-05-06 13:28       ` Hagen Paul Pfeifer

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).