Ver código fonte

core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH

The variable 'KERNEL_ARCH' is actually a normalized version of
'ARCH'/'BR2_ARCH'. For example, 'arcle' and 'arceb' both become 'arc', just
as all powerpc variants become 'powerpc'.

It is presumably called 'KERNEL_ARCH' because the Linux kernel is typically
the first place where support for a new architecture is added, and thus is
the entity that defines the normalized name.

However, the term 'KERNEL_ARCH' can also be interpreted as 'the architecture
used by the kernel', which need not be exactly the same as 'the normalized
name for a certain arch'. In particular, for cases where a 64-bit
architecture is running a 64-bit kernel but 32-bit userspace. Examples
include:
    * aarch64 architecture, with aarch64 kernel and 32-bit (ARM) userspace
    * x86_64 architecture, with x86_64 kernel and 32-bit (i386) userspace

In such cases, the 'architecture used by the kernel' needs to refer to the
64-bit name (aarch64, x86_64), whereas all userspace applications need to
refer the, potentially normalized, 32-bit name.

This means that there need to be two different variables:

KERNEL_ARCH:     the architecture used by the kernel
NORMALIZED_ARCH: the normalized name for the current userspace architecture

At this moment, both will actually have the same content. But a subsequent
patch will add basic support for situations described above, in which
KERNEL_ARCH may become overwritten to the 64-bit architecture, while
NORMALIZED_ARCH needs to remain the same (32-bit) case.

This commit replaces use of KERNEL_ARCH where actually the userspace arch is
needed.  Places that use KERNEL_ARCH in combination with building of kernel
modules are not touched.
There may be cases where a package builds both a kernel module as userspace,
in which case it may need to know about both KERNEL_ARCH and
NORMALIZED_ARCH, for the case where they differ. But this is to be fixed on
a per-need basis.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
[Arnout: Also rename BR2_KERNEL_ARCH to BR2_NORMALIZED_ARCH]
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Thomas De Schampheleire 3 anos atrás
pai
commit
dd8a410eaf

+ 2 - 1
Makefile

@@ -437,7 +437,8 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
 
 # Strip off the annoying quoting
 ARCH := $(call qstrip,$(BR2_ARCH))
-KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
+NORMALIZED_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH))
+KERNEL_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH))
 
 ZCAT := $(call qstrip,$(BR2_ZCAT))
 BZCAT := $(call qstrip,$(BR2_BZCAT))

+ 1 - 1
arch/Config.in

@@ -328,7 +328,7 @@ config BR2_ARCH_NEEDS_GCC_AT_LEAST_11
 config BR2_ARCH
 	string
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	string
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.arc

@@ -62,7 +62,7 @@ config BR2_ARCH
 	default "arc"	if BR2_arcle
 	default "arceb"	if BR2_arceb
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "arc"
 
 config BR2_arc

+ 1 - 1
arch/Config.in.arm

@@ -822,7 +822,7 @@ config BR2_ARCH
 	default "aarch64"	if BR2_aarch64
 	default "aarch64_be"	if BR2_aarch64_be
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "arm"		if BR2_arm || BR2_armeb
 	default "arm64"		if BR2_aarch64 || BR2_aarch64_be
 

+ 1 - 1
arch/Config.in.csky

@@ -39,7 +39,7 @@ config BR2_GCC_TARGET_FLOAT_ABI
 config BR2_ARCH
 	default "csky"
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "csky"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.m68k

@@ -1,7 +1,7 @@
 config BR2_ARCH
 	default "m68k"		if BR2_m68k
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "m68k"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.microblaze

@@ -2,7 +2,7 @@ config BR2_ARCH
 	default "microblazeel"  if BR2_microblazeel
 	default "microblaze"    if BR2_microblazebe
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "microblaze"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.mips

@@ -235,7 +235,7 @@ config BR2_ARCH
 	default "mips64"	if BR2_mips64
 	default "mips64el"	if BR2_mips64el
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "mips"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.nds32

@@ -1,7 +1,7 @@
 config BR2_ARCH
 	default "nds32le"
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "nds32"
 
 config BR2_GCC_TARGET_ARCH

+ 1 - 1
arch/Config.in.nios2

@@ -1,7 +1,7 @@
 config BR2_ARCH
 	default "nios2"
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "nios2"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.or1k

@@ -1,7 +1,7 @@
 config BR2_ARCH
 	default "or1k"
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "openrisc"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.powerpc

@@ -157,7 +157,7 @@ config BR2_ARCH
 	default "powerpc64"	if BR2_powerpc64
 	default "powerpc64le"	if BR2_powerpc64le
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "powerpc"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.riscv

@@ -118,7 +118,7 @@ config BR2_ARCH
 	default "riscv32" if !BR2_ARCH_IS_64
 	default "riscv64" if BR2_ARCH_IS_64
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "riscv"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.s390x

@@ -17,7 +17,7 @@ endchoice
 config BR2_ARCH
 	default "s390x"	if BR2_s390x
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "s390"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.sh

@@ -24,7 +24,7 @@ config BR2_ARCH
 	default "sh4a"		if BR2_sh4a
 	default "sh4aeb"	if BR2_sh4aeb
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "sh"
 
 config BR2_ENDIAN

