Basic support for 64-bit kernel and 32-bit userland
Subsystems (3)
v2 cover Basic support for 64-bit kernel and 32-bit userland
From: Thomas De Schampheleire <[email protected]>
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.
Patch 5 prepares host-qemu for the case of x86_64. I'm not very fond of the fact that this does not provide a generic solution.
Patch 6 adds a new qemu defconfig for x86_64 kernel and x86 userspace, that employs the new logic.
Finally patch 7 corrects LINUX_ARCH_PATH for sparc64, not directly related to this series but reported by Romain Naour during his review.
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 (7):
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 package/qemu: add support for overridden KERNEL_ARCH=x86_64
configs: add new qemu defconfig 'x86_multilib' linux/linux.mk: correct LINUX_ARCH_PATH for sparc64
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 + board/qemu/x86_multilib/linux.config | 57 +++++++++++++++++++ board/qemu/x86_multilib/post-build.sh | 11 ++++ board/qemu/x86_multilib/readme.txt | 7 +++ boot/barebox/barebox.mk | 10 ++-- boot/uboot/uboot.mk | 6 +- configs/qemu_x86_multilib_defconfig | 26 +++++++++ linux/linux.mk | 2 + 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/qemu/qemu.mk | 3 + package/uboot-tools/uboot-tools.mk | 10 ++-- 35 files changed, 210 insertions(+), 42 deletions(-) create mode 100644 board/qemu/x86_multilib/linux.config create mode 100755 board/qemu/x86_multilib/post-build.sh create mode 100644 board/qemu/x86_multilib/readme.txt create mode 100644 configs/qemu_x86_multilib_defconfig
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/7 arch: move definition of KERNEL_ARCH to Config.in.<arch> files
From: Thomas De Schampheleire <[email protected]>
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.
--- 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(-)
Makefile +1 -16
@@ -437,22 +437,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))
arch/Config.in +3 -0
@@ -328,6 +328,9 @@ config BR2_ARCH_NEEDS_GCC_AT_LEAST_11 config BR2_ARCH string +config BR2_KERNEL_ARCH + string + config BR2_ENDIAN string
arch/Config.in.arc +3 -0
@@ -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
arch/Config.in.arm +4 -0
@@ -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)
arch/Config.in.csky +3 -0
@@ -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"
arch/Config.in.m68k +3 -0
@@ -1,6 +1,9 @@ config BR2_ARCH default "m68k" if BR2_m68k +config BR2_KERNEL_ARCH + default "m68k" + config BR2_ENDIAN default "BIG"
arch/Config.in.microblaze +3 -0
@@ -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
arch/Config.in.mips +3 -0
@@ -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
arch/Config.in.nds32 +3 -0
@@ -1,6 +1,9 @@ config BR2_ARCH default "nds32le" +config BR2_KERNEL_ARCH + default "nds32" + config BR2_GCC_TARGET_ARCH default "v3"
arch/Config.in.nios2 +3 -0
@@ -1,6 +1,9 @@ config BR2_ARCH default "nios2" +config BR2_KERNEL_ARCH + default "nios2" + config BR2_ENDIAN default "LITTLE"
arch/Config.in.or1k +3 -0
@@ -1,6 +1,9 @@ config BR2_ARCH default "or1k" +config BR2_KERNEL_ARCH + default "openrisc" + config BR2_ENDIAN default "BIG"
arch/Config.in.powerpc +3 -0
@@ -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
arch/Config.in.riscv +3 -0
@@ -118,6 +118,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"
arch/Config.in.s390x +3 -0
@@ -17,6 +17,9 @@ endchoice config BR2_ARCH default "s390x" if BR2_s390x +config BR2_KERNEL_ARCH + default "s390" + config BR2_ENDIAN default "BIG"
arch/Config.in.sh +3 -0
@@ -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
arch/Config.in.sparc +4 -0
@@ -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"
arch/Config.in.x86 +4 -0
@@ -337,6 +337,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"
arch/Config.in.xtensa +3 -0
@@ -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"
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Arnout Vandecappelle
AppliedRe: [Buildroot] [PATCHv2 1/7] arch: move definition of KERNEL_ARCH to Config.in.<arch> files
Quoted 10 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
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 <[email protected]>Reviewed-by Romain Naour <[email protected]>
Applied to master, thanks.
Regards,
Arnout
Quoted 282 lines
--- 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(-)Makefile +1
-16@@ -437,22 +437,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))arch/Config.in +3
-0@@ -328,6 +328,9 @@ config BR2_ARCH_NEEDS_GCC_AT_LEAST_11 config BR2_ARCH string +config BR2_KERNEL_ARCH + string + config BR2_ENDIAN stringarch/Config.in.arc +3
-0@@ -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_arcebarch/Config.in.arm +4
-0@@ -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)arch/Config.in.csky +3
-0@@ -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"arch/Config.in.m68k +3
-0@@ -1,6 +1,9 @@ config BR2_ARCH default "m68k" if BR2_m68k +config BR2_KERNEL_ARCH + default "m68k" + config BR2_ENDIAN default "BIG"arch/Config.in.microblaze +3
-0@@ -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_microblazebearch/Config.in.mips +3
-0@@ -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_mips64arch/Config.in.nds32 +3
-0@@ -1,6 +1,9 @@ config BR2_ARCH default "nds32le" +config BR2_KERNEL_ARCH + default "nds32" + config BR2_GCC_TARGET_ARCH default "v3"arch/Config.in.nios2 +3
-0@@ -1,6 +1,9 @@ config BR2_ARCH default "nios2" +config BR2_KERNEL_ARCH + default "nios2" + config BR2_ENDIAN default "LITTLE"arch/Config.in.or1k +3
-0@@ -1,6 +1,9 @@ config BR2_ARCH default "or1k" +config BR2_KERNEL_ARCH + default "openrisc" + config BR2_ENDIAN default "BIG"arch/Config.in.powerpc +3
-0@@ -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_powerpc64learch/Config.in.riscv +3
-0@@ -118,6 +118,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"arch/Config.in.s390x +3
-0@@ -17,6 +17,9 @@ endchoice config BR2_ARCH default "s390x" if BR2_s390x +config BR2_KERNEL_ARCH + default "s390" + config BR2_ENDIAN default "BIG"arch/Config.in.sh +3
-0@@ -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_sh4aebarch/Config.in.sparc +4
-0@@ -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"arch/Config.in.x86 +4
-0@@ -337,6 +337,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"arch/Config.in.xtensa +0
-0
arch/Config.in.xtensa config BR2_ENDIAN · line 56
Quoted 9 lines
arch/Config.in.xtensa +3
-0@@ -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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 2/7 core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
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.
--- 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(-)
Makefile +1 -0
@@ -437,6 +437,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))
boot/barebox/barebox.mk +5 -5
@@ -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)"
boot/uboot/uboot.mk +3 -3
@@ -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 += \
package/busybox/busybox.mk +1 -1
@@ -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)" \
package/environment-setup/environment-setup.mk +1 -1
@@ -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) \
package/kvmtool/kvmtool.mk +2 -2
@@ -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
package/libselinux/libselinux.mk +1 -1
@@ -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
package/linux-tools/linux-tool-perf.mk.in +2 -2
@@ -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 = \
package/linux-tools/linux-tool-selftests.mk.in +3 -3
@@ -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
package/olsr/olsr.mk +2 -2
@@ -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
package/pciutils/pciutils.mk +1 -1
@@ -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 \
package/uboot-tools/uboot-tools.mk +5 -5
@@ -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
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Arnout Vandecappelle
AppliedRe: [Buildroot] [PATCHv2 2/7] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
Quoted 40 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
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_64architecture, withx86_64kernel and 32-bit (i386) userspaceIn 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 architectureAt this moment, both will actually have the same content. But a subsequent patch will add basic support for situations described above, in which
KERNEL_ARCHmay become overwritten to the 64-bit architecture, whileNORMALIZED_ARCHneeds to remain the same (32-bit) case.This commit replaces use of
KERNEL_ARCHwhere actually the userspace arch is needed. Places that useKERNEL_ARCHin 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 bothKERNEL_ARCHandNORMALIZED_ARCH, for the case where they differ. But this is to be fixed on a per-need basis.
Quoted 2 lines
Signed-off-by Thomas De Schampheleire <[email protected]>Reviewed-by Romain Naour <[email protected]>
I also renamed BR2_KERNEL_ARCH introduced in the previous patch toBR2_NORMALIZED_ARCH.
Applied to master, thanks.
Regards,
Arnout
Quoted 213 lines
--- 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(-)Makefile +1
-0@@ -437,6 +437,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))boot/barebox/barebox.mk +5
-5@@ -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)"boot/uboot/uboot.mk +3
-3@@ -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 += \package/busybox/busybox.mk +1
-1@@ -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)" \package/environment-setup/environment-setup.mk +1
-1@@ -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) \package/kvmtool/kvmtool.mk +2
-2@@ -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 endefpackage/libselinux/libselinux.mk +1
-1@@ -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 = installpackage/linux-tools/linux-tool-perf.mk.in +2
-2@@ -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 = \package/linux-tools/linux-tool-selftests.mk.in +3
-3@@ -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 endifpackage/olsr/olsr.mk +2
-2@@ -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) ) endefpackage/pciutils/pciutils.mk +1
-1@@ -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 \package/uboot-tools/uboot-tools.mk +1
-3@@ -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)
package/uboot-tools/uboot-tools.mk $(eval $(host-generic-package)) · line 237
Quoted 10 lines
package/uboot-tools/uboot-tools.mk +4
-2+# 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
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 3/7 core: introduce BR2_KERNEL_ARCH_OVERRIDE
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
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.
--- Makefile | 4 ++++ arch/Config.in | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
Makefile +4 -0
@@ -438,7 +438,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))
arch/Config.in +15 -0
@@ -331,6 +331,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
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 4/7 perf: fix compilation in case of i386 userspace with x86_64 kernel
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
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.
--- package/linux-tools/linux-tool-perf.mk.in | 3 +++ 1 file changed, 3 insertions(+)
package/linux-tools/linux-tool-perf.mk.in +3 -0
@@ -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
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 5/7 package/qemu: add support for overridden KERNEL_ARCH=x86_64
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
When the kernel architecture is overridden via BR2_KERNEL_ARCH_OVERRIDE, this has an impact on the required architecture for qemu-system.
The correct architecture for Qemu is currently determined based on ARCH, not KERNEL_ARCH. For example, while KERNEL_ARCH is 'powerpc' for all PowerPC variants, ARCH may be powerpc, powerpc64 or powerpc64le. And this translates to ppc, ppc64 and ppc64le for Qemu.
This means that it is not generically possible to determine the Qemu architecture based on KERNEL_ARCH alone.
For now, already handle the case of x86_64.
--- package/qemu/qemu.mk | 3 +++ 1 file changed, 3 insertions(+)
package/qemu/qemu.mk +3 -0
@@ -302,6 +302,9 @@ endif ifeq ($(HOST_QEMU_ARCH),sh4aeb) HOST_QEMU_ARCH = sh4eb endif +ifeq ($(call qstrip,$(BR2_KERNEL_ARCH_OVERRIDE)),x86_64) +HOST_QEMU_SYS_ARCH = x86_64 +endif HOST_QEMU_SYS_ARCH ?= $(HOST_QEMU_ARCH) HOST_QEMU_CFLAGS = $(HOST_CFLAGS)
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 6/7 configs: add new qemu defconfig 'x86_multilib'
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
Add a new qemu defconfig for an x86_64 target that will run an x86_64 kernel but userspace in 32-bit (x86) mode, using BR2_KERNEL_ARCH_OVERRIDE.
---
Note that the defconfig refers to a toolchain at autobuild.buildroot.org, but is not yet present at that location. I uploaded the toolchain temporarily to:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
md5sum:b085c0d8f137c078f8f09d116d8364f8
sha256sum 2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
board/qemu/x86_multilib/linux.config | 57 +++++++++++++++++++++++++++ board/qemu/x86_multilib/post-build.sh | 11 ++++++ board/qemu/x86_multilib/readme.txt | 7 ++++ configs/qemu_x86_multilib_defconfig | 26 ++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 board/qemu/x86_multilib/linux.config create mode 100755 board/qemu/x86_multilib/post-build.sh create mode 100644 board/qemu/x86_multilib/readme.txt create mode 100644 configs/qemu_x86_multilib_defconfig
board/qemu/x86_multilib/linux.config new file +57 -0
@@ -0,0 +1,57 @@ +CONFIG_SYSVIPC=y +# CONFIG_USELIB is not set +CONFIG_CGROUPS=y +CONFIG_SMP=y +CONFIG_HYPERVISOR_GUEST=y +CONFIG_PARAVIRT=y +CONFIG_IA32_EMULATION=y +# CONFIG_COMPAT_32BIT_TIME is not set +# CONFIG_GCC_PLUGINS is not set +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_WIRELESS is not set +CONFIG_PCI=y +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_VIRTIO_BLK=y +CONFIG_BLK_DEV_SD=y +CONFIG_SCSI_VIRTIO=y +CONFIG_ATA=y +CONFIG_ATA_PIIX=y +CONFIG_NETDEVICES=y +CONFIG_VIRTIO_NET=y +CONFIG_NE2K_PCI=y +CONFIG_8139CP=y +# CONFIG_WLAN is not set +CONFIG_INPUT_EVDEV=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_VIRTIO_CONSOLE=y +CONFIG_HW_RANDOM_VIRTIO=m +CONFIG_DRM=y +CONFIG_DRM_QXL=y +CONFIG_DRM_VIRTIO_GPU=y +CONFIG_DRM_BOCHS=y +CONFIG_SOUND=y +CONFIG_SND=y +CONFIG_SND_HDA_INTEL=y +CONFIG_SND_HDA_GENERIC=y +CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_UHCI_HCD=y +CONFIG_USB_STORAGE=y +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_BALLOON=y +CONFIG_VIRTIO_INPUT=y +CONFIG_VIRTIO_MMIO=y +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y +CONFIG_EXT4_FS=y +CONFIG_AUTOFS4_FS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_UNWINDER_FRAME_POINTER=y
board/qemu/x86_multilib/post-build.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh + +set -u +set -e + +# Add a console on tty1 +if [ -e ${TARGET_DIR}/etc/inittab ]; then + grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \ + sed -i '/GENERIC_SERIAL/a\ +tty1::respawn:/sbin/getty -L tty1 0 vt100 # QEMU graphical window' ${TARGET_DIR}/etc/inittab +fi
board/qemu/x86_multilib/readme.txt new file +7 -0
@@ -0,0 +1,7 @@ +Run the emulation with: + + qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append "rootwait root=/dev/vda console=tty1 console=ttyS0" -serial stdio -net nic,model=virtio -net user # qemu_x86_multilib_defconfig + +Optionally add -smp N to emulate a SMP system with N CPUs. + +The login prompt will appear in the graphical window.
configs/qemu_x86_multilib_defconfig new file +26 -0
@@ -0,0 +1,26 @@ +BR2_KERNEL_ARCH_OVERRIDE="x86_64" +BR2_x86_core2=y +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y +BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y +BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz" +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="x86_64-multilib-linux-gnu" +BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_15=y +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y +# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set +BR2_TOOLCHAIN_EXTERNAL_CXX=y +BR2_TARGET_OPTIMIZATION="-m32" +BR2_SYSTEM_DHCP="eth0" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_multilib/post-build.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_multilib/linux.config" +BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y +BR2_TARGET_ROOTFS_EXT2=y +# BR2_TARGET_ROOTFS_TAR is not set +BR2_PACKAGE_HOST_QEMU=y +BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCHv2 6/7] configs: add new qemu defconfig 'x86_multilib'
Hi,
Quoted 7 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
Add a new qemu defconfig for an
x86_64target that will run anx86_64kernel but userspace in 32-bit (x86) mode, usingBR2_KERNEL_ARCH_OVERRIDE.Signed-off-by Thomas De Schampheleire <[email protected]>
Quoted 10 lines
---
Note that the defconfig refers to a toolchain at autobuild.buildroot.org, but is not yet present at that location. I uploaded the toolchain temporarily to:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
md5sum:b085c0d8f137c078f8f09d116d8364f8
sha256sum2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
Romain Naour notified me that this toolchain does not run on the GCC Farm (Illegal instruction) so I made a new version, currently uploaded at:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
md5sum: 3cee64f82675446ad255f6c165786eb5
sha256sum: 6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1
Best regards,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCHv2 6/7] configs: add new qemu defconfig 'x86_multilib'
Hello Thomas,
Le 18/01/2022 à 12:19, Thomas De Schampheleire a écrit :
Quoted 22 lines
Hi,
Quoted 7 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
Add a new qemu defconfig for an
x86_64target that will run anx86_64kernel but userspace in 32-bit (x86) mode, usingBR2_KERNEL_ARCH_OVERRIDE.Signed-off-by Thomas De Schampheleire <[email protected]>Quoted 10 lines
---
Note that the defconfig refers to a toolchain at autobuild.buildroot.org, but is not yet present at that location. I uploaded the toolchain temporarily to:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
md5sum:b085c0d8f137c078f8f09d116d8364f8
sha256sum2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
Quoted 6 lines
Romain Naour notified me that this toolchain does not run on the GCC Farm (Illegal instruction) so I made a new version, currently uploaded at:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
md5sum:3cee64f82675446ad255f6c165786eb5
sha256sum:6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1
This toolchain doesn't work either.
Did you tried with CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64" ? With CT_EXTRA_CXXFLAGS_FOR_BUILD maybe or both.
Also, building with a Debian jessie docker container would allow to run the toolchain with old Glibc.
Best regards,
Romain
Quoted 4 lines
Best regards,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCHv2 6/7] configs: add new qemu defconfig 'x86_multilib'
Hi Romain,
Quoted 33 lines · Romain Naour
Hello Thomas,
Quoted 22 lines · Thomas De Schampheleire
Hi,
Quoted 7 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
Add a new qemu defconfig for an
x86_64target that will run anx86_64kernel but userspace in 32-bit (x86) mode, usingBR2_KERNEL_ARCH_OVERRIDE.Signed-off-by Thomas De Schampheleire <[email protected]>Quoted 10 lines
---
Note that the defconfig refers to a toolchain at autobuild.buildroot.org, but is not yet present at that location. I uploaded the toolchain temporarily to:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
md5sum:b085c0d8f137c078f8f09d116d8364f8
sha256sum2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2Quoted 6 lines
Romain Naour notified me that this toolchain does not run on the GCC Farm (Illegal instruction) so I made a new version, currently uploaded at:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
md5sum:3cee64f82675446ad255f6c165786eb5
sha256sum:6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1
Quoted 4 lines
This toolchain doesn't work either.
Did you tried with CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64" ? With
CT_EXTRA_CXXFLAGS_FOR_BUILDmaybe or both.
So you get the same error of 'Illegal instruction' ?
Following config was used (both the config as the build log are part of the archive):
CT_CONFIG_VERSION="3"
# CT_PREFIX_DIR_RO is not set
CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64"
CT_EXTRA_CXXFLAGS_FOR_BUILD="-march=x86-64"
CT_ARCH_X86=y
CT_MULTILIB=y
CT_ARCH_64=y
CT_STATIC_TOOLCHAIN=y
CT_TARGET_VENDOR="multilib"
CT_KERNEL_LINUX=y
CT_GLIBC_KERNEL_VERSION_NONE=y
# CT_CREATE_LDSO_CONF is not set
CT_CC_GCC_MULTILIB_LIST="m64,m32"
CT_CC_GCC_LNK_HASH_STYLE_BOTH=y
CT_CC_LANG_CXX=y
CT_DEBUG_GDB=y
CT_ZLIB_NEEDED=y
Quoted 3 lines
Also, building with a Debian jessie docker container would allow to run the toolchain with old Glibc.
The toolchain is built statically, so the glibc version on the host does not matter.
Perhaps I misunderstand the problem you are referring to?
Thanks,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCHv2 6/7] configs: add new qemu defconfig 'x86_multilib'
Hi Thomas,
Le 18/01/2022 à 13:02, Thomas De Schampheleire a écrit :
Quoted 47 lines
Hi Romain,
Quoted 33 lines · Romain Naour
Hello Thomas,
Quoted 22 lines · Thomas De Schampheleire
Hi,
Quoted 7 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
Add a new qemu defconfig for an
x86_64target that will run anx86_64kernel but userspace in 32-bit (x86) mode, usingBR2_KERNEL_ARCH_OVERRIDE.Signed-off-by Thomas De Schampheleire <[email protected]>Quoted 10 lines
---
Note that the defconfig refers to a toolchain at autobuild.buildroot.org, but is not yet present at that location. I uploaded the toolchain temporarily to:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
md5sum:b085c0d8f137c078f8f09d116d8364f8
sha256sum2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2Quoted 6 lines
Romain Naour notified me that this toolchain does not run on the GCC Farm (Illegal instruction) so I made a new version, currently uploaded at:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
md5sum:3cee64f82675446ad255f6c165786eb5
sha256sum:6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1Quoted 4 lines
This toolchain doesn't work either.
Did you tried with CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64" ? With
CT_EXTRA_CXXFLAGS_FOR_BUILDmaybe or both.So you get the same error of 'Illegal instruction' ?
Following config was used (both the config as the build log are part of the archive):
Quoted 8 lines
CT_CONFIG_VERSION="3"
#CT_PREFIX_DIR_ROis not set
CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64"
CT_EXTRA_CXXFLAGS_FOR_BUILD="-march=x86-64"
CT_ARCH_X86=y
CT_MULTILIB=y
CT_ARCH_64=y
CT_STATIC_TOOLCHAIN=y
I didn't enabled static toolchain option. Can you try without it.
Notes: All Bootlin toolchain use glibc installed on the host, so we can't use really old systems.
Quoted 13 lines
CT_TARGET_VENDOR="multilib"
CT_KERNEL_LINUX=y
CT_GLIBC_KERNEL_VERSION_NONE=y
#CT_CREATE_LDSO_CONFis not set
CT_CC_GCC_MULTILIB_LIST="m64,m32"
CT_CC_GCC_LNK_HASH_STYLE_BOTH=y
CT_CC_LANG_CXX=y
CT_DEBUG_GDB=y
CT_ZLIB_NEEDED=yQuoted 1 line
Quoted 6 lines
Quoted 2 lines
Also, building with a Debian jessie docker container would allow to run the toolchain with old Glibc.
The toolchain is built statically, so the glibc version on the host does not matter.
Perhaps I misunderstand the problem you are referring to?
I missed that your toolchain was build statically. Usually other prebuilt toolchain are not built statically.
Best regards,
Romain
Quoted 4 lines
Thanks,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 7/7 linux/linux.mk: correct LINUX_ARCH_PATH for sparc64
In reply to Thomas De SchampheleireFrom: Thomas De Schampheleire <[email protected]>
Buildroot uses variable LINUX_ARCH_PATH to refer to the arch-specific directory in the Linux tree, which may not necessarily be arch/$(KERNEL_ARCH).
Buildroot already accounts for the case of KERNEL_ARCH=i386 and KERNEL_ARCH=x86_64, but does not for KERNEL_ARCH=sparc64, in which case the correct directory is arch/sparc.
--- linux/linux.mk | 2 ++ 1 file changed, 2 insertions(+)
linux/linux.mk +2 -0
@@ -242,6 +242,8 @@ ifeq ($(KERNEL_ARCH),i386) LINUX_ARCH_PATH = $(LINUX_DIR)/arch/x86 else ifeq ($(KERNEL_ARCH),x86_64) LINUX_ARCH_PATH = $(LINUX_DIR)/arch/x86 +else ifeq ($(KERNEL_ARCH),sparc64) +LINUX_ARCH_PATH = $(LINUX_DIR)/arch/sparc else LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH) endif
Signature · 6 lines
2.32.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCHv2 7/7] linux/linux.mk: correct LINUX_ARCH_PATH for sparc64
Quoted 11 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
Buildroot uses variable
LINUX_ARCH_PATHto refer to the arch-specific directory in the Linux tree, which may not necessarily be arch/$(KERNEL_ARCH).Buildroot already accounts for the case of KERNEL_ARCH=i386 and KERNEL_ARCH=x86_64, but does not for KERNEL_ARCH=sparc64, in which case the correct directory is
arch/sparc.Reported-by Romain Naour <[email protected]>Signed-off-by Thomas De Schampheleire <[email protected]>
AFAIU this is completely independent of the rest of the series, so I applied
to master, thanks.
Regards,
Arnout
Quoted 9 lines
--- linux/linux.mk | 2 ++ 1 file changed, 2 insertions(+)linux/linux.mk +0
-0
linux/linux.mk ifeq ($(KERNEL_ARCH),i386) · line 249
Quoted 8 lines
linux/linux.mk +2
-0@@ -242,6 +242,8 @@ ifeq ($(KERNEL_ARCH),i386) LINUX_ARCH_PATH = $(LINUX_DIR)/arch/x86 else ifeq ($(KERNEL_ARCH),x86_64) LINUX_ARCH_PATH = $(LINUX_DIR)/arch/x86 +else ifeq ($(KERNEL_ARCH),sparc64) +LINUX_ARCH_PATH = $(LINUX_DIR)/arch/sparc else LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH) endif
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 54 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
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-bitx86_64kernel with 32-bit i386 userspace
- 64-bit aarch64 kernel with 32-bit arm userspaceThis 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.
Patch 5 prepares host-qemu for the case of
x86_64. I'm not very fond of the fact that this does not provide a generic solution.Patch 6 adds a new qemu defconfig for
x86_64kernel and x86 userspace, that employs the new logic.Finally patch 7 corrects
LINUX_ARCH_PATHfor sparc64, not directly related to this series but reported by Romain Naour during his review.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_OVERRIDEis 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_OPTIMIZATIONfor 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)
Quoted 5 lines
-
BR2_KERNEL_64_USERLAND_32is not automatically passed.An alternative implementation would be to explicitly support certain combinations, but this is less flexible.
So, I'm not entirely convinced about this approach. Here are my objections.
- At least for arm, you need an entirely different toolchain for the 32 and the 64-bit variants. But even for x86, the Buildroot internal toolchain for x86_64 doesn't support -m32. So for most users this is not even going to work.
- There is an alternative: two separate Buildroot configs, one for the kernel + modules, one for userspace.
- I don't think the flexibility is useful. I think it would be better to reuse the BR2_KERNEL_64_USERLAND_32 option. (E.g. add an option to Config.in.x86 when the arch is x86_64 to build a 32-bit userspace.) That way we can use it to pass -m32 where needed, to build an internal toolchain that supports it, and to check for the external toolchain if it supports it. Doesn't solve the issue for ARM, but it's a start.
Also, I think we absolutely need to test this feature. At the very least, we'd
need to config in the autobuilders that enables it, or enable it randomly in genrandconfig. Although I'm not sure if it tests anything if no kernel is built (let alone that it's not even booted).
For now, I've left the rest of the series as New in patchwork, let's see what
the others think.
Regards,
Arnout
Quoted 50 lines
Best regards,
ThomasThomas De Schampheleire (7):
arch: move definition ofKERNEL_ARCHto Config.in.<arch> files
core: introduceNORMALIZED_ARCHas non-kernel replacement for
KERNEL_ARCH
core: introduceBR2_KERNEL_ARCH_OVERRIDE
perf: fix compilation in case of i386 userspace withx86_64kernel package/qemu: add support for overridden KERNEL_ARCH=x86_64
configs: add new qemu defconfig 'x86_multilib'linux/linux.mk: correctLINUX_ARCH_PATHfor sparc64Makefile | 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 + board/qemu/x86_multilib/linux.config | 57 +++++++++++++++++++ board/qemu/x86_multilib/post-build.sh | 11 ++++ board/qemu/x86_multilib/readme.txt | 7 +++ boot/barebox/barebox.mk | 10 ++-- boot/uboot/uboot.mk | 6 +- configs/qemu_x86_multilib_defconfig | 26 +++++++++ linux/linux.mk | 2 + 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/qemu/qemu.mk | 3 + package/uboot-tools/uboot-tools.mk | 10 ++-- 35 files changed, 210 insertions(+), 42 deletions(-)
Quoted 5 lines
create mode 100644
board/qemu/x86_multilib/linux.configcreate mode 100755board/qemu/x86_multilib/post-build.shcreate mode 100644board/qemu/x86_multilib/readme.txtcreate mode 100644 configs/qemu_x86_multilib_defconfig
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Arnout,
Quoted 61 lines · Arnout Vandecappelle
Quoted 57 lines · Thomas De Schampheleire
From: Thomas De Schampheleire <[email protected]>
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-bitx86_64kernel with 32-bit i386 userspace
- 64-bit aarch64 kernel with 32-bit arm userspaceThis 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.
Patch 5 prepares host-qemu for the case of
x86_64. I'm not very fond of the fact that this does not provide a generic solution.Patch 6 adds a new qemu defconfig for
x86_64kernel and x86 userspace, that employs the new logic.Finally patch 7 corrects
LINUX_ARCH_PATHfor sparc64, not directly related to this series but reported by Romain Naour during his review.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_OVERRIDEis 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_OPTIMIZATIONfor 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_32is not automatically passed.
Quoted 8 lines
Quoted 2 lines
An alternative implementation would be to explicitly support certain combinations, but this is less flexible.
So, I'm not entirely convinced about this approach. Here are my objections.
- At least for arm, you need an entirely different toolchain for the 32 and the 64-bit variants. But even for x86, the Buildroot internal toolchain for
x86_64doesn't support -m32. So for most users this is not even going to work.
With crosstool-ng it is possible to build a multilib toolchain for x86 without issue. It's true that the internal Buildroot logic does not allow this currently, but that by itself is not necessarily an objection to me.
For ARM we have packaged two toolchains in one, with the bin/, lib/ etc. paths at top-level pointing to the 'default' toolchain, i.e. 32-bit in our case, and changes in linux/uboot to use the 64-bit toolchain specifically. We'd need to discuss if and how we would integrate that in mainline Buildroot.
Quoted 3 lines
- There is an alternative: two separate Buildroot configs, one for the kernel + modules, one for userspace.
Ok, but it is not so convenient at least in our case, where all surrounding build logic and validation assumes that you just set a single defconfig, build it, then obtain the results from output/images. We'd need surrounding scripting to handle the separate kernel build.
Additionally, what about a build with initramfs built-in the vmlinux image? This would need the rootfs file from the 32-bit buildroot copied over to the kernel buildroot context, and then attached there. This is additional complexity.
Quoted 9 lines
- I don't think the flexibility is useful. I think it would be better to reuse the
BR2_KERNEL_64_USERLAND_32option. (E.g. add an option to Config.in.x86 when the arch isx86_64to build a 32-bit userspace.) That way we can use it to pass -m32 where needed, to build an internal toolchain that supports it, and to check for the external toolchain if it supports it. Doesn't solve the issue for ARM, but it's a start.
Quoted 4 lines
Also, I think we absolutely need to test this feature. At the very least, we'd
need to config in the autobuilders that enables it, or enable it randomly in genrandconfig. Although I'm not sure if it tests anything if no kernel is built (let alone that it's not even booted).
Yes I had created a qemu defconfig and multilib toolchain that can be used for tests. But Romain found that the binaries do not run on the build farm.
Would it be possible to get temporary shell access to that environment so I can find out what options I really need?
Quoted 4 lines
For now, I've left the rest of the series as New in patchwork, let's see what
the others think.
Thanks for your feedback,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas, All,
On 2022-01-15 21:02 +0100, Thomas De Schampheleire spake thusly:
Quoted 11 lines
From: Thomas De Schampheleire <[email protected]> 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-bitx86_64kernel with 32-bit i386 userspace
- 64-bit aarch64 kernel with 32-bit arm userspaceThis series adds basic support for these cases, with the limitation that the user still needs to know what they are doing.
We've discussed this series, and Arnout provided some feedback.
It is not entirely clear that this is something we want to carry, especially, as Arnout suggest, as there are other ways to do so.
I agree with most of what Arnout said. If your tooling can't handle building two defconfigs, then I would adapt the tooling (it's very easy with e.g. gitlab-CI to have two jobs in sequence, where the first builds the kernel + modules, puts that artefacts, retrieved from the second job that builds userland + final image).
It also look a bit to fragile and complex (as someone put it: "spit and ducktape").
So, we're going to decline the rest of this series, sorry.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot