mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@kernel.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: "Keith A. Prickett" <keithp@marvell.com>, linux-kernel@vger.kernel.org
Subject: Re: Building Kernel with -O0
Date: Tue, 9 Sep 2008 22:43:05 +0300	[thread overview]
Message-ID: <20080909194305.GG30160@cs181140183.pp.htv.fi> (raw)
In-Reply-To: <87vdx5ruk5.fsf@basil.nowhere.org>

On Tue, Sep 09, 2008 at 09:24:58PM +0200, Andi Kleen wrote:
> "Keith A. Prickett" <keithp@marvell.com> writes:
> >
> > All of this could, potentially be changed by a configuration parameter
> > and added into the kernel release.  Does someone have a primer on why
> > this kind of behavior is not desired or "possible"?
> 
> Traditionally it was not allowed because -O0 didn't inline and
> the kernel relied on inlining in some cases. But with always_inline
> that is obsolete -- all functions that rely on inlining should be 
> marked __always_inline.
> 
> I think a few more cases crept in where it was common to write
> build time asserts as
> 
>       if (some condition the compiler evaluates at runtime)
                                                     ^^^^^^^
buildtime

>          __error_condition_xyz_is_false(); 
>  
> and this obviously relies on the optimizer to build. But these
> are all slowly moving over the BUILD_BUG_ON() which also doesn't
> rely on the optimizer, so it's also obsolete.
>...

The reason why it works for Keith at all seems to be that even with -O0 
gcc already does this kind of optimizations.

Check e.g. the assembler generated for the following
(userspace) program with -O0:

<--  snip  -->

int foobar;

int main()
{ 
	if (1) return 0;

	foobar = 12345;

	return 42;
}

<--  snip  -->

> Hope this helps,
> 
> -Andi

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


  reply	other threads:[~2008-09-09 19:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-04 17:50 Keith A. Prickett
2008-09-09 16:04 ` Adrian Bunk
2008-09-09 17:10   ` Keith A. Prickett
2008-09-09 18:55     ` linux-os (Dick Johnson)
2008-09-09 19:24     ` Andi Kleen
2008-09-09 19:43       ` Adrian Bunk [this message]
2008-09-09 20:05         ` Andi Kleen
2008-09-09 22:24 ` David Howells
2008-09-25 13:31   ` Adrian Bunk
2008-09-25 13:51   ` David Howells
     [not found] <fa.NLANnOwj/8iuI5QjLt63gFrBDJA@ifi.uio.no>
2008-09-04 23:40 ` Robert Hancock
     [not found] <b8rB2-6BM-1@gated-at.bofh.it>
     [not found] ` <badXc-7gl-21@gated-at.bofh.it>
     [not found]   ` <baf2M-bE-7@gated-at.bofh.it>
     [not found]     ` <bagBJ-20J-7@gated-at.bofh.it>
2008-09-10 11:52       ` Bodo Eggert
2008-09-12  5:21         ` emin ak
2008-09-12 13:23           ` linux-os (Dick Johnson)
2008-09-12 14:45             ` linux-os (Dick Johnson)

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=20080909194305.GG30160@cs181140183.pp.htv.fi \
    --to=bunk@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=keithp@marvell.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®