From 19d70f97079417315cb5e2ca555418016ac395ba Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Wed, 11 Jan 2023 01:01:21 +0800 Subject: [PATCH] rockchip: build kernel with -O3 optimization --- armv8/config-6.1 | 2 ++ patches-6.1/999-linux-O3.patch | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 patches-6.1/999-linux-O3.patch diff --git a/armv8/config-6.1 b/armv8/config-6.1 index 2e20dc3..df4cec7 100644 --- a/armv8/config-6.1 +++ b/armv8/config-6.1 @@ -120,6 +120,8 @@ CONFIG_BSD_PROCESS_ACCT_V3=y # CONFIG_CACHEFILES_ONDEMAND is not set CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y CONFIG_CC_IMPLICIT_FALLTHROUGH="-Wimplicit-fallthrough=5" +# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y CONFIG_CHARGER_GPIO=y CONFIG_CHR_DEV_SG=y CONFIG_CLKSRC_MMIO=y diff --git a/patches-6.1/999-linux-O3.patch b/patches-6.1/999-linux-O3.patch new file mode 100644 index 0000000..7cd51ed --- /dev/null +++ b/patches-6.1/999-linux-O3.patch @@ -0,0 +1,41 @@ +diff --git a/Makefile b/Makefile +index 56afd1509..10b3a59b4 100644 +--- a/Makefile ++++ b/Makefile +@@ -823,6 +823,9 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) + ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE + KBUILD_CFLAGS += -O2 + KBUILD_RUSTFLAGS += -Copt-level=2 ++else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 ++KBUILD_CFLAGS += -O3 ++KBUILD_RUSTFLAGS += -Copt-level=3 + else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE + KBUILD_CFLAGS += -Os + KBUILD_RUSTFLAGS += -Copt-level=s +diff --git a/init/Kconfig b/init/Kconfig +index 94125d3b6..8ecbc5e96 100644 +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -1405,7 +1405,7 @@ config INITRAMFS_PRESERVE_MTIME + + choice + prompt "Compiler optimization level" +- default CC_OPTIMIZE_FOR_PERFORMANCE ++ default CC_OPTIMIZE_FOR_PERFORMANCE_O3 + + config CC_OPTIMIZE_FOR_PERFORMANCE + bool "Optimize for performance (-O2)" +@@ -1414,6 +1414,13 @@ config CC_OPTIMIZE_FOR_PERFORMANCE + with the "-O2" compiler flag for best performance and most + helpful compile-time warnings. + ++config CC_OPTIMIZE_FOR_PERFORMANCE_O3 ++ bool "Optimize more for performance (-O3)" ++ imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED ++ help ++ Choosing this option will pass "-O3" to your compiler to optimize ++ the kernel yet more for performance. ++ + config CC_OPTIMIZE_FOR_SIZE + bool "Optimize for size (-Os)" + help