From: der.herr@hofr.at (Nicholas Mc Guire)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Is it possible to turn off the gcc optimization when compiling kernel?
Date: Tue, 22 Mar 2016 11:35:16 +0000 [thread overview]
Message-ID: <20160322113516.GA11898@osadl.at> (raw)
In-Reply-To: <CA+PpKPm=eHxK5oj39r8nrT6XGA4qo6XKMNRcgcNCNdGQW_SPvw@mail.gmail.com>
On Tue, Mar 22, 2016 at 07:24:38PM +0800, Hao Lee wrote:
> On Mon, Mar 21, 2016 at 5:51 PM, Nicholas Mc Guire <der.herr@hofr.at> wrote:
> > You can not turn it off in all functions as some need particluar
> > optimization flags to comile at all, but you can pass
> > individual CFLAGS per file via the Makefile
> >
> > CFLAGS_target.o = -O0 or -flags-to-use
> >
> > aswell as remove specific CFLAGS with
> >
> > CFLAGS_REMOVE_target.o = -flags-to-remove
> >
> > but if you want to debug the kernel it is most likely not
> > a good idea to try and disable optimization as the code you then
> > are debugging might not have that much to do with the final code
> > once optimization is on again. So simply generate the .lst file
> > of the target you are trying to debug e.g. for kernel/sched/core.c:
> >
> > make kernel/sched/core.lst
> >
> > and then use that .lst file to understand the output of gdb you
> > are inspecting.
>
> Thanks for your reply!
> Besides,I also find that use "gcc -c -Q -O1 --help=optimizers" can
> print the exact set of optimizations.
>
yes - but for any given code you will find that many of those
options actually have no effect for the particular code blob.
The set of flags effectively impacting the generated object
file is generally much smaller than the ones reported by
gcc -c -Q -O1 --help=optimizers.
thx!
hofrat
next prev parent reply other threads:[~2016-03-22 11:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-20 6:46 Is it possible to turn off the gcc optimization when compiling kernel? Hao Lee
2016-03-21 9:51 ` Nicholas Mc Guire
2016-03-22 11:24 ` Hao Lee
2016-03-22 11:35 ` Nicholas Mc Guire [this message]
2016-03-22 11:46 ` Hao Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160322113516.GA11898@osadl.at \
--to=der.herr@hofr.at \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).