Skip to contentSkip to conversation

selftests/nolibc: customize CROSS_COMPILE for all supported architectures

PATCH In review Zhangjin Wu 2 participants 18 messages Aug 11, 2023 – Aug 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover selftests/nolibc: customize CROSS_COMPILE for all supported architectures

Hi, Willy

Here is v2 of the customized CROSS_COMPILE support, this helps a lot during the testing of the other cross-arch nolibc changes:

    $ 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

Based on your suggestion, we did this changes:

- The qemu notes patch [1] is removed, welcome your doc file ;-)
- Arnd's crosstools are customized by default
- Import cc-cross-prefix to support local cross toolchains too
- Use mips64 toolchains for mips like x86_64 toolchains for i386, allow download less toolchains
- Use HOSTCC for libc-test compiling

Changes from v1 --> v2:

* selftests/nolibc: allow use x86_64 toolchain for i386

No change.

* selftests/nolibc: allow use mips64 toolchain for mips

Allow download less toolchains, save time save storage space

* selftests/nolibc: libc-test: use HOSTCC instead of CC

libc-test is mainly for local test, use HOSTCC

* selftests/nolibc: allow customize CROSS_COMPILE by architecture

Moved the ../../../scripts/Makefile.include after our customized CROSS_COMPILE, to let it prefix CC with $(CROSS_COMPILE) for us.

* selftests/nolibc: customize CROSS_COMPILE for all architectures

Use Arnd's crosstools as the default ones

* selftests/nolibc: import cc-cross-prefix macro selftests/nolibc: allow use cross toolchains from software repository

Import cc-cross-prefix to allow customize a list of the cross compilers, the ones from local repositories are appended in.

If already installed ones from local repos, why not use them, let's do it.

Willy, since this series is really important to test the coming patchsets, I send it here before the others to simplify the testing, but we can delay its review, it is not urgent.

And here [2] is the simple script I wrote to download, decompress and configure the PATH variable for Anrd's crosstools, hope it helps.

Best regards,
Zhangjin Wu
---
[1]: https://lore.kernel.org/lkml/6de680acbc2d87e13a680d4453ef022568bf489b.1691263493.git.falcon@tinylab.org/
[2]: https://gitee.com/tinylab/linux-lab/blob/next/tools/nolibc/crosstool.sh
v1: https://lore.kernel.org/lkml/[email protected]/

Zhangjin Wu (7):
selftests/nolibc: allow use x86_64 toolchain for i386 selftests/nolibc: allow use mips64 toolchain for mips selftests/nolibc: libc-test: use HOSTCC instead of CC selftests/nolibc: allow customize CROSS_COMPILE by architecture selftests/nolibc: customize CROSS_COMPILE for all architectures selftests/nolibc: import cc-cross-prefix macro selftests/nolibc: allow use cross toolchains from software repository

 tools/testing/selftests/nolibc/Makefile | 38 +++++++++++++++++++++----
 1 file changed, 33 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/7 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
index 76c387a20811..98d0a619d49d 100644
@@ -125,6 +125,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
#2 lore raw

PATCH v2 2/7 selftests/nolibc: allow use mips64 toolchain for mips

In reply to Zhangjin Wu

This allows to share the same mips64 toolchain for mips architecture.

Pass '-mabi=32' CFLAGS to tell mips64 toolchains to generate 32-bit mips executable.

---
 tools/testing/selftests/nolibc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/nolibc/Makefile +1 -1
index 98d0a619d49d..d1012f006405 100644
@@ -130,7 +130,7 @@ 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)
 CFLAGS_s390 = -m64
-CFLAGS_mips = -EL
+CFLAGS_mips = -mabi=32 -EL
 CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
 CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \
 		$(call cc-option,-fno-stack-protector) \
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/7 selftests/nolibc: libc-test: use HOSTCC instead of CC

In reply to Zhangjin Wu

libc-test is mainly added to compare the behavior of nolibc to the system libc, it is meaningless and error-prone with cross compiling.

Let's use HOSTCC instead of CC to avoid wrongly use cross compiler when CROSS_COMPILE is passed or customized.