+ 1 - 1
arch/Config.in.sparc

@@ -21,7 +21,7 @@ config BR2_ARCH
 	default "sparc"	if BR2_sparc
 	default "sparc64" if BR2_sparc64
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "sparc"	if BR2_sparc
 	default "sparc64" if BR2_sparc64
 

+ 1 - 1
arch/Config.in.x86

@@ -564,7 +564,7 @@ config BR2_ARCH
 	default "i686"		if BR2_i386
 	default "x86_64"	if BR2_x86_64
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "i386"		if !BR2_x86_64
 	default "x86_64"	if BR2_x86_64
 

+ 1 - 1
arch/Config.in.xtensa

@@ -48,7 +48,7 @@ config BR2_ENDIAN
 config BR2_ARCH
 	default "xtensa"	if BR2_xtensa
 
-config BR2_KERNEL_ARCH
+config BR2_NORMALIZED_ARCH
 	default "xtensa"
 
 config BR2_READELF_ARCH_NAME

+ 5 - 5
boot/barebox/barebox.mk

@@ -59,16 +59,16 @@ ifneq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
 $(1)_INSTALL_TARGET = NO
 endif
 
-ifeq ($$(KERNEL_ARCH),i386)
+ifeq ($$(NORMALIZED_ARCH),i386)
 $(1)_ARCH = x86
-else ifeq ($$(KERNEL_ARCH),x86_64)
+else ifeq ($$(NORMALIZED_ARCH),x86_64)
 $(1)_ARCH = x86
-else ifeq ($$(KERNEL_ARCH),powerpc)
+else ifeq ($$(NORMALIZED_ARCH),powerpc)
 $(1)_ARCH = ppc
-else ifeq ($$(KERNEL_ARCH),arm64)
+else ifeq ($$(NORMALIZED_ARCH),arm64)
 $(1)_ARCH = arm
 else
-$(1)_ARCH = $$(KERNEL_ARCH)
+$(1)_ARCH = $$(NORMALIZED_ARCH)
 endif
 
 $(1)_MAKE_FLAGS = ARCH=$$($(1)_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)"

+ 3 - 3
boot/uboot/uboot.mk

@@ -143,12 +143,12 @@ endif
 
 # The kernel calls AArch64 'arm64', but U-Boot calls it just 'arm', so
 # we have to special case it. Similar for i386/x86_64 -> x86
-ifeq ($(KERNEL_ARCH),arm64)
+ifeq ($(NORMALIZED_ARCH),arm64)
 UBOOT_ARCH = arm
-else ifneq ($(filter $(KERNEL_ARCH),i386 x86_64),)
+else ifneq ($(filter $(NORMALIZED_ARCH),i386 x86_64),)
 UBOOT_ARCH = x86
 else
-UBOOT_ARCH = $(KERNEL_ARCH)
+UBOOT_ARCH = $(NORMALIZED_ARCH)
 endif
 
 UBOOT_MAKE_OPTS += \

+ 1 - 1
package/busybox/busybox.mk

@@ -95,7 +95,7 @@ BUSYBOX_MAKE_OPTS = \
 	NM="$(TARGET_NM)" \
 	RANLIB="$(TARGET_RANLIB)" \
 	CC="$(TARGET_CC)" \
-	ARCH=$(KERNEL_ARCH) \
+	ARCH=$(NORMALIZED_ARCH) \
 	PREFIX="$(TARGET_DIR)" \
 	EXTRA_LDFLAGS="$(BUSYBOX_LDFLAGS)" \
 	CROSS_COMPILE="$(TARGET_CROSS)" \

+ 1 - 1
package/environment-setup/environment-setup.mk

@@ -11,7 +11,7 @@ define HOST_ENVIRONMENT_SETUP_INSTALL_CMDS
 	for var in $(TARGET_CONFIGURE_OPTS); do \
 		printf "export \"$$var\"\n" >> $(ENVIRONMENT_SETUP_FILE); \
 	done
-	printf "export \"ARCH=$(KERNEL_ARCH)\"\n" >> $(ENVIRONMENT_SETUP_FILE)
+	printf "export \"ARCH=$(NORMALIZED_ARCH)\"\n" >> $(ENVIRONMENT_SETUP_FILE)
 	printf "export \"CROSS_COMPILE=$(TARGET_CROSS)\"\n" >> $(ENVIRONMENT_SETUP_FILE)
 	printf "export \"CONFIGURE_FLAGS=--target=$(GNU_TARGET_NAME) \
 		--host=$(GNU_TARGET_NAME) \

+ 2 - 2
package/kvmtool/kvmtool.mk

@@ -25,11 +25,11 @@ KVMTOOL_MAKE_OPTS = \
 	WERROR=0
 
 define KVMTOOL_BUILD_CMDS
-	$(TARGET_MAKE_ENV) ARCH=$(KERNEL_ARCH) $(MAKE) -C $(@D) $(KVMTOOL_MAKE_OPTS)
+	$(TARGET_MAKE_ENV) ARCH=$(NORMALIZED_ARCH) $(MAKE) -C $(@D) $(KVMTOOL_MAKE_OPTS)
 endef
 
 define KVMTOOL_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) ARCH=$(KERNEL_ARCH) $(MAKE) -C $(@D) \
