The default DEFCONFIG_<XARCH> of some architectures may not just work for nolibc test, some require extra kernel config options to enable features like console for print.
To make nolibc-test happy, a new nolibc-test-config target is added with a new NOLIBC_TEST_CONFIG macro. The macro allows store extra common options via nolibc-test-common.config and the ones by architecture (or variant) via nolibc-test-$(XARCH).config.
During the nolibc-test-config target, the above extra options will be appended to .config generated by the old DEFCONFIG_<XARCH> target or by another config target specified via the CONFIG variable (e.g. tinyconfig). At last, the 'allnoconfig' target is called with the .config as the base to let them take effect and let new missing symbols as no.
The scripts/kconfig/merge_config.sh tool is used to merge the extra config files listed in NOLIBC_TEST_CONFIG.
Suggested-by: Thomas Weißschuh linux@weissschuh.net Link: https://lore.kernel.org/lkml/67eb70d4-c9ff-4afc-bac7-7f36cc2c81bc@t-8ch.de/ Link: https://lore.kernel.org/lkml/74f6a3b5-666c-41e9-a3d5-0ed5457f20f5@t-8ch.de/ Suggested-by: Suggested-by: Willy Tarreau w@1wt.eu Link: https://lore.kernel.org/lkml/20230730061801.GA7690@1wt.eu/#t Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/Makefile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 7902b86911a5..f01b258ef19b 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -63,6 +63,10 @@ DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig DEFCONFIG = $(DEFCONFIG_$(XARCH))
+# extra configs/ files appended to .config during the nolibc-test-config target +# include common + architecture specific +NOLIBC_TEST_CONFIG = nolibc-test-common.config nolibc-test-$(XARCH).config + # optional tests to run (default = all) TEST =
@@ -192,8 +196,22 @@ MAKE_KERNEL = $(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROS KERNEL_CONFIG = $(objtree)/.config KERNEL_IMAGE = $(objtree)/$(IMAGE)
-defconfig: - $(Q)$(MAKE_KERNEL) mrproper $(DEFCONFIG) prepare +# kernel config for nolibc-test +# +# - delete the current configuration and all generated files via 'mrproper' target +# - generate .config via '$(CONFIG)' or '$(DEFCONFIG_$(XARCH))' target +# - merge extra config options from $(NOLIBC_TEST_CONFIG) files to .config +# - use merged .config as base and fills in any missing symbols with '# CONFIG_* is not set' via 'allnoconfig' target +# - prepare things we need to do before we recursively start building the kernel via 'prepare' target +# +nolibc-test-config: + $(Q)$(MAKE_KERNEL) mrproper + $(Q)$(MAKE_KERNEL) $(or $(CONFIG),$(DEFCONFIG)) + $(Q)$(srctree)/scripts/kconfig/merge_config.sh -Q -O "$(objtree)" -m "$(KERNEL_CONFIG)" $(foreach c,$(NOLIBC_TEST_CONFIG),$(wildcard $(CURDIR)/configs/$c)) + $(Q)$(MAKE_KERNEL) KCONFIG_ALLCONFIG=$(KERNEL_CONFIG) allnoconfig + $(Q)$(MAKE_KERNEL) prepare + +defconfig: nolibc-test-config
kernel: initramfs $(Q)$(MAKE_KERNEL) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs