selftests/nolibc: customize CROSS_COMPILE for all supported architectures
Subsystems (2)
cover selftests/nolibc: customize CROSS_COMPILE for all supported architectures
Hi, Willy
Based on the CROSS_COMPILE customize support [1] from the last ppc patchset, to further make run-user/run targets happy for all of the nolibc supported architectures, let's customize CROSS_COMPILE for all of them.
Beside loongarch, all of the other architectures have local toolchains. let's use the one from [2] for loongarch, it has a different prefix.
And also, as suggested by you in our previous discuss, let's add some notes for the toolchains and firmwares instead of automatically download them.
Now, the test iteration becomes very simple and pretty:
$ ARCHS="i386 x86_64 arm64 arm mips ppc ppc64 ppc64le riscv s390"
$ for arch in ${ARCHS[@]}; do printf "%9s: " $arch; make run-user XARCH=$arch | grep status; done
i386: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
x86_64: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
arm64: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
arm: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
mips: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
ppc: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
ppc64: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
ppc64le: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
riscv: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
s390: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning(I have no qemu-user currently for loongarch, so, no test result above)
Best regards,
Zhangjin
---
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://mirrors.edge.kernel.org/pub/tools/crosstool/
Zhangjin Wu (4):
selftests/nolibc: allow use x86_64 toolchain for i386 selftests/nolibc: customize CROSS_COMPILE for many architectures selftests/nolibc: customize CROSS_COMPILE for loongarch selftests/nolibc: add some notes about qemu tools
tools/testing/selftests/nolibc/Makefile | 32 ++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH 1/4 selftests/nolibc: allow use x86_64 toolchain for i386
This allows to share the same x86_64 toolchain for i386 architecture.
Pass '-m32' CFLAGS to tell x86_64 toolchains to generate i386 executable.
--- tools/testing/selftests/nolibc/Makefile | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/nolibc/Makefile +1 -0
@@ -122,6 +122,7 @@ else Q=@ endif +CFLAGS_i386 = -m32 CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64 = -m64 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64le = -m64 -mlittle-endian -mno-vsx $(call cc-option,-mabi=elfv2)
Signature · 1 line
2.25.1
PATCH 2/4 selftests/nolibc: customize CROSS_COMPILE for many architectures
In reply to Zhangjin WuThis simplifies the 'make' commands for most of nolibc supported architectures, only requires the XARCH option now.
Almost all distributions provide qemu and toolchains for i386, x86_64, arm64, arm, mips, riscv and s390, let's customize the local toolchains for them. The fresh new loongarch is an exception, which is not covered here.
If want to use another toolchain which is not customized here, we can also pass CROSS_COMPILE, CROSS_COMPILE_$(XARCH) and even CC from command line.
After carefully install and configure $(CROSS_COMPILE_$(XARCH)) and qemu-$(XARCH), it is able to run tests for the architectures or their variants like this:
$ ARCHS="i386 x86_64 arm64 arm mips ppc ppc64 ppc64le riscv s390"
$ for arch in ${ARCHS[@]}; do printf "%9s: " $arch; make run-user XARCH=$arch | grep status; done
i386: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
x86_64: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
arm64: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
arm: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
mips: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
ppc: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
ppc64: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
ppc64le: 165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
riscv: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
s390: 165 test(s): 156 passed, 9 skipped, 0 failed => status: warning[1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/
--- tools/testing/selftests/nolibc/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/testing/selftests/nolibc/Makefile +8 -0
@@ -56,9 +56,17 @@ IMAGE = $(IMAGE_$(XARCH)) IMAGE_NAME = $(notdir $(IMAGE)) # CROSS_COMPILE: cross toolchain prefix by architecture +CROSS_COMPILE_i386 ?= x86_64-linux-gnu- +CROSS_COMPILE_x86_64 ?= x86_64-linux-gnu- +CROSS_COMPILE_x86 ?= x86_64-linux-gnu- +CROSS_COMPILE_arm64 ?= aarch64-linux-gnu- +CROSS_COMPILE_arm ?= arm-linux-gnueabi- +CROSS_COMPILE_mips ?= mipsel-linux-gnu- CROSS_COMPILE_ppc ?= powerpc-linux-gnu- CROSS_COMPILE_ppc64 ?= powerpc64le-linux-gnu- CROSS_COMPILE_ppc64le ?= powerpc64le-linux-gnu- +CROSS_COMPILE_riscv ?= riscv64-linux-gnu- +CROSS_COMPILE_s390 ?= s390x-linux-gnu- CROSS_COMPILE ?= $(CROSS_COMPILE_$(XARCH)) # make sure CC is prefixed with CROSS_COMPILE
Signature · 1 line
2.25.1
PATCH 3/4 selftests/nolibc: customize CROSS_COMPILE for loongarch
In reply to Zhangjin WuLoongarch is a fresh new architecture, there is no prebuilt toolchain from most of local software repositories, let's use the one from [1].
[1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/
--- tools/testing/selftests/nolibc/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/testing/selftests/nolibc/Makefile +9 -0
@@ -56,6 +56,14 @@ IMAGE = $(IMAGE_$(XARCH)) IMAGE_NAME = $(notdir $(IMAGE)) # CROSS_COMPILE: cross toolchain prefix by architecture +# +# Notes: +# - Loongarch may require toolchain from +# https://mirrors.edge.kernel.org/pub/tools/crosstool/ +# +# For an external toolchain, please add its bin/ path to 'PATH' and then pass +# CROSS_COMPLE, CROSS_COMPILE_$(XARCH), or even CC from command line. + CROSS_COMPILE_i386 ?= x86_64-linux-gnu- CROSS_COMPILE_x86_64 ?= x86_64-linux-gnu- CROSS_COMPILE_x86 ?= x86_64-linux-gnu-
@@ -67,6 +75,7 @@ CROSS_COMPILE_ppc64 ?= powerpc64le-linux-gnu- CROSS_COMPILE_ppc64le ?= powerpc64le-linux-gnu- CROSS_COMPILE_riscv ?= riscv64-linux-gnu- CROSS_COMPILE_s390 ?= s390x-linux-gnu- +CROSS_COMPILE_loongarch ?= loongarch64-linux- CROSS_COMPILE ?= $(CROSS_COMPILE_$(XARCH)) # make sure CC is prefixed with CROSS_COMPILE
Signature · 1 line
2.25.1
PATCH 4/4 selftests/nolibc: add some notes about qemu tools
In reply to Zhangjin WuAlmost all distributions provide qemu-system-$(XARCH), their firmwares and qemu-$(XARCH), but for the new riscv and loongarch, users may still need to download external firmwares or compile qemu from scratch, let's add some notes about them.
--- tools/testing/selftests/nolibc/Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/testing/selftests/nolibc/Makefile +13 -1
@@ -100,6 +100,18 @@ DEFCONFIG = $(DEFCONFIG_$(XARCH)) TEST = # QEMU_ARCH: arch names used by qemu +# +# Notes: +# - qemu-system of riscv may require latest firmware from +# https://github.com/riscv-software-src/opensbi/releases/ +# - qemu-system of loongarch may require latest firmware from +# https://github.com/loongson/Firmware/tree/main/LoongArchVirtMachine +# +# If qemu-$(XARCH) or qemu-system-$(XARCH) is missing from software repository, +# please compile them with help from https://wiki.qemu.org/Documentation +# +# To specify a firmware, please pass QEMU_ARGS_EXTRA="-bios dir/to/firmware" + QEMU_ARCH_i386 = i386 QEMU_ARCH_x86_64 = x86_64 QEMU_ARCH_x86 = x86_64
@@ -114,7 +126,7 @@ QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 QEMU_ARCH = $(QEMU_ARCH_$(XARCH)) -# QEMU_ARGS : some arch-specific args to pass to qemu +# QEMU_ARGS: some arch-specific args to pass to qemu QEMU_ARGS_i386 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_x86_64 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
Signature · 1 line
2.25.1
Willy Tarreau
maintainerRe: [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools
Quoted 4 lines · Zhangjin Wu
Almost all distributions provide qemu-system-$(XARCH), their firmwares and qemu-$(XARCH), but for the new riscv and loongarch, users may still need to download external firmwares or compile qemu from scratch, let's add some notes about them.
That's indeed useful information but I think that we should really move all the download instructions to a separate file. I wanted to write one anyway, but didn't have the time with all the build tests to run :-(
I may propose one to be merged late, possibly.
Willy