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>
This commit is contained in:
Thomas De Schampheleire
2022-01-15 21:03:00 +01:00
committed by Arnout Vandecappelle (Essensium/Mind)
parent cf198e2299
commit dd8a410eaf
29 changed files with 45 additions and 44 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

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

View File

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

View File

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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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