---
 tools/testing/selftests/nolibc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/nolibc/Makefile +1 -1
index d1012f006405..91ccfc27780f 100644
@@ -191,7 +191,7 @@ nolibc-test: nolibc-test.c
 endif
 
 libc-test: nolibc-test.c
-	$(QUIET_CC)$(CC) -o $@ $<
+	$(QUIET_CC)$(HOSTCC) -o $@ $<
 
 # local libc-test
 run-libc-test: libc-test
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH v2 3/7] selftests/nolibc: libc-test: use HOSTCC instead of CC

Quoted 5 lines · Zhangjin Wu

libc-test is mainly added to compare the behavior of nolibc to the system libc, it is meaningless and error-prone with cross compiling.

Let's use HOSTCC instead of CC to avoid wrongly use cross compiler when CROSS_COMPILE is passed or customized.

Indeed. This one is actually a fix for this one, I'll pick it separately as it's independent on this series:

    85a0b029a1ce ("selftests/nolibc: add run-libc-test target")

Thanks,
Willy

#5 lore raw

PATCH v2 4/7 selftests/nolibc: allow customize CROSS_COMPILE by architecture

In reply to Zhangjin Wu

Some cross compilers are not just prefixed with XARCH, customize them by architecture may simplify the test a lot, especially, when iterate with XARCH.

After customizing this for every architecture or its variant, the minimal test argument will be architecture or variant itself, no CROSS_COMPILE required to be passed.

If the prefix of installed cross compiler is not the same as the one customized, we can also pass CROSS_COMPILE as before or even pass CROSS_COMPILE_$(XARCH) and CC from command line.

---
 tools/testing/selftests/nolibc/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/selftests/nolibc/Makefile +6 -1
index 91ccfc27780f..5aff60d31d72 100644
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for nolibc tests
-include ../../../scripts/Makefile.include
 # We need this for the "cc-option" macro.
 include ../../../build/Build.include
 
@@ -55,6 +54,12 @@ IMAGE_loongarch  = arch/loongarch/boot/vmlinuz.efi
 IMAGE            = $(IMAGE_$(XARCH))
 IMAGE_NAME       = $(notdir $(IMAGE))
 
+# CROSS_COMPILE: cross toolchain prefix by architecture
+CROSS_COMPILE           ?= $(CROSS_COMPILE_$(XARCH))
+
+# Make CC is always prefixed with $(CROSS_COMPILE)
+include ../../../scripts/Makefile.include
+
 # default kernel configurations that appear to be usable
 DEFCONFIG_i386       = defconfig
 DEFCONFIG_x86_64     = defconfig
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 5/7 selftests/nolibc: customize CROSS_COMPILE for all architectures

In reply to Zhangjin Wu

This simplifies the 'make' commands for nolibc supported architectures, only requires the XARCH option now.

As suggested by Willy, the small, newest and obtainable cross toolchains from [1] are customized by default, users must download, decompress and configure the bin/ path to the PATH environment variable manually.

If still want to use a cross toolchain from local software repositories, we can also pass CROSS_COMPILE, CROSS_COMPILE_$(XARCH) or even CC from command line.

After carefully install and configure $(CROSS_COMPILE_$(XARCH)), qemu-system-$(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 loongarch"
    $ for arch in ${ARCHS[@]}; do printf "%9s: " $arch; make run-user XARCH=$arch | grep status; done
    $ for arch in ${ARCHS[@]}; do printf "%9s: " $arch; make defconfig run XARCH=$arch | grep status; done

[1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/

---
 tools/testing/selftests/nolibc/Makefile | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
tools/testing/selftests/nolibc/Makefile +21 -0
index 5aff60d31d72..9a787fdf9842 100644
@@ -55,6 +55,27 @@ IMAGE            = $(IMAGE_$(XARCH))
 IMAGE_NAME       = $(notdir $(IMAGE))
 
 # CROSS_COMPILE: cross toolchain prefix by architecture
+#
+# Notes,
+# - The small, newest and obtainable cross toolchains from [1] are recommended,
+#   Please download, decompress and add the bin/ path to 'PATH' env variable
+# - To use another cross compiler, pass 'CROSS_COMPLE', 'CROSS_COMPILE_$(XARCH)'
+#   by variant or even 'CC' from command line
+#
+# [1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/
+
+CROSS_COMPILE_i386      ?= x86_64-linux-
+CROSS_COMPILE_x86_64    ?= x86_64-linux-
+CROSS_COMPILE_x86       ?= x86_64-linux-
+CROSS_COMPILE_arm64     ?= aarch64-linux-
+CROSS_COMPILE_arm       ?= arm-linux-gnueabi-
+CROSS_COMPILE_mips      ?= mips64-linux-
+CROSS_COMPILE_ppc       ?= powerpc64-linux-
+CROSS_COMPILE_ppc64     ?= powerpc64-linux-
+CROSS_COMPILE_ppc64le   ?= powerpc64-linux-
+CROSS_COMPILE_riscv     ?= riscv64-linux-
+CROSS_COMPILE_s390      ?= s390-linux-
+CROSS_COMPILE_loongarch ?= loongarch64-linux-
 CROSS_COMPILE           ?= $(CROSS_COMPILE_$(XARCH))
 
 # Make CC is always prefixed with $(CROSS_COMPILE)
Signature · 1 line
2.25.1
maintainer
#7 lore raw

Re: [PATCH v2 5/7] selftests/nolibc: customize CROSS_COMPILE for all architectures

tools/testing/selftests/nolibc/Makefile IMAGE = $(IMAGE_$(XARCH)) · line 72

Quoted 6 lines · Zhangjin Wu
tools/testing/selftests/nolibc/Makefile +6 -0
+CROSS_COMPILE_i386      ?= x86_64-linux-
+CROSS_COMPILE_x86_64    ?= x86_64-linux-
+CROSS_COMPILE_x86       ?= x86_64-linux-
+CROSS_COMPILE_arm64     ?= aarch64-linux-
+CROSS_COMPILE_arm       ?= arm-linux-gnueabi-
+CROSS_COMPILE_mips      ?= mips64-linux-

Given that we don't support mips64, I'd suggest to ust mips-linux- instead here for now. That doesn't seem right to ask users to download a toolchain for a different architecture than the one supported just because we can adapt to it.

Willy

#8 lore raw

Re: [PATCH v2 5/7] selftests/nolibc: customize CROSS_COMPILE for all architectures

Quoted 13 lines · Zhangjin Wu

tools/testing/selftests/nolibc/Makefile IMAGE = $(IMAGE_$(XARCH)) · line 72

Quoted 6 lines
tools/testing/selftests/nolibc/Makefile +6 -0
+CROSS_COMPILE_i386      ?= x86_64-linux-
+CROSS_COMPILE_x86_64    ?= x86_64-linux-
+CROSS_COMPILE_x86       ?= x86_64-linux-
+CROSS_COMPILE_arm64     ?= aarch64-linux-
+CROSS_COMPILE_arm       ?= arm-linux-gnueabi-
+CROSS_COMPILE_mips      ?= mips64-linux-

Given that we don't support mips64, I'd suggest to ust mips-linux- instead here for now. That doesn't seem right to ask users to download a toolchain for a different architecture than the one supported just because we can adapt to it.

Agree very much, and the one below from patch 7/7 [1]:

    +CROSS_COMPILE_arm64     ?= aarch64-linux- aarch64-linux-gnu-
    +CROSS_COMPILE_arm       ?= arm-linux-gnueabi- arm-none-eabi-
    +CROSS_COMPILE_mips      ?= mips64-linux- mips64el-linux-gnuabi64-

It should be:

+CROSS_COMPILE_mips ?= mips-linux- mips-linux-gnu-gcc

And if necessary, the mips64-linux- line in the commit message of [1] should be corrected too.

Thanks very much!

Best regards,
Zhangjin
[1]: https://lore.kernel.org/lkml/b06de47989e3138de3d178da0d705ad6560924ec.1691783604.git.falcon@tinylab.org/

Quoted 1 line

Willy

maintainer
#9 lore raw

Re: [PATCH v2 5/7] selftests/nolibc: customize CROSS_COMPILE for all architectures

Quoted 12 lines · Zhangjin Wu
Quoted 5 lines

Given that we don't support mips64, I'd suggest to ust mips-linux- instead here for now. That doesn't seem right to ask users to download a toolchain for a different architecture than the one supported just because we can adapt to it.

Agree very much, and the one below from patch 7/7 [1]:

    +CROSS_COMPILE_arm64     ?= aarch64-linux- aarch64-linux-gnu-
    +CROSS_COMPILE_arm       ?= arm-linux-gnueabi- arm-none-eabi-
    +CROSS_COMPILE_mips      ?= mips64-linux- mips64el-linux-gnuabi64-
Quoted 6 lines

It should be:

+CROSS_COMPILE_mips ?= mips-linux- mips-linux-gnu-gcc

And if necessary, the mips64-linux- line in the commit message of [1] should be corrected too.

I just did that (and fixed mips-linux-gnu- instead of mips-linux-gnu-gcc above).

Thanks,
Willy

#10 lore raw

PATCH v2 6/7 selftests/nolibc: import cc-cross-prefix macro

In reply to Zhangjin Wu

cc-cross-prefix is required to return first <prefix> where a <prefix>gcc is found in PATH, this allows to customize more than one cross compiler.

Since scripts/Makefile.compiler provides cc-option too, let's use it instead of tools/build/Build.include.

---
 tools/testing/selftests/nolibc/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/nolibc/Makefile +2 -2
index 9a787fdf9842..7687988c780b 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for nolibc tests
-# We need this for the "cc-option" macro.
-include ../../../build/Build.include
+# We need this for the "cc-option" and "cc-cross-prefix" macros.
+include ../../../../scripts/Makefile.compiler
 
 # we're in ".../tools/testing/selftests/nolibc"
 ifeq ($(srctree),)
Signature · 1 line
2.25.1
#11 lore raw

PATCH v2 7/7 selftests/nolibc: allow use cross toolchains from software repository

In reply to Zhangjin Wu

This allows users to install and use cross toolchains from local software repositories.

The prefixes of local cross toolchains are appended to the CROSS_COMPILE_$(XARCH) list, cc-cross-prefix is called to search this list and return the first <prefix> where a <prefix>gcc is found in PATH.

Since different distributions have different prefixes, here only adds the frequently used ones.

To use more prefixes not listed in Makefile, please put the lines as following in your script and load it with a 'source' command:

    export CROSS_COMPILE_i386="x86_64-linux-"
    export CROSS_COMPILE_x86_64="x86_64-linux-"
    export CROSS_COMPILE_x86="x86_64-linux-"
    export CROSS_COMPILE_arm64="aarch64-linux-"
    export CROSS_COMPILE_arm="arm-linux-gnueabi-"
    export CROSS_COMPILE_mips="mips64-linux-"
    export CROSS_COMPILE_ppc="powerpc64-linux-"
    export CROSS_COMPILE_ppc64="powerpc64-linux-"
    export CROSS_COMPILE_ppc64le="powerpc64-linux-"
    export CROSS_COMPILE_riscv="riscv64-linux-"
    export CROSS_COMPILE_s390="s390-linux-"
    export CROSS_COMPILE_loongarch="loongarch64-linux-"
---
 tools/testing/selftests/nolibc/Makefile | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
tools/testing/selftests/nolibc/Makefile +13 -12
index 7687988c780b..ef2507f12e24 100644
@@ -59,24 +59,25 @@ IMAGE_NAME       = $(notdir $(IMAGE))
 # Notes,
 # - The small, newest and obtainable cross toolchains from [1] are recommended,
 #   Please download, decompress and add the bin/ path to 'PATH' env variable
+# - The frequently used prefixes are added for local cross toolchains
 # - To use another cross compiler, pass 'CROSS_COMPLE', 'CROSS_COMPILE_$(XARCH)'
 #   by variant or even 'CC' from command line
 #
 # [1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/
 
-CROSS_COMPILE_i386      ?= x86_64-linux-
-CROSS_COMPILE_x86_64    ?= x86_64-linux-
-CROSS_COMPILE_x86       ?= x86_64-linux-
-CROSS_COMPILE_arm64     ?= aarch64-linux-
-CROSS_COMPILE_arm       ?= arm-linux-gnueabi-
-CROSS_COMPILE_mips      ?= mips64-linux-
-CROSS_COMPILE_ppc       ?= powerpc64-linux-
-CROSS_COMPILE_ppc64     ?= powerpc64-linux-
-CROSS_COMPILE_ppc64le   ?= powerpc64-linux-
-CROSS_COMPILE_riscv     ?= riscv64-linux-
-CROSS_COMPILE_s390      ?= s390-linux-
+CROSS_COMPILE_i386      ?= x86_64-linux- x86_64-linux-gnu-
+CROSS_COMPILE_x86_64    ?= x86_64-linux- x86_64-linux-gnu-
+CROSS_COMPILE_x86       ?= x86_64-linux- x86_64-linux-gnu-
+CROSS_COMPILE_arm64     ?= aarch64-linux- aarch64-linux-gnu-
+CROSS_COMPILE_arm       ?= arm-linux-gnueabi- arm-none-eabi-
+CROSS_COMPILE_mips      ?= mips64-linux- mips64el-linux-gnuabi64-
+CROSS_COMPILE_ppc       ?= powerpc64-linux- powerpc-linux-gnu-
+CROSS_COMPILE_ppc64     ?= powerpc64-linux- powerpc64le-linux-gnu-
+CROSS_COMPILE_ppc64le   ?= powerpc64-linux- powerpc64le-linux-gnu-
+CROSS_COMPILE_riscv     ?= riscv64-linux- riscv64-linux-gnu-
+CROSS_COMPILE_s390      ?= s390-linux- s390x-linux-gnu-
 CROSS_COMPILE_loongarch ?= loongarch64-linux-
-CROSS_COMPILE           ?= $(CROSS_COMPILE_$(XARCH))
+CROSS_COMPILE           ?= $(call cc-cross-prefix,$(CROSS_COMPILE_$(XARCH)))
 
 # Make CC is always prefixed with $(CROSS_COMPILE)
 include ../../../scripts/Makefile.include
Signature · 1 line
2.25.1
maintainer
#12 lore raw
In reply to Zhangjin Wu

Hi Zhangjin,

Quoted 8 lines · Zhangjin Wu

Hi, Willy

Here is v2 of the customized CROSS_COMPILE support, this helps a lot during the testing of the other cross-arch nolibc changes:

    $ 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
Quoted 8 lines

Based on your suggestion, we did this changes:

- The qemu notes patch [1] is removed, welcome your doc file ;-)
- Arnd's crosstools are customized by default
- Import cc-cross-prefix to support local cross toolchains too
- Use mips64 toolchains for mips like x86_64 toolchains for i386, allow download less toolchains
- Use HOSTCC for libc-test compiling

(...)

I think it's basically OK (just this mips64 thing). I've picked patch 3 already since it's a fix. Once we agree on what to do there, I can queue it if that helps (I can modify mips64- to mips- in the patch if that's OK for you, no need to resend for this, just let me know).

I think that later I'll further extend XARCH with new variants to support ARMv5 and Thumb2, because we have different code for this and I continue to manually change the CFLAGS to test both.

Thanks,
Willy

#13 lore raw

Hi, Willy

Quoted 19 lines

Hi Zhangjin,

Quoted 8 lines · Zhangjin Wu

Hi, Willy

Here is v2 of the customized CROSS_COMPILE support, this helps a lot during the testing of the other cross-arch nolibc changes:

    $ 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
Quoted 8 lines

Based on your suggestion, we did this changes:

- The qemu notes patch [1] is removed, welcome your doc file ;-)
- Arnd's crosstools are customized by default
- Import cc-cross-prefix to support local cross toolchains too
- Use mips64 toolchains for mips like x86_64 toolchains for i386, allow download less toolchains
- Use HOSTCC for libc-test compiling

Quoted 7 lines

(...)

I think it's basically OK (just this mips64 thing). I've picked patch 3 already since it's a fix. Once we agree on what to do there, I can queue it if that helps (I can modify mips64- to mips- in the patch if that's OK for you, no need to resend for this, just let me know).

It is ok for me, thanks ;-)

I thought somebody may add mips64 support soon, but we do only have mips currently, it is fair to not use mips64 toolchain.

Quoted 4 lines

