Skip to content

Commit 15f5db6

Browse files
committed
kbuild,arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC
arch/arc/Makefile overrides -O2 with -O3. This is the only user of ARCH_CFLAGS. There is no user of ARCH_CPPFLAGS or ARCH_AFLAGS. My plan is to remove ARCH_{CPP,A,C}FLAGS after refactoring the ARC Makefile. Currently, ARC has no way to enable -Wmaybe-uninitialized because both -O3 and -Os disable it. Enabling it will be useful for compile-testing. This commit allows allmodconfig (, which defaults to -O2) to enable it. Add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y to all the defconfig files in arch/arc/configs/ in order to keep the current config settings. Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: Vineet Gupta <[email protected]>
1 parent e2079e9 commit 15f5db6

19 files changed

+32
-14
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,12 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
723723
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
724724
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
725725

726-
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
727-
KBUILD_CFLAGS += -Os
728-
else
729-
KBUILD_CFLAGS += -O2
726+
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
727+
KBUILD_CFLAGS += -O2
728+
else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
729+
KBUILD_CFLAGS += -O3
730+
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
731+
KBUILD_CFLAGS += -Os
730732
endif
731733

732734
ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED

arch/arc/Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ endif
4848
cfi := $(call as-instr,.cfi_startproc\n.cfi_endproc,-DARC_DW2_UNWIND_AS_CFI)
4949
cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables $(cfi)
5050

51-
ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
52-
# Generic build system uses -O2, we want -O3
53-
# Note: No need to add to cflags-y as that happens anyways
54-
#
55-
# Disable the false maybe-uninitialized warings gcc spits out at -O3
56-
ARCH_CFLAGS += -O3 $(call cc-disable-warning,maybe-uninitialized,)
57-
endif
58-
5951
# small data is default for elf32 tool-chain. If not usable, disable it
6052
# This also allows repurposing GP as scratch reg to gcc reg allocator
6153
disable_small_data := y

arch/arc/configs/axs101_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
99
# CONFIG_UTS_NS is not set
1010
# CONFIG_PID_NS is not set
1111
CONFIG_BLK_DEV_INITRD=y
12+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213
CONFIG_EMBEDDED=y
1314
CONFIG_PERF_EVENTS=y
1415
# CONFIG_VM_EVENT_COUNTERS is not set

arch/arc/configs/axs103_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
99
# CONFIG_UTS_NS is not set
1010
# CONFIG_PID_NS is not set
1111
CONFIG_BLK_DEV_INITRD=y
12+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213
CONFIG_EMBEDDED=y
1314
CONFIG_PERF_EVENTS=y
1415
# CONFIG_VM_EVENT_COUNTERS is not set

arch/arc/configs/axs103_smp_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
99
# CONFIG_UTS_NS is not set
1010
# CONFIG_PID_NS is not set
1111
CONFIG_BLK_DEV_INITRD=y
12+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213
CONFIG_EMBEDDED=y
1314
CONFIG_PERF_EVENTS=y
1415
# CONFIG_VM_EVENT_COUNTERS is not set

arch/arc/configs/haps_hs_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
1010
# CONFIG_UTS_NS is not set
1111
# CONFIG_PID_NS is not set
1212
CONFIG_BLK_DEV_INITRD=y
13+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314
CONFIG_EXPERT=y
1415
CONFIG_PERF_EVENTS=y
1516
# CONFIG_COMPAT_BRK is not set

arch/arc/configs/haps_hs_smp_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
1010
# CONFIG_UTS_NS is not set
1111
# CONFIG_PID_NS is not set
1212
CONFIG_BLK_DEV_INITRD=y
13+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314
CONFIG_EMBEDDED=y
1415
CONFIG_PERF_EVENTS=y
1516
# CONFIG_VM_EVENT_COUNTERS is not set

arch/arc/configs/hsdk_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CONFIG_NAMESPACES=y
99
# CONFIG_PID_NS is not set
1010
CONFIG_BLK_DEV_INITRD=y
1111
CONFIG_BLK_DEV_RAM=y
12+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1213
CONFIG_EMBEDDED=y
1314
CONFIG_PERF_EVENTS=y
1415
# CONFIG_VM_EVENT_COUNTERS is not set

arch/arc/configs/nps_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CONFIG_HIGH_RES_TIMERS=y
66
CONFIG_IKCONFIG=y
77
CONFIG_IKCONFIG_PROC=y
88
CONFIG_BLK_DEV_INITRD=y
9+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
910
CONFIG_SYSCTL_SYSCALL=y
1011
# CONFIG_EPOLL is not set
1112
# CONFIG_SIGNALFD is not set

