Use -O3 build optimization flag for base and BORE kernels

Signed-off-by: Krzysztof Wilczyński <kwilczynski@omarchy.org>
This commit is contained in:
Krzysztof Wilczyński committed 2026-09-17 18:25:54 +09:00
1 parent 52cba6cd95
commit 1b8e0f3845
8 files changed
+78 -4

No files matched your search

@@ -0,0 +1,31 @@
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -935,6 +935,9 @@ KBUILD_RUSTFLAGS += -Copt-level=2
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += -Os
KBUILD_RUSTFLAGS += -Copt-level=s
+else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
+KBUILD_CFLAGS += -O3
+KBUILD_RUSTFLAGS += -Copt-level=3
endif
# Always set `debug-assertions` and `overflow-checks` because their default
diff --git a/init/Kconfig b/init/Kconfig
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1622,6 +1622,14 @@ config CC_OPTIMIZE_FOR_SIZE
Choosing this option will pass "-Os" to your compiler resulting
in a smaller kernel.
+config CC_OPTIMIZE_FOR_PERFORMANCE_O3
+ bool "Optimize harder for performance (-O3)"
+ help
+ Build with the "-O3" compiler flag: more inlining, loop
+ unrolling and vectorization than -O2, at the cost of a larger
+ kernel image and larger modules. Rust code is built at
+ opt-level 3.
+
endchoice
config HAVE_LD_DEAD_CODE_DATA_ELIMINATION