+	$(TARGET_MAKE_ENV) ARCH=$(NORMALIZED_ARCH) $(MAKE) -C $(@D) \
 		$(KVMTOOL_MAKE_OPTS) install DESTDIR=$(TARGET_DIR) prefix=/usr
 endef
 

+ 1 - 1
package/libselinux/libselinux.mk

@@ -18,7 +18,7 @@ LIBSELINUX_INSTALL_STAGING = YES
 # we won't have to use a relative path in 0002-revert-ln-relative.patch
 LIBSELINUX_MAKE_OPTS = \
 	$(TARGET_CONFIGURE_OPTS) \
-	ARCH=$(KERNEL_ARCH) \
+	ARCH=$(NORMALIZED_ARCH) \
 	SHLIBDIR=/usr/lib
 
 LIBSELINUX_MAKE_INSTALL_TARGETS = install

+ 2 - 2
package/linux-tools/linux-tool-perf.mk.in

@@ -8,10 +8,10 @@ LINUX_TOOLS += perf
 
 PERF_DEPENDENCIES = host-flex host-bison
 
-ifeq ($(KERNEL_ARCH),x86_64)
+ifeq ($(NORMALIZED_ARCH),x86_64)
 PERF_ARCH=x86
 else
-PERF_ARCH=$(KERNEL_ARCH)
+PERF_ARCH=$(NORMALIZED_ARCH)
 endif
 
 PERF_MAKE_FLAGS = \

+ 3 - 3
package/linux-tools/linux-tool-selftests.mk.in

@@ -6,13 +6,13 @@
 
 LINUX_TOOLS += selftests
 
-ifeq ($(KERNEL_ARCH),x86_64)
+ifeq ($(NORMALIZED_ARCH),x86_64)
 SELFTESTS_ARCH=x86
 else
-ifeq ($(KERNEL_ARCH),i386)
+ifeq ($(NORMALIZED_ARCH),i386)
 SELFTESTS_ARCH=x86
 else
-SELFTESTS_ARCH=$(KERNEL_ARCH)
+SELFTESTS_ARCH=$(NORMALIZED_ARCH)
 endif
 endif
 

+ 2 - 2
package/olsr/olsr.mk

@@ -27,10 +27,10 @@ OLSR_PLUGINS += pud
 endif
 
 define OLSR_BUILD_CMDS
-	$(TARGET_CONFIGURE_OPTS) $(MAKE) ARCH=$(KERNEL_ARCH) \
+	$(TARGET_CONFIGURE_OPTS) $(MAKE) ARCH=$(NORMALIZED_ARCH) \
 		CFLAGS="$(OLSR_CFLAGS)" -C $(@D) olsrd
 	$(foreach p,$(OLSR_PLUGINS), \
-		$(TARGET_CONFIGURE_OPTS) $(MAKE) ARCH=$(KERNEL_ARCH) \
+		$(TARGET_CONFIGURE_OPTS) $(MAKE) ARCH=$(NORMALIZED_ARCH) \
 			CFLAGS="$(OLSR_CFLAGS)" -C $(@D)/lib/$(p)
 	)
 endef

+ 1 - 1
package/pciutils/pciutils.mk

@@ -12,7 +12,7 @@ PCIUTILS_LICENSE = GPL-2.0+
 PCIUTILS_LICENSE_FILES = COPYING
 PCIUTILS_MAKE_OPTS = \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
-	HOST="$(KERNEL_ARCH)-linux" \
+	HOST="$(NORMALIZED_ARCH)-linux" \
 	OPT="$(TARGET_CFLAGS)" \
 	LDFLAGS="$(TARGET_LDFLAGS)" \
 	DNS=no \

+ 5 - 5
package/uboot-tools/uboot-tools.mk

@@ -224,14 +224,14 @@ $(eval $(host-generic-package))
 MKIMAGE = $(HOST_DIR)/bin/mkimage
 
 # mkimage supports alpha arc arm arm64 blackfin ia64 invalid m68k microblaze mips mips64 nds32 nios2 or1k powerpc riscv s390 sandbox sh sparc sparc64 x86 x86_64 xtensa
-# KERNEL_ARCH can be arm64 arc arm blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa
+# NORMALIZED_ARCH can be arm64 arc arm blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa
 # For i386, we need to convert
 # For openrisc, we need to convert
-# For others, we'll just keep KERNEL_ARCH
-ifeq ($(KERNEL_ARCH),i386)
+# For others, we'll just keep NORMALIZED_ARCH
+ifeq ($(NORMALIZED_ARCH),i386)
 MKIMAGE_ARCH = x86
-else ifeq ($(KERNEL_ARCH),openrisc)
+else ifeq ($(NORMALIZED_ARCH),openrisc)
 MKIMAGE_ARCH = or1k
 else
-MKIMAGE_ARCH = $(KERNEL_ARCH)
+MKIMAGE_ARCH = $(NORMALIZED_ARCH)
 endif