arch/arc/configs/nsim_700_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
1010
# CONFIG_UTS_NS is not set
1111
# CONFIG_PID_NS is not set
1212
CONFIG_BLK_DEV_INITRD=y
13+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314
CONFIG_KALLSYMS_ALL=y
1415
CONFIG_EMBEDDED=y
1516
CONFIG_PERF_EVENTS=y

arch/arc/configs/nsim_hs_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
1010
# CONFIG_UTS_NS is not set
1111
# CONFIG_PID_NS is not set
1212
CONFIG_BLK_DEV_INITRD=y
13+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314
CONFIG_KALLSYMS_ALL=y
1415
CONFIG_EMBEDDED=y
1516
CONFIG_PERF_EVENTS=y

arch/arc/configs/nsim_hs_smp_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CONFIG_NAMESPACES=y
88
# CONFIG_UTS_NS is not set
99
# CONFIG_PID_NS is not set
1010
CONFIG_BLK_DEV_INITRD=y
11+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1112
CONFIG_KALLSYMS_ALL=y
1213
CONFIG_EMBEDDED=y
1314
CONFIG_PERF_EVENTS=y

arch/arc/configs/nsimosci_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
1010
# CONFIG_UTS_NS is not set
1111
# CONFIG_PID_NS is not set
1212
CONFIG_BLK_DEV_INITRD=y
13+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314
CONFIG_KALLSYMS_ALL=y
1415
CONFIG_EMBEDDED=y
1516
CONFIG_PERF_EVENTS=y

arch/arc/configs/nsimosci_hs_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONFIG_NAMESPACES=y
1010
# CONFIG_UTS_NS is not set
1111
# CONFIG_PID_NS is not set
1212
CONFIG_BLK_DEV_INITRD=y
13+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1314
CONFIG_KALLSYMS_ALL=y
1415
CONFIG_EMBEDDED=y
1516
CONFIG_PERF_EVENTS=y

arch/arc/configs/nsimosci_hs_smp_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CONFIG_IKCONFIG_PROC=y
88
# CONFIG_UTS_NS is not set
99
# CONFIG_PID_NS is not set
1010
CONFIG_BLK_DEV_INITRD=y
11+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1112
CONFIG_PERF_EVENTS=y
1213
# CONFIG_COMPAT_BRK is not set
1314
CONFIG_KPROBES=y

arch/arc/configs/tb10x_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_INITRAMFS_SOURCE="../tb10x-rootfs.cpio"
1414
CONFIG_INITRAMFS_ROOT_UID=2100
1515
CONFIG_INITRAMFS_ROOT_GID=501
1616
# CONFIG_RD_GZIP is not set
17+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
1718
CONFIG_SYSCTL_SYSCALL=y
1819
CONFIG_KALLSYMS_ALL=y
1920
# CONFIG_AIO is not set

arch/arc/configs/vdk_hs38_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CONFIG_HIGH_RES_TIMERS=y
44
CONFIG_IKCONFIG=y
55
CONFIG_IKCONFIG_PROC=y
66
CONFIG_BLK_DEV_INITRD=y
7+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
78
CONFIG_EMBEDDED=y
89
CONFIG_PERF_EVENTS=y
910
# CONFIG_VM_EVENT_COUNTERS is not set

arch/arc/configs/vdk_hs38_smp_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CONFIG_HIGH_RES_TIMERS=y
44
CONFIG_IKCONFIG=y
55
CONFIG_IKCONFIG_PROC=y
66
CONFIG_BLK_DEV_INITRD=y
7+
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y
78
CONFIG_EMBEDDED=y
89
CONFIG_PERF_EVENTS=y
910
# CONFIG_VM_EVENT_COUNTERS is not set

init/Kconfig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,14 +1209,22 @@ choice
12091209
default CC_OPTIMIZE_FOR_PERFORMANCE
12101210

12111211
config CC_OPTIMIZE_FOR_PERFORMANCE
1212-
bool "Optimize for performance"
1212+
bool "Optimize for performance (-O2)"
12131213
help
12141214
This is the default optimization level for the kernel, building
12151215
with the "-O2" compiler flag for best performance and most
12161216
helpful compile-time warnings.
12171217

1218+
config CC_OPTIMIZE_FOR_PERFORMANCE_O3
1219+
bool "Optimize more for performance (-O3)"
1220+
depends on ARC
1221+
imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
1222+
help
1223+
Choosing this option will pass "-O3" to your compiler to optimize
1224+
the kernel yet more for performance.
1225+
12181226
config CC_OPTIMIZE_FOR_SIZE
1219-
bool "Optimize for size"
1227+
bool "Optimize for size (-Os)"
12201228
imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
12211229
help
12221230
Choosing this option will pass "-Os" to your compiler resulting

0 commit comments

Comments
 (0)