Le 23/05/2022 à 20:26, Nick Desaulniers a écrit :
On Sat, May 21, 2022 at 2:04 AM Christophe JAILLET
<christophe.jaillet@xxxxxxxxxx> 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.
Which is a tragedy.
As with the Rust series, I'm not a fan of this (or
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3):
https://lore.kernel.org/lkml/CAKwvOd=7QTUH69+ZbT7e8einvgcosTbDkyohmPaUBv6_y8RfrQ@xxxxxxxxxxxxxx/
These feel more like attempts to wrap every conceivable command line
flag in a kconfig option, which makes me think of that meme from
Jurassic Park: "your scientists were so preoccupied with whether or
not they could, they didn't stop to think if they should."
Not a fan. I'd ask for measurements, but that would be a request for
a "rock fetching quest" for something I still wouldn't be a fan of.
Hi,
some preliminary tests gave roughly a 5% build time speed-up with -O1.
That is to say that the impact seems quite limited, after all.
This was done on building /drivers/net/ or /drivers/net/ethernet/ only.
I don't have numbers for the impact on memory consumption.
Given the feedbacks on -O1 which is unlikely to be able to build a full
kernel and your position on yet another option for a very specific use
case, I won't push the idea further.
I'll keep it in my own tree for (small) build time improvement when
running smatch.
The idea of turning off a subset of -O2 options would just be some too
fine tuning. I'll certainly try it for my own use, but it would end to
an un-understandable list of flags in Makefile.
-O1 (or -O0) was simple. A more complex solution is way too much.
Thanks for your feedbacks.
CJ
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
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
s/slighly/slightly/
Thanks for taking time for a full review, even on something you are not
fan on. This is really appreciated.
CJ
+ memory.
+
config CC_OPTIMIZE_FOR_PERFORMANCE
bool "Optimize for performance (-O2)"
help
--
2.34.1