Skip to content

Commit e0fe0bb

Browse files
committed
kbuild: include scripts/Makefile.* only when relevant CONFIG is enabled
Currently, the top Makefile includes all of scripts/Makefile.<feature> even if the associated CONFIG option is disabled. Do not include unneeded Makefiles in order to slightly optimize the parse stage. Include $(include-y), and ignore $(include-). Signed-off-by: Masahiro Yamada <[email protected]>
1 parent faabed2 commit e0fe0bb

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,6 @@ endif
745745
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
746746
KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
747747

748-
include scripts/Makefile.kcov
749-
include scripts/Makefile.gcc-plugins
750-
751748
ifdef CONFIG_READABLE_ASM
752749
# Disable optimizations that make assembler listings hard to read.
753750
# reorder blocks reorders the control in the function
@@ -948,10 +945,15 @@ ifdef CONFIG_RETPOLINE
948945
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
949946
endif
950947

951-
include scripts/Makefile.kasan
952-
include scripts/Makefile.extrawarn
953-
include scripts/Makefile.ubsan
954-
include scripts/Makefile.kcsan
948+
# include additional Makefiles when needed
949+
include-y := scripts/Makefile.extrawarn
950+
include-$(CONFIG_KASAN) += scripts/Makefile.kasan
951+
include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
952+
include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
953+
include-$(CONFIG_KCOV) += scripts/Makefile.kcov
954+
include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
955+
956+
include $(addprefix $(srctree)/, $(include-y))
955957

956958
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
957959
KBUILD_CPPFLAGS += $(KCPPFLAGS)

scripts/Makefile.kcov

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
ifdef CONFIG_KCOV
3-
42
kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc
53
kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp
64
kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
75

86
export CFLAGS_KCOV := $(kcov-flags-y)
9-
10-
endif

scripts/Makefile.kcsan

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
ifdef CONFIG_KCSAN
3-
42
# GCC and Clang accept backend options differently. Do not wrap in cc-option,
53
# because Clang accepts "--param" even if it is unused.
64
ifdef CONFIG_CC_IS_CLANG
@@ -15,5 +13,3 @@ CFLAGS_KCSAN := -fsanitize=thread \
1513
$(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
1614
$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
1715
$(call cc-param,tsan-distinguish-volatile=1)
18-
19-
endif # CONFIG_KCSAN

scripts/Makefile.ubsan

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
ifdef CONFIG_UBSAN
3-
42
ifdef CONFIG_UBSAN_ALIGNMENT
53
CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
64
endif
@@ -26,4 +24,3 @@ endif
2624
# -fsanitize=* options makes GCC less smart than usual and
2725
# increase number of 'maybe-uninitialized false-positives
2826
CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
29-
endif

0 commit comments

Comments
 (0)