Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <masahiroy@kernel.org>

+9 -18
+9 -7
Makefile
··· 745 745 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) 746 746 KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) 747 747 748 - include scripts/Makefile.kcov 749 - include scripts/Makefile.gcc-plugins 750 - 751 748 ifdef CONFIG_READABLE_ASM 752 749 # Disable optimizations that make assembler listings hard to read. 753 750 # reorder blocks reorders the control in the function ··· 945 948 KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) 946 949 endif 947 950 948 - include scripts/Makefile.kasan 949 - include scripts/Makefile.extrawarn 950 - include scripts/Makefile.ubsan 951 - include scripts/Makefile.kcsan 951 + # include additional Makefiles when needed 952 + include-y := scripts/Makefile.extrawarn 953 + include-$(CONFIG_KASAN) += scripts/Makefile.kasan 954 + include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan 955 + include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan 956 + include-$(CONFIG_KCOV) += scripts/Makefile.kcov 957 + include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins 958 + 959 + include $(addprefix $(srctree)/, $(include-y)) 952 960 953 961 # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments 954 962 KBUILD_CPPFLAGS += $(KCPPFLAGS)
-4
scripts/Makefile.kcov
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - ifdef CONFIG_KCOV 3 - 4 2 kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc 5 3 kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp 6 4 kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so 7 5 8 6 export CFLAGS_KCOV := $(kcov-flags-y) 9 - 10 - endif
-4
scripts/Makefile.kcsan
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - ifdef CONFIG_KCSAN 3 - 4 2 # GCC and Clang accept backend options differently. Do not wrap in cc-option, 5 3 # because Clang accepts "--param" even if it is unused. 6 4 ifdef CONFIG_CC_IS_CLANG ··· 13 15 $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \ 14 16 $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \ 15 17 $(call cc-param,tsan-distinguish-volatile=1) 16 - 17 - endif # CONFIG_KCSAN
-3
scripts/Makefile.ubsan
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - ifdef CONFIG_UBSAN 3 - 4 2 ifdef CONFIG_UBSAN_ALIGNMENT 5 3 CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) 6 4 endif ··· 24 26 # -fsanitize=* options makes GCC less smart than usual and 25 27 # increase number of 'maybe-uninitialized false-positives 26 28 CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized) 27 - endif