I think that later I'll further extend XARCH with new variants to support ARMv5 and Thumb2, because we have different code for this and I continue to manually change the CFLAGS to test both.

Ok, what about further add x86_64 as the default variant for x86 (like ppc for powerpc)? and then it is able to only resereve the variables for x86_64. I have prepared a patch for this goal in our new tinyconfig patchset, it will further avoid adding the same nolibc-test-x86.config and nolibc-test-x86_64.config.

Best regards,
Zhangjin

Quoted 2 lines

Thanks,
Willy

maintainer
#14 lore raw
Quoted 9 lines · Zhangjin Wu
Quoted 4 lines

I think that later I'll further extend XARCH with new variants to support ARMv5 and Thumb2, because we have different code for this and I continue to manually change the CFLAGS to test both.

Ok, what about further add x86_64 as the default variant for x86 (like ppc for powerpc)? and then it is able to only resereve the variables for x86_64. I have prepared a patch for this goal in our new tinyconfig patchset, it will further avoid adding the same nolibc-test-x86.config and nolibc-test-x86_64.config.

I'm confused, x86 already defaults to x86_64, it's just that it depends on the .config itself to figure whether to produce a 32- or 64-bit kernel. But for example it starts qemu in 64-bit mode. Am I missing anything ?

Willy

