public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] selftests/nolibc: customize CROSS_COMPILE for all supported architectures
@ 2023-08-05 19:36 Zhangjin Wu
  2023-08-05 19:38 ` [PATCH v1 1/4] selftests/nolibc: allow use x86_64 toolchain for i386 Zhangjin Wu
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Zhangjin Wu @ 2023-08-05 19:36 UTC (permalink / raw)
  To: w; +Cc: falcon, linux-kernel, linux-kselftest, tanyuan, thomas

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/cover.1691259983.git.falcon@tinylab.org/
[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(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/4] selftests/nolibc: allow use x86_64 toolchain for i386
  2023-08-05 19:36 [PATCH v1 0/4] selftests/nolibc: customize CROSS_COMPILE for all supported architectures Zhangjin Wu
@ 2023-08-05 19:38 ` Zhangjin Wu
  2023-08-05 19:44 ` [PATCH v1 2/4] selftests/nolibc: customize CROSS_COMPILE for many architectures Zhangjin Wu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Zhangjin Wu @ 2023-08-05 19:38 UTC (permalink / raw)
  To: w; +Cc: falcon, linux-kernel, linux-kselftest, tanyuan, thomas

This allows to share the same x86_64 toolchain for i386 architecture.

Pass '-m32' CFLAGS to tell x86_64 toolchains to generate i386 executable.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index b4171a754eb2..e2b02761ad44 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/4] selftests/nolibc: customize CROSS_COMPILE for many architectures
  2023-08-05 19:36 [PATCH v1 0/4] selftests/nolibc: customize CROSS_COMPILE for all supported architectures Zhangjin Wu
  2023-08-05 19:38 ` [PATCH v1 1/4] selftests/nolibc: allow use x86_64 toolchain for i386 Zhangjin Wu
@ 2023-08-05 19:44 ` Zhangjin Wu
  2023-08-05 19:49 ` [PATCH v1 3/4] selftests/nolibc: customize CROSS_COMPILE for loongarch Zhangjin Wu
  2023-08-05 19:51 ` [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools Zhangjin Wu
  3 siblings, 0 replies; 6+ messages in thread
From: Zhangjin Wu @ 2023-08-05 19:44 UTC (permalink / raw)
  To: w; +Cc: falcon, linux-kernel, linux-kselftest, tanyuan, thomas

This 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/

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index e2b02761ad44..d32694656221 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -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
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 3/4] selftests/nolibc: customize CROSS_COMPILE for loongarch
  2023-08-05 19:36 [PATCH v1 0/4] selftests/nolibc: customize CROSS_COMPILE for all supported architectures Zhangjin Wu
  2023-08-05 19:38 ` [PATCH v1 1/4] selftests/nolibc: allow use x86_64 toolchain for i386 Zhangjin Wu
  2023-08-05 19:44 ` [PATCH v1 2/4] selftests/nolibc: customize CROSS_COMPILE for many architectures Zhangjin Wu
@ 2023-08-05 19:49 ` Zhangjin Wu
  2023-08-05 19:51 ` [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools Zhangjin Wu
  3 siblings, 0 replies; 6+ messages in thread
From: Zhangjin Wu @ 2023-08-05 19:49 UTC (permalink / raw)
  To: w; +Cc: falcon, linux-kernel, linux-kselftest, tanyuan, thomas

Loongarch 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/

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index d32694656221..9cd6dc0e8b75 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools
  2023-08-05 19:36 [PATCH v1 0/4] selftests/nolibc: customize CROSS_COMPILE for all supported architectures Zhangjin Wu
                   ` (2 preceding siblings ...)
  2023-08-05 19:49 ` [PATCH v1 3/4] selftests/nolibc: customize CROSS_COMPILE for loongarch Zhangjin Wu
@ 2023-08-05 19:51 ` Zhangjin Wu
  2023-08-06 10:12   ` Willy Tarreau
  3 siblings, 1 reply; 6+ messages in thread
From: Zhangjin Wu @ 2023-08-05 19:51 UTC (permalink / raw)
  To: w; +Cc: falcon, linux-kernel, linux-kselftest, tanyuan, thomas

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.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 9cd6dc0e8b75..1e92bb5138db 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -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=%)"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools
  2023-08-05 19:51 ` [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools Zhangjin Wu
@ 2023-08-06 10:12   ` Willy Tarreau
  0 siblings, 0 replies; 6+ messages in thread
From: Willy Tarreau @ 2023-08-06 10:12 UTC (permalink / raw)
  To: Zhangjin Wu; +Cc: linux-kernel, linux-kselftest, tanyuan, thomas

On Sun, Aug 06, 2023 at 03:51:24AM +0800, Zhangjin Wu wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-06 10:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-05 19:36 [PATCH v1 0/4] selftests/nolibc: customize CROSS_COMPILE for all supported architectures Zhangjin Wu
2023-08-05 19:38 ` [PATCH v1 1/4] selftests/nolibc: allow use x86_64 toolchain for i386 Zhangjin Wu
2023-08-05 19:44 ` [PATCH v1 2/4] selftests/nolibc: customize CROSS_COMPILE for many architectures Zhangjin Wu
2023-08-05 19:49 ` [PATCH v1 3/4] selftests/nolibc: customize CROSS_COMPILE for loongarch Zhangjin Wu
2023-08-05 19:51 ` [PATCH v1 4/4] selftests/nolibc: add some notes about qemu tools Zhangjin Wu
2023-08-06 10:12   ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox