mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Changbin Du <changbin.du@gmail.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Changbin Du <changbin.du@gmail.com>
Subject: Re: [RFC PATCH] kbuild: Add an option to enable -O1 and speed-up compilation time
Date: Mon, 23 May 2022 20:34:36 +0800	[thread overview]
Message-ID: <20220523123436.b5gwj55xacc2hxcv@mail.google.com> (raw)
In-Reply-To: <CAK7LNASHGyzKS-d+S1GYz_L0pBxxSwk05YfvV+LK4ghZ5xx=cA@mail.gmail.com>

On Sun, May 22, 2022 at 12:38:17AM +0900, Masahiro Yamada wrote:
> (+CC: Arnd, Changbin Du)
> 
> 
> If -O1 support does not require additional effort,
> I have no objection to this patch.
> 
> (but I do not have enough insight about
> the compiler's inlining heuristic)
> 
> 
> 
> BTW, when we attempted to add the -Og support,
> we fixed various parts, and Linus rejected it.
> 
> https://lore.kernel.org/linux-kbuild/CAK7LNARQggM3aKEPRKJqa4tunFAfmfErMZuS-rrnRv6UB1VpPQ@mail.gmail.com/
> 
> 
> 
> 
> 
> 
> 
I am afraid that '-O1' has the same situation with '-Og'. As described in GCC
mannual:

Like -O0, -Og completely disables a number of optimization passes so that 
individual options controlling them have no effect. Otherwise -Og enables all
-O1 optimization flags except for those that may interfere with debugging:
 -fbranch-count-reg  -fdelayed-branch 
 -fdse  -fif-conversion  -fif-conversion2  
 -finline-functions-called-once 
 -fmove-loop-invariants  -fmove-loop-stores  -fssa-phiopt 
 -ftree-bit-ccp  -ftree-dse  -ftree-pta  -ftree-sra


> On Sat, May 21, 2022 at 6:04 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
> >
> > Add a new compilation option which speeds-up compilation time.
> > This can be useful when using static checker such as smatch or build-bots.
> > In such cases, the speed and quality of the generated code is not
> > important.
> >
> > Using -O0 would be even better, but unfortunately, building fails with
> > this option.
> >
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> >  Makefile     | 5 ++++-
> >  init/Kconfig | 8 ++++++++
> >  2 files changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 1f8bef92868f..14467386f947 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -817,7 +817,10 @@ KBUILD_CFLAGS      += $(call cc-disable-warning, format-truncation)
> >  KBUILD_CFLAGS  += $(call cc-disable-warning, format-overflow)
> >  KBUILD_CFLAGS  += $(call cc-disable-warning, address-of-packed-member)
> >
> > -ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
> > +ifdef CONFIG_CC_OPTIMIZE_FOR_COMPILATION_SPEED
> > +KBUILD_CFLAGS += -O1
> > +KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 1
> > +else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
> >  KBUILD_CFLAGS += -O2
> >  KBUILD_RUSTFLAGS_OPT_LEVEL_MAP := 2
> >  else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
> > diff --git a/init/Kconfig b/init/Kconfig
> > index a96776a9b080..3177a1830c9a 100644
> > --- a/init/Kconfig
> > +++ b/init/Kconfig
> > @@ -1384,6 +1384,14 @@ choice
> >         prompt "Compiler optimization level"
> >         default CC_OPTIMIZE_FOR_PERFORMANCE
> >
> > +config CC_OPTIMIZE_FOR_COMPILATION_SPEED
> > +       bool "Optimize for compilation speed (-O1)"
> > +       help
> > +         This option can be useful when running a static checker such as smatch
> > +         or a build-bot.
> > +         Compilation time is slighly faster than -O2 and it requires less
> > +         memory.
> > +
> >  config CC_OPTIMIZE_FOR_PERFORMANCE
> >         bool "Optimize for performance (-O2)"
> >         help
> > --
> > 2.34.1
> >
> 
> 
> -- 
> Best Regards
> Masahiro Yamada

-- 
Cheers,
Changbin Du

  reply	other threads:[~2022-05-23 12:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21  9:04 Christophe JAILLET
2022-05-21 15:38 ` Masahiro Yamada
2022-05-23 12:34   ` Changbin Du [this message]
2022-05-23 12:50     ` Arnd Bergmann
2022-05-23 18:26 ` Nick Desaulniers
2022-05-23 20:16   ` Christophe JAILLET
2022-05-23 20:31     ` Nick Desaulniers
2022-05-24 14:16   ` Miguel Ojeda
2022-05-23 20:25 ` Miguel Ojeda
2022-05-23 20:44   ` Christophe JAILLET
2022-05-24 14:16     ` Miguel Ojeda

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=20220523123436.b5gwj55xacc2hxcv@mail.google.com \
    --to=changbin.du@gmail.com \
    --cc=arnd@arndb.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    /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®