#15 lore raw
Quoted 6 lines · Zhangjin Wu
Quoted 5 lines
Quoted 4 lines

I think that later I'll further extend XARCH with new variants to support ARMv5 and Thumb2, because we have different code for this and I continue to manually change the CFLAGS to test both.

Quoted 9 lines
Quoted 4 lines

Ok, what about further add x86_64 as the default variant for x86 (like ppc for powerpc)? and then it is able to only resereve the variables for x86_64. I have prepared a patch for this goal in our new tinyconfig patchset, it will further avoid adding the same nolibc-test-x86.config and nolibc-test-x86_64.config.

I'm confused, x86 already defaults to x86_64, it's just that it depends on the .config itself to figure whether to produce a 32- or 64-bit kernel. But for example it starts qemu in 64-bit mode. Am I missing anything ?

In kernel side, it is, but in our nolibc-test, we have added a copy of x86_64 for x86:

    $ grep -E "_x86" tools/testing/selftests/nolibc/Makefile 
    IMAGE_x86_64     = arch/x86/boot/bzImage
    IMAGE_x86        = arch/x86/boot/bzImage
    CROSS_COMPILE_x86_64    ?= x86_64-linux- x86_64-linux-gnu-
    CROSS_COMPILE_x86       ?= x86_64-linux- x86_64-linux-gnu-
    DEFCONFIG_x86_64     = defconfig
    DEFCONFIG_x86        = defconfig
    QEMU_ARCH_x86_64     = x86_64
    QEMU_ARCH_x86        = x86_64
    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=%)"

With 'XARCH', the "_x86" copy of them can be simply replaced with such a line:

     # configure default variants for target kernel supported architectures
     XARCH_powerpc    = ppc
    +XARCH_x86        = x86_64
     XARCH            = $(or $(XARCH_$(ARCH)),$(ARCH))

And therefore, the future nolibc-test-x86_64.config is also enough for x86.

But I have seen the 'x86' exception in tools/include/nolibc/Makefile, just a confirm on if this replacement is ok.

BR,
Zhangjin

Quoted 1 line

Willy

maintainer
#16 lore raw
Quoted 38 lines · Zhangjin Wu
Quoted 6 lines · Zhangjin Wu
Quoted 5 lines
Quoted 4 lines

I think that later I'll further extend XARCH with new variants to support ARMv5 and Thumb2, because we have different code for this and I continue to manually change the CFLAGS to test both.

Quoted 9 lines
Quoted 4 lines

Ok, what about further add x86_64 as the default variant for x86 (like ppc for powerpc)? and then it is able to only resereve the variables for x86_64. I have prepared a patch for this goal in our new tinyconfig patchset, it will further avoid adding the same nolibc-test-x86.config and nolibc-test-x86_64.config.

