]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Always save architecture with savedefconfig
authorSimon Kuenzer <simon@unikraft.io>
Fri, 8 Sep 2023 17:37:46 +0000 (19:37 +0200)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:32:28 +0000 (19:32 +0300)
With `savedefconfig`, KConfig creates a file that contains only options
that are different from the default selection. Because the build system
automatically detects the host architecture and sets the default
architecture to this detected architecture, the architecture is never
part of the defconfig file if the architecture in the configuration
matches the host architecture. This becomes problematic as soon as such
a file is loaded on a build environment that has a different host
architecture: The configuration can fail because of architectural
configuration differences.

This commit ensures that the configured architecture is always stored
in the defconfig file. The `savedefconfig` target appends the configured
architecture to the file if the architectures between host and config
match.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1084

Makefile
arch/Makefile.rules

index ba7b592adb86ad911d38a2169f8662830b80d8b2..3af8beeeb9e7fb1f91718f1997a2e7c209829273 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -969,6 +969,10 @@ defconfig:
 
 savedefconfig:
        @$(COMMON_CONFIG_ENV) $(KPYTHON) $(CONFIGLIB)/savedefconfig.py --kconfig $(CONFIG_CONFIG_IN) --out $(DEFCONFIG)
+ifeq ($(HOSTARCH),$(CONFIG_UK_ARCH))
+       @# Make sure arch is stored in the file even if arch matches between host and config
+       @echo "$(call ukarch_str2cfg,$(CONFIG_UK_ARCH))=y" >> $(DEFCONFIG)
+endif
 
 oldconfig:
        @$(COMMON_CONFIG_ENV) $(KPYTHON) $(CONFIGLIB)/oldconfig.py $(CONFIG_CONFIG_IN)
@@ -1043,6 +1047,11 @@ savedefconfig: $(KCONFIG_DIR)/conf
        @$(COMMON_CONFIG_ENV) $< \
                --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
                $(CONFIG_CONFIG_IN)
+ifeq ($(HOSTARCH),$(CONFIG_UK_ARCH))
+       @# Make sure arch is stored in the file even if arch matches between host and config
+       @echo "$(call ukarch_str2cfg,$(CONFIG_UK_ARCH))=y" >> \
+               $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
+endif
 
 .PHONY: defconfig savedefconfig silentoldconfig
 
index 69e98d47ea0028fb9e64f845c100671bd7076054..6513b1d3801d44dd2b8a9dcbef8d45993072262d 100644 (file)
@@ -19,3 +19,19 @@ endef
 define aarch64_no_reserved_tcb_overlap =
        $(eval LIBCONTEXT_CFLAGS-y+=-DCONFIG_AARCH64_NO_TCB_OVERLAP=1)
 endef
+
+# Converts an architecture string to the corresponding name of a configuration
+# variable
+# WARNING: This function might need to get modified as sson as we introduce
+#          another (external) architecture. This is is only necessary if the
+#          following assumption will note be valid:
+#          This function intents that for any future architecture the
+#          configuration name of matches with its name string, like we we have
+#          with x86: For example, the architecture string is called "x86_64" and
+#          its configuration name just contains this string in capital letters:
+#          `CONFIG_ARCH_X86_64`
+# Usage:
+#  $(call ukarch_str2cfg,"<architecture name>")
+define ukarch_str2cfg =
+$(addprefix CONFIG_ARCH_,$(call uc,$(subst arm,ARM_32,$(subst arm64,ARM_64,$(1)))))
+endef