Re: How can I turn off/disable -O2/-Os optimization?

From: Renato Westphal
Date: Sat May 05 2012 - 22:01:00 EST


2012/4/2 Zhihua Che <zhihua.che@xxxxxxxxx>:
> å 2012å4æ2æ äå12:49ïRandy Dunlap <rdunlap@xxxxxxxxxxxx> åéï
>> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/