I'm confused, x86 already defaults to x86_64, it's just that it depends on the .config itself to figure whether to produce a 32- or 64-bit kernel. But for example it starts qemu in 64-bit mode. Am I missing anything ?

In kernel side, it is, but in our nolibc-test, we have added a copy of x86_64 for x86:

    $ grep -E "_x86" tools/testing/selftests/nolibc/Makefile 
    IMAGE_x86_64     = arch/x86/boot/bzImage
    IMAGE_x86        = arch/x86/boot/bzImage
    CROSS_COMPILE_x86_64    ?= x86_64-linux- x86_64-linux-gnu-
    CROSS_COMPILE_x86       ?= x86_64-linux- x86_64-linux-gnu-
    DEFCONFIG_x86_64     = defconfig
    DEFCONFIG_x86        = defconfig
    QEMU_ARCH_x86_64     = x86_64
    QEMU_ARCH_x86        = x86_64
    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=%)"

With 'XARCH', the "_x86" copy of them can be simply replaced with such a line:

     # configure default variants for target kernel supported architectures
     XARCH_powerpc    = ppc
    +XARCH_x86        = x86_64
     XARCH            = $(or $(XARCH_$(ARCH)),$(ARCH))
Quoted 4 lines

And therefore, the future nolibc-test-x86_64.config is also enough for x86.

But I have seen the 'x86' exception in tools/include/nolibc/Makefile, just a confirm on if this replacement is ok.

Ah I thought you meant the opposite, i.e. that ppc did map to powerpc that I was not seeing anywhere else. Yes we can probably do that and remove the x86-specific lines later.

Willy

maintainer
#17 lore raw
Quoted 39 lines · Willy Tarreau
Quoted 38 lines · Zhangjin Wu
Quoted 6 lines · Zhangjin Wu
Quoted 5 lines
Quoted 4 lines

I think that later I'll further extend XARCH with new variants to support ARMv5 and Thumb2, because we have different code for this and I continue to manually change the CFLAGS to test both.

Quoted 9 lines
Quoted 4 lines

Ok, what about further add x86_64 as the default variant for x86 (like ppc for powerpc)? and then it is able to only resereve the variables for x86_64. I have prepared a patch for this goal in our new tinyconfig patchset, it will further avoid adding the same nolibc-test-x86.config and nolibc-test-x86_64.config.

I'm confused, x86 already defaults to x86_64, it's just that it depends on the .config itself to figure whether to produce a 32- or 64-bit kernel. But for example it starts qemu in 64-bit mode. Am I missing anything ?

In kernel side, it is, but in our nolibc-test, we have added a copy of x86_64 for x86:

    $ grep -E "_x86" tools/testing/selftests/nolibc/Makefile 
    IMAGE_x86_64     = arch/x86/boot/bzImage
    IMAGE_x86        = arch/x86/boot/bzImage
    CROSS_COMPILE_x86_64    ?= x86_64-linux- x86_64-linux-gnu-
    CROSS_COMPILE_x86       ?= x86_64-linux- x86_64-linux-gnu-
    DEFCONFIG_x86_64     = defconfig
    DEFCONFIG_x86        = defconfig
    QEMU_ARCH_x86_64     = x86_64
    QEMU_ARCH_x86        = x86_64
    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=%)"

With 'XARCH', the "_x86" copy of them can be simply replaced with such a line:

     # configure default variants for target kernel supported architectures
     XARCH_powerpc    = ppc
    +XARCH_x86        = x86_64
     XARCH            = $(or $(XARCH_$(ARCH)),$(ARCH))
Quoted 8 lines
Quoted 4 lines

And therefore, the future nolibc-test-x86_64.config is also enough for x86.

But I have seen the 'x86' exception in tools/include/nolibc/Makefile, just a confirm on if this replacement is ok.

Ah I thought you meant the opposite, i.e. that ppc did map to powerpc that I was not seeing anywhere else. Yes we can probably do that and remove the x86-specific lines later.

by "later" I mean "further" in the file.

Willy