[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNASHGyzKS-d+S1GYz_L0pBxxSwk05YfvV+LK4ghZ5xx=cA@mail.gmail.com>
Date: Sun, 22 May 2022 00:38:17 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: Dan Carpenter <dan.carpenter@...cle.com>,
Michal Marek <michal.lkml@...kovi.net>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
Arnd Bergmann <arnd@...db.de>,
Changbin Du <changbin.du@...il.com>
Subject: Re: [RFC PATCH] kbuild: Add an option to enable -O1 and speed-up
compilation time
(+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/
On Sat, May 21, 2022 at 6:04 PM Christophe JAILLET
<christophe.jaillet@...adoo.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@...adoo.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
Powered by blists - more mailing lists