* [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland
@ 2021-05-18 11:36 Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files Thomas De Schampheleire
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Thomas De Schampheleire @ 2021-05-18 11:36 UTC (permalink / raw)
To: buildroot
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Hello,
Even though there are already cases where a 64-bit kernel is combined with
32-bit userland, like MIPS64n32, that Buildroot can support out-of-the-box,
there are other combinations that don't currently work.
At work, we have two such cases:
- 64-bit x86_64 kernel with 32-bit i386 userspace
- 64-bit aarch64 kernel with 32-bit arm userspace
This series adds basic support for these cases, with the limitation that the
user still needs to know what they are doing.
Patch 1 is a general improvement and can land even if you don't agree
with the rest.
Patch 2 handles the realization that 'KERNEL_ARCH' can mean two different
things, and that we need two separate variables.
Patch 3 makes it possible for users to specify the kernel architecture that
differs from the Buildroot notion of userspace architecture.
Patch 4 fixes the build of perf in this mixed 64-bit-kernel+32-bit-userspace
case.
As hinted above, users that would like to employ such scenarios still need to
know what they are doing:
- the correct value of BR2_KERNEL_ARCH_OVERRIDE is to be known by the user
- the toolchain should be capable of generating both 64-bit (kernel) output as
well as 32-bit userspace output. This is typically done with a multilib
toolchain, where the default output is 64-bit so that the kernel build does
not require additional changes, while passing the correct '-mXXX' flag as
BR2_TARGET_OPTIMIZATION for the userspace compilations.
- it is not possible to create one multilib toolchain that supports Aarch64 and
(32-bit) ARM output. We have solved it by packaging two individual toolchains
in one archive, with symlinks at top-level to the 32-bit toolchain, and
some additional changes in Buildroot to make sure the 64-bit toolchain is
used where needed (kernel, bootloader)
- BR2_KERNEL_64_USERLAND_32 is not automatically passed.
An alternative implementation would be to explicitly support certain
combinations, but this is less flexible.
Best regards,
Thomas
Thomas De Schampheleire (4):
arch: move definition of KERNEL_ARCH to Config.in.<arch> files
core: introduce NORMALIZED_ARCH as non-kernel replacement for
KERNEL_ARCH
core: introduce BR2_KERNEL_ARCH_OVERRIDE
perf: fix compilation in case of i386 userspace with x86_64 kernel
Makefile | 22 +++++--------------
arch/Config.in | 18 +++++++++++++++
arch/Config.in.arc | 3 +++
arch/Config.in.arm | 4 ++++
arch/Config.in.csky | 3 +++
arch/Config.in.m68k | 3 +++
arch/Config.in.microblaze | 3 +++
arch/Config.in.mips | 3 +++
arch/Config.in.nds32 | 3 +++
arch/Config.in.nios2 | 3 +++
arch/Config.in.or1k | 3 +++
arch/Config.in.powerpc | 3 +++
arch/Config.in.riscv | 3 +++
arch/Config.in.s390x | 3 +++
arch/Config.in.sh | 3 +++
arch/Config.in.sparc | 4 ++++
arch/Config.in.x86 | 4 ++++
arch/Config.in.xtensa | 3 +++
boot/barebox/barebox.mk | 10 ++++-----
boot/uboot/uboot.mk | 6 ++---
package/busybox/busybox.mk | 2 +-
.../environment-setup/environment-setup.mk | 2 +-
package/kvmtool/kvmtool.mk | 4 ++--
package/libselinux/libselinux.mk | 2 +-
package/linux-tools/linux-tool-perf.mk.in | 7 ++++--
.../linux-tools/linux-tool-selftests.mk.in | 6 ++---
package/olsr/olsr.mk | 4 ++--
package/pciutils/pciutils.mk | 2 +-
package/uboot-tools/uboot-tools.mk | 10 ++++-----
29 files changed, 104 insertions(+), 42 deletions(-)
--
2.26.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files
2021-05-18 11:36 [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland Thomas De Schampheleire
@ 2021-05-18 11:36 ` Thomas De Schampheleire
2022-01-13 20:48 ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH Thomas De Schampheleire
` (2 subsequent siblings)
3 siblings, 1 reply; 18+ messages in thread
From: Thomas De Schampheleire @ 2021-05-18 11:36 UTC (permalink / raw)
To: buildroot
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Similar to other arch-specific strings, the 'KERNEL_ARCH' variable can be
determined from Config.in.<arch> files.
Besides aligning with similar strings, this also means simplification: the
big 'sed' covers several architectures not even supported by Buildroot.
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
Makefile | 17 +----------------
arch/Config.in | 3 +++
arch/Config.in.arc | 3 +++
arch/Config.in.arm | 4 ++++
arch/Config.in.csky | 3 +++
arch/Config.in.m68k | 3 +++
arch/Config.in.microblaze | 3 +++
arch/Config.in.mips | 3 +++
arch/Config.in.nds32 | 3 +++
arch/Config.in.nios2 | 3 +++
arch/Config.in.or1k | 3 +++
arch/Config.in.powerpc | 3 +++
arch/Config.in.riscv | 3 +++
arch/Config.in.s390x | 3 +++
arch/Config.in.sh | 3 +++
arch/Config.in.sparc | 4 ++++
arch/Config.in.x86 | 4 ++++
arch/Config.in.xtensa | 3 +++
18 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/Makefile b/Makefile
index c3305f46e9..7b6998fde6 100644
--- a/Makefile
+++ b/Makefile
@@ -433,22 +433,7 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
# Strip off the annoying quoting
ARCH := $(call qstrip,$(BR2_ARCH))
-
-KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
- -e s/i.86/i386/ -e s/sun4u/sparc64/ \
- -e s/arcle/arc/ \
- -e s/arceb/arc/ \
- -e s/arm.*/arm/ -e s/sa110/arm/ \
- -e s/aarch64.*/arm64/ \
- -e s/nds32.*/nds32/ \
- -e s/or1k/openrisc/ \
- -e s/parisc64/parisc/ \
- -e s/powerpc64.*/powerpc/ \
- -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
- -e s/riscv.*/riscv/ \
- -e s/sh.*/sh/ \
- -e s/s390x/s390/ \
- -e s/microblazeel/microblaze/)
+KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
ZCAT := $(call qstrip,$(BR2_ZCAT))
BZCAT := $(call qstrip,$(BR2_BZCAT))
diff --git a/arch/Config.in b/arch/Config.in
index 155403c363..7575acf48c 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -326,6 +326,9 @@ config BR2_ARCH_NEEDS_GCC_AT_LEAST_10
config BR2_ARCH
string
+config BR2_KERNEL_ARCH
+ string
+
config BR2_ENDIAN
string
diff --git a/arch/Config.in.arc b/arch/Config.in.arc
index f7a6d920b5..cc55c9e68f 100644
--- a/arch/Config.in.arc
+++ b/arch/Config.in.arc
@@ -62,6 +62,9 @@ config BR2_ARCH
default "arc" if BR2_arcle
default "arceb" if BR2_arceb
+config BR2_KERNEL_ARCH
+ default "arc"
+
config BR2_arc
bool
default y if BR2_arcle || BR2_arceb
diff --git a/arch/Config.in.arm b/arch/Config.in.arm
index 4c0910e4f8..0f50512fad 100644
--- a/arch/Config.in.arm
+++ b/arch/Config.in.arm
@@ -822,6 +822,10 @@ config BR2_ARCH
default "aarch64" if BR2_aarch64
default "aarch64_be" if BR2_aarch64_be
+config BR2_KERNEL_ARCH
+ default "arm" if BR2_arm || BR2_armeb
+ default "arm64" if BR2_aarch64 || BR2_aarch64_be
+
config BR2_ENDIAN
default "LITTLE" if (BR2_arm || BR2_aarch64)
default "BIG" if (BR2_armeb || BR2_aarch64_be)
diff --git a/arch/Config.in.csky b/arch/Config.in.csky
index 7e2029f759..df9e7ab75b 100644
--- a/arch/Config.in.csky
+++ b/arch/Config.in.csky
@@ -39,6 +39,9 @@ config BR2_GCC_TARGET_FLOAT_ABI
config BR2_ARCH
default "csky"
+config BR2_KERNEL_ARCH
+ default "csky"
+
config BR2_ENDIAN
default "LITTLE"
diff --git a/arch/Config.in.m68k b/arch/Config.in.m68k
index 275f47f1d3..7f3aec7232 100644
--- a/arch/Config.in.m68k
+++ b/arch/Config.in.m68k
@@ -1,6 +1,9 @@
config BR2_ARCH
default "m68k" if BR2_m68k
+config BR2_KERNEL_ARCH
+ default "m68k"
+
config BR2_ENDIAN
default "BIG"
diff --git a/arch/Config.in.microblaze b/arch/Config.in.microblaze
index 5fe2906d40..52aa252a2c 100644
--- a/arch/Config.in.microblaze
+++ b/arch/Config.in.microblaze
@@ -2,6 +2,9 @@ config BR2_ARCH
default "microblazeel" if BR2_microblazeel
default "microblaze" if BR2_microblazebe
+config BR2_KERNEL_ARCH
+ default "microblaze"
+
config BR2_ENDIAN
default "LITTLE" if BR2_microblazeel
default "BIG" if BR2_microblazebe
diff --git a/arch/Config.in.mips b/arch/Config.in.mips
index 619456c2d5..b4923f8484 100644
--- a/arch/Config.in.mips
+++ b/arch/Config.in.mips
@@ -235,6 +235,9 @@ config BR2_ARCH
default "mips64" if BR2_mips64
default "mips64el" if BR2_mips64el
+config BR2_KERNEL_ARCH
+ default "mips"
+
config BR2_ENDIAN
default "LITTLE" if BR2_mipsel || BR2_mips64el
default "BIG" if BR2_mips || BR2_mips64
diff --git a/arch/Config.in.nds32 b/arch/Config.in.nds32
index 322ff49f2e..61fc346260 100644
--- a/arch/Config.in.nds32
+++ b/arch/Config.in.nds32
@@ -1,6 +1,9 @@
config BR2_ARCH
default "nds32le"
+config BR2_KERNEL_ARCH
+ default "nds32"
+
config BR2_GCC_TARGET_ARCH
default "v3"
diff --git a/arch/Config.in.nios2 b/arch/Config.in.nios2
index aae435fa17..c77b1a1c59 100644
--- a/arch/Config.in.nios2
+++ b/arch/Config.in.nios2
@@ -1,6 +1,9 @@
config BR2_ARCH
default "nios2"
+config BR2_KERNEL_ARCH
+ default "nios2"
+
config BR2_ENDIAN
default "LITTLE"
diff --git a/arch/Config.in.or1k b/arch/Config.in.or1k
index abdf498fb8..ef1bded453 100644
--- a/arch/Config.in.or1k
+++ b/arch/Config.in.or1k
@@ -1,6 +1,9 @@
config BR2_ARCH
default "or1k"
+config BR2_KERNEL_ARCH
+ default "openrisc"
+
config BR2_ENDIAN
default "BIG"
diff --git a/arch/Config.in.powerpc b/arch/Config.in.powerpc
index ba56c9c721..33b2471cf9 100644
--- a/arch/Config.in.powerpc
+++ b/arch/Config.in.powerpc
@@ -157,6 +157,9 @@ config BR2_ARCH
default "powerpc64" if BR2_powerpc64
default "powerpc64le" if BR2_powerpc64le
+config BR2_KERNEL_ARCH
+ default "powerpc"
+
config BR2_ENDIAN
default "BIG" if BR2_powerpc || BR2_powerpc64
default "LITTLE" if BR2_powerpc64le
diff --git a/arch/Config.in.riscv b/arch/Config.in.riscv
index 1fc20e5de7..e8b6ddc833 100644
--- a/arch/Config.in.riscv
+++ b/arch/Config.in.riscv
@@ -116,6 +116,9 @@ config BR2_ARCH
default "riscv32" if !BR2_ARCH_IS_64
default "riscv64" if BR2_ARCH_IS_64
+config BR2_KERNEL_ARCH
+ default "riscv"
+
config BR2_ENDIAN
default "LITTLE"
diff --git a/arch/Config.in.s390x b/arch/Config.in.s390x
index ad866b421e..bf4b70f957 100644
--- a/arch/Config.in.s390x
+++ b/arch/Config.in.s390x
@@ -17,6 +17,9 @@ endchoice
config BR2_ARCH
default "s390x" if BR2_s390x
+config BR2_KERNEL_ARCH
+ default "s390"
+
config BR2_ENDIAN
default "BIG"
diff --git a/arch/Config.in.sh b/arch/Config.in.sh
index b5cce18e22..fde42dfce2 100644
--- a/arch/Config.in.sh
+++ b/arch/Config.in.sh
@@ -24,6 +24,9 @@ config BR2_ARCH
default "sh4a" if BR2_sh4a
default "sh4aeb" if BR2_sh4aeb
+config BR2_KERNEL_ARCH
+ default "sh"
+
config BR2_ENDIAN
default "LITTLE" if BR2_sh4 || BR2_sh4a
default "BIG" if BR2_sh2a || BR2_sh4eb || BR2_sh4aeb
diff --git a/arch/Config.in.sparc b/arch/Config.in.sparc
index 4c4dc61745..b91df6892b 100644
--- a/arch/Config.in.sparc
+++ b/arch/Config.in.sparc
@@ -21,6 +21,10 @@ config BR2_ARCH
default "sparc" if BR2_sparc
default "sparc64" if BR2_sparc64
+config BR2_KERNEL_ARCH
+ default "sparc" if BR2_sparc
+ default "sparc64" if BR2_sparc64
+
config BR2_ENDIAN
default "BIG"
diff --git a/arch/Config.in.x86 b/arch/Config.in.x86
index 7aae3cafb7..88ac9cdc44 100644
--- a/arch/Config.in.x86
+++ b/arch/Config.in.x86
@@ -266,6 +266,10 @@ config BR2_ARCH
default "i686" if BR2_x86_athlon_4
default "x86_64" if BR2_x86_64
+config BR2_KERNEL_ARCH
+ default "i386" if !BR2_x86_64
+ default "x86_64" if BR2_x86_64
+
config BR2_ENDIAN
default "LITTLE"
diff --git a/arch/Config.in.xtensa b/arch/Config.in.xtensa
index a79d906985..acc340eca6 100644
--- a/arch/Config.in.xtensa
+++ b/arch/Config.in.xtensa
@@ -48,6 +48,9 @@ config BR2_ENDIAN
config BR2_ARCH
default "xtensa" if BR2_xtensa
+config BR2_KERNEL_ARCH
+ default "xtensa"
+
config BR2_READELF_ARCH_NAME
default "Tensilica Xtensa Processor"
--
2.26.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
2021-05-18 11:36 [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files Thomas De Schampheleire
@ 2021-05-18 11:36 ` Thomas De Schampheleire
2022-01-13 21:30 ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel Thomas De Schampheleire
3 siblings, 1 reply; 18+ messages in thread
From: Thomas De Schampheleire @ 2021-05-18 11:36 UTC (permalink / raw)
To: buildroot
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
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>
---
Makefile | 1 +
boot/barebox/barebox.mk | 10 +++++-----
boot/uboot/uboot.mk | 6 +++---
package/busybox/busybox.mk | 2 +-
package/environment-setup/environment-setup.mk | 2 +-
package/kvmtool/kvmtool.mk | 4 ++--
package/libselinux/libselinux.mk | 2 +-
package/linux-tools/linux-tool-perf.mk.in | 4 ++--
package/linux-tools/linux-tool-selftests.mk.in | 6 +++---
package/olsr/olsr.mk | 4 ++--
package/pciutils/pciutils.mk | 2 +-
package/uboot-tools/uboot-tools.mk | 10 +++++-----
12 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/Makefile b/Makefile
index 7b6998fde6..c5399e9a35 100644
--- a/Makefile
+++ b/Makefile
@@ -433,6 +433,7 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
# Strip off the annoying quoting
ARCH := $(call qstrip,$(BR2_ARCH))
+NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
ZCAT := $(call qstrip,$(BR2_ZCAT))
diff --git a/boot/barebox/barebox.mk b/boot/barebox/barebox.mk
index 8f02f9f9e1..6506294d6d 100644
--- a/boot/barebox/barebox.mk
+++ b/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)"
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index dbe82e65b1..77df9c8bba 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -139,12 +139,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 += \
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index e979ac4f4b..456ed04a73 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -99,7 +99,7 @@ endif
BUSYBOX_MAKE_OPTS = \
CC="$(TARGET_CC)" \
- ARCH=$(KERNEL_ARCH) \
+ ARCH=$(NORMALIZED_ARCH) \
PREFIX="$(TARGET_DIR)" \
EXTRA_LDFLAGS="$(BUSYBOX_LDFLAGS)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
diff --git a/package/environment-setup/environment-setup.mk b/package/environment-setup/environment-setup.mk
index fcad013f0d..8e0fdff208 100644
--- a/package/environment-setup/environment-setup.mk
+++ b/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) \
diff --git a/package/kvmtool/kvmtool.mk b/package/kvmtool/kvmtool.mk
index 2984817c7e..df6ae7e0f1 100644
--- a/package/kvmtool/kvmtool.mk
+++ b/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
diff --git a/package/libselinux/libselinux.mk b/package/libselinux/libselinux.mk
index fdd13aa942..5a62b8d829 100644
--- a/package/libselinux/libselinux.mk
+++ b/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
diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
index efa747cf8d..4e28129f50 100644
--- a/package/linux-tools/linux-tool-perf.mk.in
+++ b/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 = \
diff --git a/package/linux-tools/linux-tool-selftests.mk.in b/package/linux-tools/linux-tool-selftests.mk.in
index c4e5bf0fea..b824c11bd6 100644
--- a/package/linux-tools/linux-tool-selftests.mk.in
+++ b/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
diff --git a/package/olsr/olsr.mk b/package/olsr/olsr.mk
index b2c8e7e001..4ad88991f2 100644
--- a/package/olsr/olsr.mk
+++ b/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
diff --git a/package/pciutils/pciutils.mk b/package/pciutils/pciutils.mk
index 9b83b62b55..67defcc743 100644
--- a/package/pciutils/pciutils.mk
+++ b/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 \
diff --git a/package/uboot-tools/uboot-tools.mk b/package/uboot-tools/uboot-tools.mk
index 8963d6182e..d60aaa7668 100644
--- a/package/uboot-tools/uboot-tools.mk
+++ b/package/uboot-tools/uboot-tools.mk
@@ -206,14 +206,14 @@ $(eval $(host-generic-package))
MKIMAGE = $(HOST_DIR)/bin/mkimage
# mkimage supports arm blackfin m68k microblaze mips mips64 nios2 powerpc ppc sh sparc sparc64 x86
-# KERNEL_ARCH can be arm64 arc arm blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa
-# For arm64, arc, xtensa we'll just keep KERNEL_ARCH
+# NORMALIZED_ARCH can be arm64 arc arm blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa
+# For arm64, arc, xtensa we'll just keep NORMALIZED_ARCH
# For mips64, we'll just keep mips
# For i386 and x86_64, we need to convert
-ifeq ($(KERNEL_ARCH),x86_64)
+ifeq ($(NORMALIZED_ARCH),x86_64)
MKIMAGE_ARCH = x86
-else ifeq ($(KERNEL_ARCH),i386)
+else ifeq ($(NORMALIZED_ARCH),i386)
MKIMAGE_ARCH = x86
else
-MKIMAGE_ARCH = $(KERNEL_ARCH)
+MKIMAGE_ARCH = $(NORMALIZED_ARCH)
endif
--
2.26.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2021-05-18 11:36 [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH Thomas De Schampheleire
@ 2021-05-18 11:36 ` Thomas De Schampheleire
2022-01-09 23:27 ` Romain Naour
2022-01-13 22:05 ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel Thomas De Schampheleire
3 siblings, 2 replies; 18+ messages in thread
From: Thomas De Schampheleire @ 2021-05-18 11:36 UTC (permalink / raw)
To: buildroot
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
There are 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 Buildroot, the ARCH/BR2_ARCH and NORMALIZED_ARCH variables will refer to
the 32-bit architecture, but the kernel needs to be built with the 64-bit
architecture.
Make it possible to define the correct architecture to be used for the
kernel, in a new config option 'BR2_KERNEL_ARCH_OVERRIDE'. The user is
expected to know the valid values.
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
Makefile | 4 ++++
arch/Config.in | 15 +++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/Makefile b/Makefile
index c5399e9a35..d09cf7c958 100644
--- a/Makefile
+++ b/Makefile
@@ -434,7 +434,11 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
# Strip off the annoying quoting
ARCH := $(call qstrip,$(BR2_ARCH))
NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
+ifeq ($(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),)
KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
+else
+KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE))
+endif
ZCAT := $(call qstrip,$(BR2_ZCAT))
BZCAT := $(call qstrip,$(BR2_BZCAT))
diff --git a/arch/Config.in b/arch/Config.in
index 7575acf48c..c82100f541 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -329,6 +329,21 @@ config BR2_ARCH
config BR2_KERNEL_ARCH
string
+config BR2_KERNEL_ARCH_OVERRIDE
+ string "Kernel architecture override"
+ help
+ Normally, the correct kernel architecture value is derived
+ from the selected architecture, and you should keep this
+ option empty.
+ However, there are cases where you may want to enter a custom
+ value, for example when using a 64-bit architecture but
+ running userspace in 32-bit mode.
+ As an example, in case of an x86_64 processor where you want
+ 32-bit userspace, BR2_ARCH will be 'i386'/'i486'/'i686' and
+ BR2_KERNEL_ARCH_OVERRIDE should be set to 'x86_64'. Note that
+ in this example you will also need a multilib toolchain and
+ pass '-m32' via BR2_TARGET_OPTIMIZATION.
+
config BR2_ENDIAN
string
--
2.26.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel
2021-05-18 11:36 [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland Thomas De Schampheleire
` (2 preceding siblings ...)
2021-05-18 11:36 ` [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE Thomas De Schampheleire
@ 2021-05-18 11:36 ` Thomas De Schampheleire
2022-01-13 22:15 ` Romain Naour
3 siblings, 1 reply; 18+ messages in thread
From: Thomas De Schampheleire @ 2021-05-18 11:36 UTC (permalink / raw)
To: buildroot
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
If a 64-bit kernel is combined with 32-bit userspace, and this is achieved
via a multilib toolchain that defaults to 64-bit with '-m32' in
BR2_TARGET_OPTIMIZATION, the '<cross>-ld' command will still default to
64-bit output.
In this case, packages that use 'ld' directly need to be instructed to use
the correct ABI via the '-m' parameter. 'perf' is one such package.
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
package/linux-tools/linux-tool-perf.mk.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
index 4e28129f50..b84b5fd415 100644
--- a/package/linux-tools/linux-tool-perf.mk.in
+++ b/package/linux-tools/linux-tool-perf.mk.in
@@ -45,6 +45,9 @@ PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
else
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
endif
+# case for x86 toolchain that defaults to 64-bit output
+else ifeq ($(BR2_i386):$(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),y:x86_64)
+PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf_i386"
endif
# The call to backtrace() function fails for ARC, because for some
--
2.26.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2021-05-18 11:36 ` [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE Thomas De Schampheleire
@ 2022-01-09 23:27 ` Romain Naour
2022-01-12 11:04 ` Thomas De Schampheleire
2022-01-13 22:05 ` Romain Naour
1 sibling, 1 reply; 18+ messages in thread
From: Romain Naour @ 2022-01-09 23:27 UTC (permalink / raw)
To: Thomas De Schampheleire, buildroot; +Cc: Thomas De Schampheleire
Hello Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>
> There are 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
Can you provide a new qemu defconfig that cover this use case?
This is for gitlab-ci runtime testing.
Best regards,
Romain
PS: (This email doesn't count as a review of this series :))
>
> In Buildroot, the ARCH/BR2_ARCH and NORMALIZED_ARCH variables will refer to
> the 32-bit architecture, but the kernel needs to be built with the 64-bit
> architecture.
>
> Make it possible to define the correct architecture to be used for the
> kernel, in a new config option 'BR2_KERNEL_ARCH_OVERRIDE'. The user is
> expected to know the valid values.
>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> Makefile | 4 ++++
> arch/Config.in | 15 +++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index c5399e9a35..d09cf7c958 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -434,7 +434,11 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
> # Strip off the annoying quoting
> ARCH := $(call qstrip,$(BR2_ARCH))
> NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> +ifeq ($(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),)
> KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> +else
> +KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE))
> +endif
>
> ZCAT := $(call qstrip,$(BR2_ZCAT))
> BZCAT := $(call qstrip,$(BR2_BZCAT))
> diff --git a/arch/Config.in b/arch/Config.in
> index 7575acf48c..c82100f541 100644
> --- a/arch/Config.in
> +++ b/arch/Config.in
> @@ -329,6 +329,21 @@ config BR2_ARCH
> config BR2_KERNEL_ARCH
> string
>
> +config BR2_KERNEL_ARCH_OVERRIDE
> + string "Kernel architecture override"
> + help
> + Normally, the correct kernel architecture value is derived
> + from the selected architecture, and you should keep this
> + option empty.
> + However, there are cases where you may want to enter a custom
> + value, for example when using a 64-bit architecture but
> + running userspace in 32-bit mode.
> + As an example, in case of an x86_64 processor where you want
> + 32-bit userspace, BR2_ARCH will be 'i386'/'i486'/'i686' and
> + BR2_KERNEL_ARCH_OVERRIDE should be set to 'x86_64'. Note that
> + in this example you will also need a multilib toolchain and
> + pass '-m32' via BR2_TARGET_OPTIMIZATION.
> +
> config BR2_ENDIAN
> string
>
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2022-01-09 23:27 ` Romain Naour
@ 2022-01-12 11:04 ` Thomas De Schampheleire
2022-01-12 19:10 ` Arnout Vandecappelle
0 siblings, 1 reply; 18+ messages in thread
From: Thomas De Schampheleire @ 2022-01-12 11:04 UTC (permalink / raw)
To: Romain Naour, Thomas Petazzoni; +Cc: Thomas De Schampheleire, buildroot
Hi Romain,
El lun, 10 ene 2022 a las 0:27, Romain Naour (<romain.naour@smile.fr>) escribió:
>
> Hello Thomas,
>
> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > There are 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
>
> Can you provide a new qemu defconfig that cover this use case?
> This is for gitlab-ci runtime testing.
>
> Best regards,
> Romain
>
> PS: (This email doesn't count as a review of this series :))
Thanks for your interest in this series :-)
Currently the qemu defconfig that I use uses an external toolchain
built via crosstool-ng. Crosstool-ng is capable of creating a multilib
toolchain supporting 32-bit and 64-bit binaries.
However, Buildroot does not currently support this for internal
toolchains. How do you suggest to proceed here?
Could we perhaps add a crosstool-ng-built multilib toolchain to the
Bootlin toolchains?
Thanks,
Thomas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2022-01-12 11:04 ` Thomas De Schampheleire
@ 2022-01-12 19:10 ` Arnout Vandecappelle
2022-01-12 20:06 ` Romain Naour
0 siblings, 1 reply; 18+ messages in thread
From: Arnout Vandecappelle @ 2022-01-12 19:10 UTC (permalink / raw)
To: Thomas De Schampheleire, Romain Naour, Thomas Petazzoni
Cc: Thomas De Schampheleire, buildroot
On 12/01/2022 12:04, Thomas De Schampheleire wrote:
> Hi Romain,
>
> El lun, 10 ene 2022 a las 0:27, Romain Naour (<romain.naour@smile.fr>) escribió:
>>
>> Hello Thomas,
>>
>> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
>>> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>>
>>> There are 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
>>
>> Can you provide a new qemu defconfig that cover this use case?
>> This is for gitlab-ci runtime testing.
>>
>> Best regards,
>> Romain
>>
>> PS: (This email doesn't count as a review of this series :))
>
>
> Thanks for your interest in this series :-)
>
> Currently the qemu defconfig that I use uses an external toolchain
> built via crosstool-ng. Crosstool-ng is capable of creating a multilib
> toolchain supporting 32-bit and 64-bit binaries.
> However, Buildroot does not currently support this for internal
> toolchains. How do you suggest to proceed here?
> Could we perhaps add a crosstool-ng-built multilib toolchain to the
> Bootlin toolchains?
Bootlin toolchains no - they are generated by Buildroot.
However, it would be useful to have such a toolchain as an autobuilder
toolchain. We could use it both in a 32-bit and 64-bit config. We can simply add
your binary to autobuild.buildroot.org/toolchains/tarballs and add two config
fragments to support/config-fragments/autobuild.
The same toolchain tarball can then also be used for a runtime test.
Regards,
Arnout
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2022-01-12 19:10 ` Arnout Vandecappelle
@ 2022-01-12 20:06 ` Romain Naour
0 siblings, 0 replies; 18+ messages in thread
From: Romain Naour @ 2022-01-12 20:06 UTC (permalink / raw)
To: Arnout Vandecappelle, Thomas De Schampheleire, Thomas Petazzoni
Cc: Thomas De Schampheleire, buildroot
Hello Thomas, Arnout,
Le 12/01/2022 à 20:10, Arnout Vandecappelle a écrit :
>
>
> On 12/01/2022 12:04, Thomas De Schampheleire wrote:
>> Hi Romain,
>>
>> El lun, 10 ene 2022 a las 0:27, Romain Naour (<romain.naour@smile.fr>) escribió:
>>>
>>> Hello Thomas,
>>>
>>> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
>>>> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>>>
>>>> There are 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
>>>
>>> Can you provide a new qemu defconfig that cover this use case?
>>> This is for gitlab-ci runtime testing.
>>>
>>> Best regards,
>>> Romain
>>>
>>> PS: (This email doesn't count as a review of this series :))
>>
>>
>> Thanks for your interest in this series :-)
>>
>> Currently the qemu defconfig that I use uses an external toolchain
>> built via crosstool-ng. Crosstool-ng is capable of creating a multilib
>> toolchain supporting 32-bit and 64-bit binaries.
>> However, Buildroot does not currently support this for internal
>> toolchains. How do you suggest to proceed here?
>> Could we perhaps add a crosstool-ng-built multilib toolchain to the
>> Bootlin toolchains?
>
> Bootlin toolchains no - they are generated by Buildroot.
Indeed.
> However, it would be useful to have such a toolchain as an autobuilder
> toolchain. We could use it both in a 32-bit and 64-bit config. We can simply add
> your binary to autobuild.buildroot.org/toolchains/tarballs and add two config
> fragments to support/config-fragments/autobuild.
>
> The same toolchain tarball can then also be used for a runtime test.
Agree, but we have to be able to rebuild them when needed.
A script or a simple text would be ok.
Best regards,
Romain
>
> Regards,
> Arnout
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files
2021-05-18 11:36 ` [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files Thomas De Schampheleire
@ 2022-01-13 20:48 ` Romain Naour
0 siblings, 0 replies; 18+ messages in thread
From: Romain Naour @ 2022-01-13 20:48 UTC (permalink / raw)
To: Thomas De Schampheleire, buildroot
Cc: ARC Maintainers, Guo Ren, Mark Corbin, Alexander Egorenkov,
Nylon Chen, Thomas Petazzoni, Spenser Gilliland, Cyril Bur,
Thomas De Schampheleire
Hi Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>
> Similar to other arch-specific strings, the 'KERNEL_ARCH' variable can be
> determined from Config.in.<arch> files.
>
> Besides aligning with similar strings, this also means simplification: the
> big 'sed' covers several architectures not even supported by Buildroot.
>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
Best regards,
Romain
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> Makefile | 17 +----------------
> arch/Config.in | 3 +++
> arch/Config.in.arc | 3 +++
> arch/Config.in.arm | 4 ++++
> arch/Config.in.csky | 3 +++
> arch/Config.in.m68k | 3 +++
> arch/Config.in.microblaze | 3 +++
> arch/Config.in.mips | 3 +++
> arch/Config.in.nds32 | 3 +++
> arch/Config.in.nios2 | 3 +++
> arch/Config.in.or1k | 3 +++
> arch/Config.in.powerpc | 3 +++
> arch/Config.in.riscv | 3 +++
> arch/Config.in.s390x | 3 +++
> arch/Config.in.sh | 3 +++
> arch/Config.in.sparc | 4 ++++
> arch/Config.in.x86 | 4 ++++
> arch/Config.in.xtensa | 3 +++
> 18 files changed, 55 insertions(+), 16 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index c3305f46e9..7b6998fde6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -433,22 +433,7 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
>
> # Strip off the annoying quoting
> ARCH := $(call qstrip,$(BR2_ARCH))
> -
> -KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
> - -e s/i.86/i386/ -e s/sun4u/sparc64/ \
> - -e s/arcle/arc/ \
> - -e s/arceb/arc/ \
> - -e s/arm.*/arm/ -e s/sa110/arm/ \
> - -e s/aarch64.*/arm64/ \
> - -e s/nds32.*/nds32/ \
> - -e s/or1k/openrisc/ \
> - -e s/parisc64/parisc/ \
> - -e s/powerpc64.*/powerpc/ \
> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
> - -e s/riscv.*/riscv/ \
> - -e s/sh.*/sh/ \
> - -e s/s390x/s390/ \
> - -e s/microblazeel/microblaze/)
> +KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
>
> ZCAT := $(call qstrip,$(BR2_ZCAT))
> BZCAT := $(call qstrip,$(BR2_BZCAT))
> diff --git a/arch/Config.in b/arch/Config.in
> index 155403c363..7575acf48c 100644
> --- a/arch/Config.in
> +++ b/arch/Config.in
> @@ -326,6 +326,9 @@ config BR2_ARCH_NEEDS_GCC_AT_LEAST_10
> config BR2_ARCH
> string
>
> +config BR2_KERNEL_ARCH
> + string
> +
> config BR2_ENDIAN
> string
>
> diff --git a/arch/Config.in.arc b/arch/Config.in.arc
> index f7a6d920b5..cc55c9e68f 100644
> --- a/arch/Config.in.arc
> +++ b/arch/Config.in.arc
> @@ -62,6 +62,9 @@ config BR2_ARCH
> default "arc" if BR2_arcle
> default "arceb" if BR2_arceb
>
> +config BR2_KERNEL_ARCH
> + default "arc"
> +
> config BR2_arc
> bool
> default y if BR2_arcle || BR2_arceb
> diff --git a/arch/Config.in.arm b/arch/Config.in.arm
> index 4c0910e4f8..0f50512fad 100644
> --- a/arch/Config.in.arm
> +++ b/arch/Config.in.arm
> @@ -822,6 +822,10 @@ config BR2_ARCH
> default "aarch64" if BR2_aarch64
> default "aarch64_be" if BR2_aarch64_be
>
> +config BR2_KERNEL_ARCH
> + default "arm" if BR2_arm || BR2_armeb
> + default "arm64" if BR2_aarch64 || BR2_aarch64_be
> +
> config BR2_ENDIAN
> default "LITTLE" if (BR2_arm || BR2_aarch64)
> default "BIG" if (BR2_armeb || BR2_aarch64_be)
> diff --git a/arch/Config.in.csky b/arch/Config.in.csky
> index 7e2029f759..df9e7ab75b 100644
> --- a/arch/Config.in.csky
> +++ b/arch/Config.in.csky
> @@ -39,6 +39,9 @@ config BR2_GCC_TARGET_FLOAT_ABI
> config BR2_ARCH
> default "csky"
>
> +config BR2_KERNEL_ARCH
> + default "csky"
> +
> config BR2_ENDIAN
> default "LITTLE"
>
> diff --git a/arch/Config.in.m68k b/arch/Config.in.m68k
> index 275f47f1d3..7f3aec7232 100644
> --- a/arch/Config.in.m68k
> +++ b/arch/Config.in.m68k
> @@ -1,6 +1,9 @@
> config BR2_ARCH
> default "m68k" if BR2_m68k
>
> +config BR2_KERNEL_ARCH
> + default "m68k"
> +
> config BR2_ENDIAN
> default "BIG"
>
> diff --git a/arch/Config.in.microblaze b/arch/Config.in.microblaze
> index 5fe2906d40..52aa252a2c 100644
> --- a/arch/Config.in.microblaze
> +++ b/arch/Config.in.microblaze
> @@ -2,6 +2,9 @@ config BR2_ARCH
> default "microblazeel" if BR2_microblazeel
> default "microblaze" if BR2_microblazebe
>
> +config BR2_KERNEL_ARCH
> + default "microblaze"
> +
> config BR2_ENDIAN
> default "LITTLE" if BR2_microblazeel
> default "BIG" if BR2_microblazebe
> diff --git a/arch/Config.in.mips b/arch/Config.in.mips
> index 619456c2d5..b4923f8484 100644
> --- a/arch/Config.in.mips
> +++ b/arch/Config.in.mips
> @@ -235,6 +235,9 @@ config BR2_ARCH
> default "mips64" if BR2_mips64
> default "mips64el" if BR2_mips64el
>
> +config BR2_KERNEL_ARCH
> + default "mips"
> +
> config BR2_ENDIAN
> default "LITTLE" if BR2_mipsel || BR2_mips64el
> default "BIG" if BR2_mips || BR2_mips64
> diff --git a/arch/Config.in.nds32 b/arch/Config.in.nds32
> index 322ff49f2e..61fc346260 100644
> --- a/arch/Config.in.nds32
> +++ b/arch/Config.in.nds32
> @@ -1,6 +1,9 @@
> config BR2_ARCH
> default "nds32le"
>
> +config BR2_KERNEL_ARCH
> + default "nds32"
> +
> config BR2_GCC_TARGET_ARCH
> default "v3"
>
> diff --git a/arch/Config.in.nios2 b/arch/Config.in.nios2
> index aae435fa17..c77b1a1c59 100644
> --- a/arch/Config.in.nios2
> +++ b/arch/Config.in.nios2
> @@ -1,6 +1,9 @@
> config BR2_ARCH
> default "nios2"
>
> +config BR2_KERNEL_ARCH
> + default "nios2"
> +
> config BR2_ENDIAN
> default "LITTLE"
>
> diff --git a/arch/Config.in.or1k b/arch/Config.in.or1k
> index abdf498fb8..ef1bded453 100644
> --- a/arch/Config.in.or1k
> +++ b/arch/Config.in.or1k
> @@ -1,6 +1,9 @@
> config BR2_ARCH
> default "or1k"
>
> +config BR2_KERNEL_ARCH
> + default "openrisc"
> +
> config BR2_ENDIAN
> default "BIG"
>
> diff --git a/arch/Config.in.powerpc b/arch/Config.in.powerpc
> index ba56c9c721..33b2471cf9 100644
> --- a/arch/Config.in.powerpc
> +++ b/arch/Config.in.powerpc
> @@ -157,6 +157,9 @@ config BR2_ARCH
> default "powerpc64" if BR2_powerpc64
> default "powerpc64le" if BR2_powerpc64le
>
> +config BR2_KERNEL_ARCH
> + default "powerpc"
> +
> config BR2_ENDIAN
> default "BIG" if BR2_powerpc || BR2_powerpc64
> default "LITTLE" if BR2_powerpc64le
> diff --git a/arch/Config.in.riscv b/arch/Config.in.riscv
> index 1fc20e5de7..e8b6ddc833 100644
> --- a/arch/Config.in.riscv
> +++ b/arch/Config.in.riscv
> @@ -116,6 +116,9 @@ config BR2_ARCH
> default "riscv32" if !BR2_ARCH_IS_64
> default "riscv64" if BR2_ARCH_IS_64
>
> +config BR2_KERNEL_ARCH
> + default "riscv"
> +
> config BR2_ENDIAN
> default "LITTLE"
>
> diff --git a/arch/Config.in.s390x b/arch/Config.in.s390x
> index ad866b421e..bf4b70f957 100644
> --- a/arch/Config.in.s390x
> +++ b/arch/Config.in.s390x
> @@ -17,6 +17,9 @@ endchoice
> config BR2_ARCH
> default "s390x" if BR2_s390x
>
> +config BR2_KERNEL_ARCH
> + default "s390"
> +
> config BR2_ENDIAN
> default "BIG"
>
> diff --git a/arch/Config.in.sh b/arch/Config.in.sh
> index b5cce18e22..fde42dfce2 100644
> --- a/arch/Config.in.sh
> +++ b/arch/Config.in.sh
> @@ -24,6 +24,9 @@ config BR2_ARCH
> default "sh4a" if BR2_sh4a
> default "sh4aeb" if BR2_sh4aeb
>
> +config BR2_KERNEL_ARCH
> + default "sh"
> +
> config BR2_ENDIAN
> default "LITTLE" if BR2_sh4 || BR2_sh4a
> default "BIG" if BR2_sh2a || BR2_sh4eb || BR2_sh4aeb
> diff --git a/arch/Config.in.sparc b/arch/Config.in.sparc
> index 4c4dc61745..b91df6892b 100644
> --- a/arch/Config.in.sparc
> +++ b/arch/Config.in.sparc
> @@ -21,6 +21,10 @@ config BR2_ARCH
> default "sparc" if BR2_sparc
> default "sparc64" if BR2_sparc64
>
> +config BR2_KERNEL_ARCH
> + default "sparc" if BR2_sparc
> + default "sparc64" if BR2_sparc64
> +
> config BR2_ENDIAN
> default "BIG"
>
> diff --git a/arch/Config.in.x86 b/arch/Config.in.x86
> index 7aae3cafb7..88ac9cdc44 100644
> --- a/arch/Config.in.x86
> +++ b/arch/Config.in.x86
> @@ -266,6 +266,10 @@ config BR2_ARCH
> default "i686" if BR2_x86_athlon_4
> default "x86_64" if BR2_x86_64
>
> +config BR2_KERNEL_ARCH
> + default "i386" if !BR2_x86_64
> + default "x86_64" if BR2_x86_64
> +
> config BR2_ENDIAN
> default "LITTLE"
>
> diff --git a/arch/Config.in.xtensa b/arch/Config.in.xtensa
> index a79d906985..acc340eca6 100644
> --- a/arch/Config.in.xtensa
> +++ b/arch/Config.in.xtensa
> @@ -48,6 +48,9 @@ config BR2_ENDIAN
> config BR2_ARCH
> default "xtensa" if BR2_xtensa
>
> +config BR2_KERNEL_ARCH
> + default "xtensa"
> +
> config BR2_READELF_ARCH_NAME
> default "Tensilica Xtensa Processor"
>
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
2021-05-18 11:36 ` [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH Thomas De Schampheleire
@ 2022-01-13 21:30 ` Romain Naour
2022-01-14 12:27 ` Thomas De Schampheleire
0 siblings, 1 reply; 18+ messages in thread
From: Romain Naour @ 2022-01-13 21:30 UTC (permalink / raw)
To: Thomas De Schampheleire, buildroot
Cc: Marcus Folkesson, Antoine Tenart, Yann E. MORIN,
Clayton Shotwell, Matt Weber, Thomas De Schampheleire
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>
> 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.
While reviewing this patch, I noticed that LINUX_ARCH_PATH [1] is wrong for sparc64
LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
Indeed:
$ make O=test/qemu_sparc64_sun4u_defconfig printvars VARS=LINUX_ARCH_PATH
LINUX_ARCH_PATH=/home/kubu/buildroot/test/qemu_sparc64_sun4u_defconfig/build/linux-5.15/arch/sparc64
But since LINUX_ARCH_PATH is not used for this architecture, it was not noticed.
[1] https://git.buildroot.net/buildroot/tree/linux/linux.mk?h=2021.11#n226
Remaining packages using KERNEL_ARCH actually build an out of tree kernel
module: jailhouse, linux-fusion, openpowerlink.
Reviewed-by: Romain Naour <romain.naour@gmail.com>
>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> Makefile | 1 +
> boot/barebox/barebox.mk | 10 +++++-----
> boot/uboot/uboot.mk | 6 +++---
> package/busybox/busybox.mk | 2 +-
> package/environment-setup/environment-setup.mk | 2 +-
> package/kvmtool/kvmtool.mk | 4 ++--
> package/libselinux/libselinux.mk | 2 +-
> package/linux-tools/linux-tool-perf.mk.in | 4 ++--
> package/linux-tools/linux-tool-selftests.mk.in | 6 +++---
> package/olsr/olsr.mk | 4 ++--
> package/pciutils/pciutils.mk | 2 +-
> package/uboot-tools/uboot-tools.mk | 10 +++++-----
> 12 files changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 7b6998fde6..c5399e9a35 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -433,6 +433,7 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
>
> # Strip off the annoying quoting
> ARCH := $(call qstrip,$(BR2_ARCH))
> +NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
>
> ZCAT := $(call qstrip,$(BR2_ZCAT))
> diff --git a/boot/barebox/barebox.mk b/boot/barebox/barebox.mk
> index 8f02f9f9e1..6506294d6d 100644
> --- a/boot/barebox/barebox.mk
> +++ b/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)"
> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
> index dbe82e65b1..77df9c8bba 100644
> --- a/boot/uboot/uboot.mk
> +++ b/boot/uboot/uboot.mk
> @@ -139,12 +139,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 += \
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index e979ac4f4b..456ed04a73 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -99,7 +99,7 @@ endif
>
> BUSYBOX_MAKE_OPTS = \
> CC="$(TARGET_CC)" \
> - ARCH=$(KERNEL_ARCH) \
> + ARCH=$(NORMALIZED_ARCH) \
> PREFIX="$(TARGET_DIR)" \
> EXTRA_LDFLAGS="$(BUSYBOX_LDFLAGS)" \
> CROSS_COMPILE="$(TARGET_CROSS)" \
> diff --git a/package/environment-setup/environment-setup.mk b/package/environment-setup/environment-setup.mk
> index fcad013f0d..8e0fdff208 100644
> --- a/package/environment-setup/environment-setup.mk
> +++ b/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) \
> diff --git a/package/kvmtool/kvmtool.mk b/package/kvmtool/kvmtool.mk
> index 2984817c7e..df6ae7e0f1 100644
> --- a/package/kvmtool/kvmtool.mk
> +++ b/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
>
> diff --git a/package/libselinux/libselinux.mk b/package/libselinux/libselinux.mk
> index fdd13aa942..5a62b8d829 100644
> --- a/package/libselinux/libselinux.mk
> +++ b/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
> diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
> index efa747cf8d..4e28129f50 100644
> --- a/package/linux-tools/linux-tool-perf.mk.in
> +++ b/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 = \
> diff --git a/package/linux-tools/linux-tool-selftests.mk.in b/package/linux-tools/linux-tool-selftests.mk.in
> index c4e5bf0fea..b824c11bd6 100644
> --- a/package/linux-tools/linux-tool-selftests.mk.in
> +++ b/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
>
> diff --git a/package/olsr/olsr.mk b/package/olsr/olsr.mk
> index b2c8e7e001..4ad88991f2 100644
> --- a/package/olsr/olsr.mk
> +++ b/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
> diff --git a/package/pciutils/pciutils.mk b/package/pciutils/pciutils.mk
> index 9b83b62b55..67defcc743 100644
> --- a/package/pciutils/pciutils.mk
> +++ b/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 \
> diff --git a/package/uboot-tools/uboot-tools.mk b/package/uboot-tools/uboot-tools.mk
> index 8963d6182e..d60aaa7668 100644
> --- a/package/uboot-tools/uboot-tools.mk
> +++ b/package/uboot-tools/uboot-tools.mk
> @@ -206,14 +206,14 @@ $(eval $(host-generic-package))
> MKIMAGE = $(HOST_DIR)/bin/mkimage
>
> # mkimage supports arm blackfin m68k microblaze mips mips64 nios2 powerpc ppc sh sparc sparc64 x86
> -# KERNEL_ARCH can be arm64 arc arm blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa
> -# For arm64, arc, xtensa we'll just keep KERNEL_ARCH
> +# NORMALIZED_ARCH can be arm64 arc arm blackfin m68k microblaze mips nios2 powerpc sh sparc i386 x86_64 xtensa
> +# For arm64, arc, xtensa we'll just keep NORMALIZED_ARCH
> # For mips64, we'll just keep mips
> # For i386 and x86_64, we need to convert
This part needs to be fixed due to a recent change.
Best regards,
Romain
> -ifeq ($(KERNEL_ARCH),x86_64)
> +ifeq ($(NORMALIZED_ARCH),x86_64)
> MKIMAGE_ARCH = x86
> -else ifeq ($(KERNEL_ARCH),i386)
> +else ifeq ($(NORMALIZED_ARCH),i386)
> MKIMAGE_ARCH = x86
> else
> -MKIMAGE_ARCH = $(KERNEL_ARCH)
> +MKIMAGE_ARCH = $(NORMALIZED_ARCH)
> endif
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2021-05-18 11:36 ` [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE Thomas De Schampheleire
2022-01-09 23:27 ` Romain Naour
@ 2022-01-13 22:05 ` Romain Naour
2022-01-15 19:31 ` Thomas De Schampheleire
2022-01-15 19:45 ` Thomas De Schampheleire
1 sibling, 2 replies; 18+ messages in thread
From: Romain Naour @ 2022-01-13 22:05 UTC (permalink / raw)
To: Thomas De Schampheleire, buildroot; +Cc: Thomas De Schampheleire
Hi Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>
> There are 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 Buildroot, the ARCH/BR2_ARCH and NORMALIZED_ARCH variables will refer to
> the 32-bit architecture, but the kernel needs to be built with the 64-bit
> architecture.
>
> Make it possible to define the correct architecture to be used for the
> kernel, in a new config option 'BR2_KERNEL_ARCH_OVERRIDE'. The user is
> expected to know the valid values.
>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> Makefile | 4 ++++
> arch/Config.in | 15 +++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index c5399e9a35..d09cf7c958 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -434,7 +434,11 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
> # Strip off the annoying quoting
> ARCH := $(call qstrip,$(BR2_ARCH))
> NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> +ifeq ($(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),)
> KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> +else
> +KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE))
> +endif
>
> ZCAT := $(call qstrip,$(BR2_ZCAT))
> BZCAT := $(call qstrip,$(BR2_BZCAT))
> diff --git a/arch/Config.in b/arch/Config.in
> index 7575acf48c..c82100f541 100644
> --- a/arch/Config.in
> +++ b/arch/Config.in
> @@ -329,6 +329,21 @@ config BR2_ARCH
> config BR2_KERNEL_ARCH
> string
>
> +config BR2_KERNEL_ARCH_OVERRIDE
> + string "Kernel architecture override"
Maybe it would be better to add architecture dependencies here (BR2_ARCH_IS_64)
> + help
> + Normally, the correct kernel architecture value is derived
> + from the selected architecture, and you should keep this
> + option empty.
> + However, there are cases where you may want to enter a custom
> + value, for example when using a 64-bit architecture but
> + running userspace in 32-bit mode.
> + As an example, in case of an x86_64 processor where you want
> + 32-bit userspace, BR2_ARCH will be 'i386'/'i486'/'i686' and
> + BR2_KERNEL_ARCH_OVERRIDE should be set to 'x86_64'. Note that
> + in this example you will also need a multilib toolchain and
> + pass '-m32' via BR2_TARGET_OPTIMIZATION.
Adding -m32 will force the mulitilib toolchain to produce 32bits binary.
But -m64 is also added to the toolchain wrapper for x86_64.
Mixing -m64 and -m32 doesn't seems a good idea.
Best regards,
Romain
> +
> config BR2_ENDIAN
> string
>
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel
2021-05-18 11:36 ` [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel Thomas De Schampheleire
@ 2022-01-13 22:15 ` Romain Naour
2022-01-14 9:33 ` Thomas De Schampheleire
0 siblings, 1 reply; 18+ messages in thread
From: Romain Naour @ 2022-01-13 22:15 UTC (permalink / raw)
To: Thomas De Schampheleire, buildroot; +Cc: Yann E. MORIN, Thomas De Schampheleire
Hello Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>
> If a 64-bit kernel is combined with 32-bit userspace, and this is achieved
> via a multilib toolchain that defaults to 64-bit with '-m32' in
> BR2_TARGET_OPTIMIZATION, the '<cross>-ld' command will still default to
> 64-bit output.
>
> In this case, packages that use 'ld' directly need to be instructed to use
> the correct ABI via the '-m' parameter. 'perf' is one such package.
>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
> package/linux-tools/linux-tool-perf.mk.in | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
> index 4e28129f50..b84b5fd415 100644
> --- a/package/linux-tools/linux-tool-perf.mk.in
> +++ b/package/linux-tools/linux-tool-perf.mk.in
> @@ -45,6 +45,9 @@ PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
> else
> PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
> endif
> +# case for x86 toolchain that defaults to 64-bit output
> +else ifeq ($(BR2_i386):$(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),y:x86_64)
> +PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf_i386"
Do you know why the ARM toolchain doesn't need a similar handling ?
Best regards,
Romain
> endif
>
> # The call to backtrace() function fails for ARC, because for some
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel
2022-01-13 22:15 ` Romain Naour
@ 2022-01-14 9:33 ` Thomas De Schampheleire
0 siblings, 0 replies; 18+ messages in thread
From: Thomas De Schampheleire @ 2022-01-14 9:33 UTC (permalink / raw)
To: Romain Naour; +Cc: Yann E. MORIN, Thomas De Schampheleire, buildroot
Hi Romain,
El jue, 13 ene 2022 a las 23:17, Romain Naour
(<romain.naour@gmail.com>) escribió:
>
> Hello Thomas,
>
> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > If a 64-bit kernel is combined with 32-bit userspace, and this is achieved
> > via a multilib toolchain that defaults to 64-bit with '-m32' in
> > BR2_TARGET_OPTIMIZATION, the '<cross>-ld' command will still default to
> > 64-bit output.
> >
> > In this case, packages that use 'ld' directly need to be instructed to use
> > the correct ABI via the '-m' parameter. 'perf' is one such package.
> >
> > Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> > ---
> > package/linux-tools/linux-tool-perf.mk.in | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
> > index 4e28129f50..b84b5fd415 100644
> > --- a/package/linux-tools/linux-tool-perf.mk.in
> > +++ b/package/linux-tools/linux-tool-perf.mk.in
> > @@ -45,6 +45,9 @@ PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
> > else
> > PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
> > endif
> > +# case for x86 toolchain that defaults to 64-bit output
> > +else ifeq ($(BR2_i386):$(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),y:x86_64)
> > +PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf_i386"
>
> Do you know why the ARM toolchain doesn't need a similar handling ?
If you are referring to the ARM toolchain that I am using, then yes.
For Aarch64, it seems not possible to produce a multilib toolchain
supporting ARM (32-bit) and Aarch64 (64-bit).
I don't know the details about why.
In order to support that case, we actually pack two separate
toolchains into one 'toolchain' archive, and point Buildroot to the
32-bit one (the top-level directories bin/ lib/ etc. correspond to the
32-bit one).
For Linux/u-boot we specifically point to the 64-bit toolchain.
So since they are separate toolchains, there is no '-m32' anywhere:
either toolchain has a fixed bitness.
How we could handle this situation in Buildroot is to be discussed.
These changes are not in this series.
Best regards,
Thomas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
2022-01-13 21:30 ` Romain Naour
@ 2022-01-14 12:27 ` Thomas De Schampheleire
2022-01-15 14:55 ` Romain Naour
0 siblings, 1 reply; 18+ messages in thread
From: Thomas De Schampheleire @ 2022-01-14 12:27 UTC (permalink / raw)
To: Romain Naour
Cc: Marcus Folkesson, Antoine Tenart, Yann E. MORIN, buildroot,
Clayton Shotwell, Matt Weber, Thomas De Schampheleire
Hi Romain,
El jue, 13 ene 2022 a las 22:30, Romain Naour
(<romain.naour@gmail.com>) escribió:
>
> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > 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.
>
> While reviewing this patch, I noticed that LINUX_ARCH_PATH [1] is wrong for sparc64
>
> LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
>
> Indeed:
>
> $ make O=test/qemu_sparc64_sun4u_defconfig printvars VARS=LINUX_ARCH_PATH
> LINUX_ARCH_PATH=/home/kubu/buildroot/test/qemu_sparc64_sun4u_defconfig/build/linux-5.15/arch/sparc64
>
> But since LINUX_ARCH_PATH is not used for this architecture, it was not noticed.
>
> [1] https://git.buildroot.net/buildroot/tree/linux/linux.mk?h=2021.11#n226
>
Are you sure that this is a problem?
In the kernel Makefile, some 'ARCH' strings are treated specially:
# Additional ARCH settings for x86
ifeq ($(ARCH),i386)
SRCARCH := x86
endif
ifeq ($(ARCH),x86_64)
SRCARCH := x86
endif
# Additional ARCH settings for sparc
ifeq ($(ARCH),sparc32)
SRCARCH := sparc
endif
ifeq ($(ARCH),sparc64)
SRCARCH := sparc
endif
# Additional ARCH settings for parisc
ifeq ($(ARCH),parisc64)
SRCARCH := parisc
endif
So compiling the kernel with ARCH=sparc64 is accepted, and the arch
directory will be arch/sparc . Similar to how compiling with
ARCH=x86_64 works even though arch/x86_64 does not (no longer) exist.
While I'm not familiar with sparc64, there does not seem to be a bug to me.
Thanks,
Thomas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
2022-01-14 12:27 ` Thomas De Schampheleire
@ 2022-01-15 14:55 ` Romain Naour
0 siblings, 0 replies; 18+ messages in thread
From: Romain Naour @ 2022-01-15 14:55 UTC (permalink / raw)
To: Thomas De Schampheleire
Cc: Marcus Folkesson, Antoine Tenart, Yann E. MORIN, buildroot,
Clayton Shotwell, Matt Weber, Thomas De Schampheleire
Hi Thomas,
Le 14/01/2022 à 13:27, Thomas De Schampheleire a écrit :
> Hi Romain,
>
> El jue, 13 ene 2022 a las 22:30, Romain Naour
> (<romain.naour@gmail.com>) escribió:
>>
>> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
>>> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>>
>>> 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.
>>
>> While reviewing this patch, I noticed that LINUX_ARCH_PATH [1] is wrong for sparc64
>>
>> LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
>>
>> Indeed:
>>
>> $ make O=test/qemu_sparc64_sun4u_defconfig printvars VARS=LINUX_ARCH_PATH
>> LINUX_ARCH_PATH=/home/kubu/buildroot/test/qemu_sparc64_sun4u_defconfig/build/linux-5.15/arch/sparc64
>>
>> But since LINUX_ARCH_PATH is not used for this architecture, it was not noticed.
>>
>> [1] https://git.buildroot.net/buildroot/tree/linux/linux.mk?h=2021.11#n226
>>
>
> Are you sure that this is a problem?
> In the kernel Makefile, some 'ARCH' strings are treated specially:
>
> # Additional ARCH settings for x86
> ifeq ($(ARCH),i386)
> SRCARCH := x86
> endif
> ifeq ($(ARCH),x86_64)
> SRCARCH := x86
> endif
>
> # Additional ARCH settings for sparc
> ifeq ($(ARCH),sparc32)
> SRCARCH := sparc
> endif
> ifeq ($(ARCH),sparc64)
> SRCARCH := sparc
> endif
>
> # Additional ARCH settings for parisc
> ifeq ($(ARCH),parisc64)
> SRCARCH := parisc
> endif
>
>
> So compiling the kernel with ARCH=sparc64 is accepted, and the arch
> directory will be arch/sparc . Similar to how compiling with
> ARCH=x86_64 works even though arch/x86_64 does not (no longer) exist.
>
> While I'm not familiar with sparc64, there does not seem to be a bug to me.
I mean LINUX_ARCH_PATH is a Buildroot variable from linux.mk used to copy some
files from the kernel build directory. For now LINUX_ARCH_PATH is not used for
sparc64 target but if it happens it will break.
Best regards,
Romain
>
> Thanks,
> Thomas
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2022-01-13 22:05 ` Romain Naour
@ 2022-01-15 19:31 ` Thomas De Schampheleire
2022-01-15 19:45 ` Thomas De Schampheleire
1 sibling, 0 replies; 18+ messages in thread
From: Thomas De Schampheleire @ 2022-01-15 19:31 UTC (permalink / raw)
To: Romain Naour; +Cc: Thomas De Schampheleire, buildroot
El jue, 13 ene 2022 a las 23:05, Romain Naour
(<romain.naour@gmail.com>) escribió:
>
> Hi Thomas,
>
> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > There are 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 Buildroot, the ARCH/BR2_ARCH and NORMALIZED_ARCH variables will refer to
> > the 32-bit architecture, but the kernel needs to be built with the 64-bit
> > architecture.
> >
> > Make it possible to define the correct architecture to be used for the
> > kernel, in a new config option 'BR2_KERNEL_ARCH_OVERRIDE'. The user is
> > expected to know the valid values.
> >
> > Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> > ---
> > Makefile | 4 ++++
> > arch/Config.in | 15 +++++++++++++++
> > 2 files changed, 19 insertions(+)
> >
> > diff --git a/Makefile b/Makefile
> > index c5399e9a35..d09cf7c958 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -434,7 +434,11 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
> > # Strip off the annoying quoting
> > ARCH := $(call qstrip,$(BR2_ARCH))
> > NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> > +ifeq ($(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),)
> > KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> > +else
> > +KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE))
> > +endif
> >
> > ZCAT := $(call qstrip,$(BR2_ZCAT))
> > BZCAT := $(call qstrip,$(BR2_BZCAT))
> > diff --git a/arch/Config.in b/arch/Config.in
> > index 7575acf48c..c82100f541 100644
> > --- a/arch/Config.in
> > +++ b/arch/Config.in
> > @@ -329,6 +329,21 @@ config BR2_ARCH
> > config BR2_KERNEL_ARCH
> > string
> >
> > +config BR2_KERNEL_ARCH_OVERRIDE
> > + string "Kernel architecture override"
>
> Maybe it would be better to add architecture dependencies here (BR2_ARCH_IS_64)
>
> > + help
> > + Normally, the correct kernel architecture value is derived
> > + from the selected architecture, and you should keep this
> > + option empty.
> > + However, there are cases where you may want to enter a custom
> > + value, for example when using a 64-bit architecture but
> > + running userspace in 32-bit mode.
> > + As an example, in case of an x86_64 processor where you want
> > + 32-bit userspace, BR2_ARCH will be 'i386'/'i486'/'i686' and
> > + BR2_KERNEL_ARCH_OVERRIDE should be set to 'x86_64'. Note that
> > + in this example you will also need a multilib toolchain and
> > + pass '-m32' via BR2_TARGET_OPTIMIZATION.
>
> Adding -m32 will force the mulitilib toolchain to produce 32bits binary.
> But -m64 is also added to the toolchain wrapper for x86_64.
> Mixing -m64 and -m32 doesn't seems a good idea.
Well, the last entry on the command-line counts, and since
BR2_TARGET_OPTIMIZATION is passed _after_ -m64, the -m32 wins as
expected.
It would be possible to avoid passing the -m64 but then I think we'll
have to make some assumptions about the value of KERNEL_ARCH_OVERRIDE
or only cover specific cases.
Best regards,
Thomas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
2022-01-13 22:05 ` Romain Naour
2022-01-15 19:31 ` Thomas De Schampheleire
@ 2022-01-15 19:45 ` Thomas De Schampheleire
1 sibling, 0 replies; 18+ messages in thread
From: Thomas De Schampheleire @ 2022-01-15 19:45 UTC (permalink / raw)
To: Romain Naour; +Cc: Thomas De Schampheleire, buildroot
El jue, 13 ene 2022 a las 23:05, Romain Naour
(<romain.naour@gmail.com>) escribió:
>
> Hi Thomas,
>
> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > There are 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 Buildroot, the ARCH/BR2_ARCH and NORMALIZED_ARCH variables will refer to
> > the 32-bit architecture, but the kernel needs to be built with the 64-bit
> > architecture.
> >
> > Make it possible to define the correct architecture to be used for the
> > kernel, in a new config option 'BR2_KERNEL_ARCH_OVERRIDE'. The user is
> > expected to know the valid values.
> >
> > Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> > ---
> > Makefile | 4 ++++
> > arch/Config.in | 15 +++++++++++++++
> > 2 files changed, 19 insertions(+)
> >
> > diff --git a/Makefile b/Makefile
> > index c5399e9a35..d09cf7c958 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -434,7 +434,11 @@ QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
> > # Strip off the annoying quoting
> > ARCH := $(call qstrip,$(BR2_ARCH))
> > NORMALIZED_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> > +ifeq ($(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),)
> > KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH))
> > +else
> > +KERNEL_ARCH := $(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE))
> > +endif
> >
> > ZCAT := $(call qstrip,$(BR2_ZCAT))
> > BZCAT := $(call qstrip,$(BR2_BZCAT))
> > diff --git a/arch/Config.in b/arch/Config.in
> > index 7575acf48c..c82100f541 100644
> > --- a/arch/Config.in
> > +++ b/arch/Config.in
> > @@ -329,6 +329,21 @@ config BR2_ARCH
> > config BR2_KERNEL_ARCH
> > string
> >
> > +config BR2_KERNEL_ARCH_OVERRIDE
> > + string "Kernel architecture override"
>
> Maybe it would be better to add architecture dependencies here (BR2_ARCH_IS_64)
>
Note that BR2_ARCH and BR2_ARCH_IS_64 refer to the architecture
Buildroot really uses, which in these scenarios is the 32-bit
architecture. So letting BR2_KERNEL_ARCH_OVERRIDE depend on
BR2_ARCH_IS_64 is not possible.
If we restrict the whole feature to specific cases (e.g. the two ones
that I currently need) and extend on case-by-case basis, we could be
more specific here.
Best regards,
Thomas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2022-01-15 19:45 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 11:36 [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files Thomas De Schampheleire
2022-01-13 20:48 ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH Thomas De Schampheleire
2022-01-13 21:30 ` Romain Naour
2022-01-14 12:27 ` Thomas De Schampheleire
2022-01-15 14:55 ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE Thomas De Schampheleire
2022-01-09 23:27 ` Romain Naour
2022-01-12 11:04 ` Thomas De Schampheleire
2022-01-12 19:10 ` Arnout Vandecappelle
2022-01-12 20:06 ` Romain Naour
2022-01-13 22:05 ` Romain Naour
2022-01-15 19:31 ` Thomas De Schampheleire
2022-01-15 19:45 ` Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel Thomas De Schampheleire
2022-01-13 22:15 ` Romain Naour
2022-01-14 9:33 ` Thomas De Schampheleire
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.