Basic support for 64-bit kernel and 32-bit userland
Subsystems (3)
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.
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(-)
Signature · 1 line
2.26.3
PATCH 1/4 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
@@ -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))
arch/Config.in +3 -0
@@ -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
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
@@ -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"
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
@@ -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"
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 · 1 line
2.26.3
Re: [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files
Hi Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
Quoted 8 lines
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.
Best regards,
Romain
Quoted 283 lines
Signed-off-by Thomas De Schampheleire <[email protected]>--- 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@@ -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))arch/Config.in +3
-0@@ -326,6 +326,9 @@ config BR2_ARCH_NEEDS_GCC_AT_LEAST_10 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@@ -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"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@@ -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"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 2/4 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
@@ -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))
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
@@ -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 += \
package/busybox/busybox.mk +1 -1
@@ -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)" \
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
@@ -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
Signature · 1 line
2.26.3
Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
Quoted 32 lines
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.
Quoted 7 lines
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.
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.
Quoted 205 lines
Signed-off-by Thomas De Schampheleire <[email protected]>--- 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@@ -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))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@@ -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 += \package/busybox/busybox.mk +1
-1@@ -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)" \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 +0
-0
package/uboot-tools/uboot-tools.mk $(eval $(host-generic-package)) · line 212
Quoted 9 lines
package/uboot-tools/uboot-tools.mk +2
-2@@ -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
package/uboot-tools/uboot-tools.mk $(eval $(host-generic-package)) · line 219
Quoted 11 lines
package/uboot-tools/uboot-tools.mk +3
-3-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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
Hi Romain,
Quoted 46 lines · Romain Naour
Quoted 32 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.Quoted 7 lines
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.While reviewing this patch, I noticed that
LINUX_ARCH_PATH[1] is wrong for sparc64
LINUX_ARCH_PATH= $(LINUX_DIR)/arch/$(KERNEL_ARCH)
Quoted 9 lines
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/sparc64But since
LINUX_ARCH_PATHis 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 := x86endif
# 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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
Hi Thomas,
Le 14/01/2022 à 13:27, Thomas De Schampheleire a écrit :
Quoted 85 lines
Hi Romain,
Quoted 46 lines · Romain Naour
Quoted 32 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.Quoted 7 lines
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.While reviewing this patch, I noticed that
LINUX_ARCH_PATH[1] is wrong for sparc64
LINUX_ARCH_PATH= $(LINUX_DIR)/arch/$(KERNEL_ARCH)Quoted 9 lines
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/sparc64But since
LINUX_ARCH_PATHis 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 kernelMakefile, some 'ARCH' strings are treated specially:# Additional ARCH settings for x86
ifeq ($(ARCH),i386)SRCARCH := x86 endif ifeq ($(ARCH),x86_64) SRCARCH := x86endif
# 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
Quoted 5 lines
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 thougharch/x86_64does 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
Quoted 4 lines
Thanks,
Thomas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/4 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
@@ -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))
arch/Config.in +15 -0
@@ -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
Signature · 1 line
2.26.3
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
Hello Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
Quoted 6 lines
From: 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_64architecture, withx86_64kernel 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 :))
Quoted 48 lines
In Buildroot, the ARCH/BR2_ARCH and
NORMALIZED_ARCHvariables 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 <[email protected]>--- Makefile | 4 ++++ arch/Config.in | 15 +++++++++++++++ 2 files changed, 19 insertions(+)Makefile +4
-0@@ -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))arch/Config.in +8
-0@@ -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
arch/Config.in config BR2_ARCH · line 349
Quoted 10 lines
arch/Config.in +7
-0+ 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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
Hi Romain,
Quoted 11 lines · Romain Naour
Hello Thomas,
Quoted 6 lines · Thomas De Schampheleire
From: 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_64architecture, withx86_64kernel and 32-bit (i386) userspace
Quoted 7 lines
Can you provide a new qemu defconfig that cover this use case? This is for gitlab-ci runtime testing.
Best regards,
RomainPS: (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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
Quoted 25 lines · Thomas De Schampheleire
Hi Romain,
Quoted 11 lines · Romain Naour
Hello Thomas,
Quoted 6 lines · Thomas De Schampheleire
From: 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_64architecture, withx86_64kernel and 32-bit (i386) userspaceQuoted 7 lines
Can you provide a new qemu defconfig that cover this use case? This is for gitlab-ci runtime testing.
Best regards,
RomainPS: (This email doesn't count as a review of this series :))
Thanks for your interest in this series :-)
Quoted 7 lines
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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
Hello Thomas, Arnout,
Le 12/01/2022 à 20:10, Arnout Vandecappelle a écrit :
Quoted 36 lines · Thomas De Schampheleire
Quoted 25 lines
Hi Romain,
Quoted 11 lines · Romain Naour
Hello Thomas,
Quoted 6 lines · Thomas De Schampheleire
From: 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_64architecture, withx86_64kernel and 32-bit (i386) userspaceQuoted 7 lines
Can you provide a new qemu defconfig that cover this use case? This is for gitlab-ci runtime testing.
Best regards,
RomainPS: (This email doesn't count as a review of this series :))
Thanks for your interest in this series :-)
Quoted 7 lines
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?
Quoted 1 line
Bootlin toolchains no - they are generated by Buildroot.
Indeed.
Quoted 6 lines
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
Quoted 4 lines
Regards,
Arnout
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
In reply to Thomas De SchampheleireHi Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
Quoted 42 lines
From: 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_64architecture, withx86_64kernel and 32-bit (i386) userspaceIn Buildroot, the ARCH/BR2_ARCH and
NORMALIZED_ARCHvariables 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 <[email protected]>--- Makefile | 4 ++++ arch/Config.in | 15 +++++++++++++++ 2 files changed, 19 insertions(+)Makefile +4
-0@@ -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))arch/Config.in +0
-0
arch/Config.in config BR2_ARCH · line 333
Quoted 5 lines
arch/Config.in +2
-0@@ -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)
arch/Config.in config BR2_ARCH · line 345
Quoted 12 lines
arch/Config.in +12
-0+ 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
arch/Config.in config BR2_ARCH · line 349
Quoted 5 lines
arch/Config.in +1
-0+ config BR2_ENDIAN string
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
Quoted 67 lines · Romain Naour
Hi Thomas,
Quoted 42 lines · Thomas De Schampheleire
From: 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_64architecture, withx86_64kernel and 32-bit (i386) userspaceIn Buildroot, the ARCH/BR2_ARCH and
NORMALIZED_ARCHvariables 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 <[email protected]>--- Makefile | 4 ++++ arch/Config.in | 15 +++++++++++++++ 2 files changed, 19 insertions(+)Makefile +4
-0@@ -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))arch/Config.in +0
-0arch/Config.in config BR2_ARCH · line 333
Quoted 5 lines
arch/Config.in +2
-0@@ -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)arch/Config.in config BR2_ARCH · line 345
Quoted 12 lines
arch/Config.in +12
-0+ 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.
Quoted 3 lines
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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE
In reply to Romain NaourQuoted 49 lines · Romain Naour
Hi Thomas,
Quoted 45 lines · Thomas De Schampheleire
From: 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_64architecture, withx86_64kernel and 32-bit (i386) userspaceIn Buildroot, the ARCH/BR2_ARCH and
NORMALIZED_ARCHvariables 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 <[email protected]>--- Makefile | 4 ++++ arch/Config.in | 15 +++++++++++++++ 2 files changed, 19 insertions(+)Makefile +4
-0@@ -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))arch/Config.in +0
-0@@ -329,6 +329,21 @@ config BR2_ARCH config BR2_KERNEL_ARCH string
Quoted 5 lines
arch/Config.in config BR2_ARCH · line 333
Quoted 2 lines
arch/Config.in +2
-0+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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 4/4 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 · 1 line
2.26.3
Re: [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel
Hello Thomas,
Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
Quoted 20 lines
From: 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.
Signed-off-by Thomas De Schampheleire <[email protected]>--- package/linux-tools/linux-tool-perf.mk.in | 3 +++ 1 file changed, 3 insertions(+)package/linux-tools/linux-tool-perf.mk.in +0
-0
package/linux-tools/linux-tool-perf.mk.in PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32" · line 50
Quoted 6 lines
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"
Do you know why the ARM toolchain doesn't need a similar handling ?
Best regards,
Romain
package/linux-tools/linux-tool-perf.mk.in PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32" · line 53
Quoted 4 lines
package/linux-tools/linux-tool-perf.mk.in +0
-0endif # The call to backtrace() function fails for ARC, because for some
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel
Hi Romain,
Quoted 19 lines · Romain Naour
Hello Thomas,
Quoted 15 lines · Thomas De Schampheleire
From: 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.
Signed-off-by Thomas De Schampheleire <[email protected]>--- package/linux-tools/linux-tool-perf.mk.in | 3 +++ 1 file changed, 3 insertions(+)
Quoted 13 lines
package/linux-tools/linux-tool-perf.mk.in PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32" · line 50
Quoted 11 lines
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"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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot