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