diff mbox series

[v6,8/8] selftests/nolibc: customize CROSS_COMPILE for 32/64-bit powerpc

Message ID 2c3ac4542621ddc4b2cab006ae8e3a7b709921f1.1691259983.git.falcon@tinylab.org (mailing list archive)
State New
Headers show
Series tools/nolibc: add 32/64-bit powerpc support | expand

Commit Message

Zhangjin Wu Aug. 5, 2023, 6:47 p.m. UTC
The little-endian powerpc64le compilers provided by Ubuntu and Fedora
are able to compile big endian kernel and big endian nolibc-test [1].

These default CROSS_COMPILE settings allow to test target architectures
with:

    $ cd /path/to/tools/testing/selftests/nolibc/

    $ for arch in ppc ppc64 ppc64le; do \
        make run-user XARCH=$arch | grep "status: "; \
      done

If want to use another cross compiler, please simply pass CROSS_COMPILE
or CC as before.

For example, it is able to build 64-bit nolibc-test with the big endian
powerpc64-linux-gcc crosstool from [2]:

    $ wget -c https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-powerpc64-linux.tar.xz
    $ tar xvf x86_64-gcc-13.1.0-nolibc-powerpc64-linux.tar.xz
    $ export PATH=$PWD/gcc-13.1.0-nolibc/powerpc64-linux/bin/:$PATH

    $ export CROSS_COMPILE_ppc=powerpc64-linux-
    $ export CROSS_COMPILE_ppc64=powerpc64-linux-
    $ export CROSS_COMPILE_ppc64le=powerpc64-linux-
    $ for arch in ppc ppc64 ppc64le; do \
        make run-user XARCH=$arch | grep "status: "; \
      done

Or specify CC directly with full path:

    $ export CC=$PWD/gcc-13.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc
    $ for arch in ppc ppc64 ppc64le; do \
        make run-user XARCH=$arch | grep "status: "; \
      done

[1]: https://github.com/open-power/skiboot
[2]: https://mirrors.edge.kernel.org/pub/tools/crosstool/

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

Comments

Willy Tarreau Aug. 5, 2023, 8:48 p.m. UTC | #1
On Sun, Aug 06, 2023 at 02:47:09AM +0800, Zhangjin Wu wrote:
> The little-endian powerpc64le compilers provided by Ubuntu and Fedora
> are able to compile big endian kernel and big endian nolibc-test [1].

FWIW I'm wondering why focusing on these ones which have a different
naming from the other ones, when I think that most users rely on the
ones maintained by Arnd there:

   https://mirrors.edge.kernel.org/pub/tools/crosstool/

Yours is called powerpc64le while the one above is "powerpc64", it
requires to make an exception for this one, I find this a bit odd.

If someone wants to use their distro's cross toolchain, that's fine,
but I think that it will depend on distros anyway and some may not
even be provided (like loongarch) so I think it would make more sense
to adopt the canonical naming from Arnd's toolchains above.

It's not critical, but as you showed below, it makes building for ppc
a little bit cumbersome: those "export" lines could be dropped when
using the default names, and that's what we should document as the
recommended way to test:

> For example, it is able to build 64-bit nolibc-test with the big endian
> powerpc64-linux-gcc crosstool from [2]:
> 
>     $ wget -c https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-powerpc64-linux.tar.xz
>     $ tar xvf x86_64-gcc-13.1.0-nolibc-powerpc64-linux.tar.xz
>     $ export PATH=$PWD/gcc-13.1.0-nolibc/powerpc64-linux/bin/:$PATH
> 
>     $ export CROSS_COMPILE_ppc=powerpc64-linux-
>     $ export CROSS_COMPILE_ppc64=powerpc64-linux-
>     $ export CROSS_COMPILE_ppc64le=powerpc64-linux-
>     $ for arch in ppc ppc64 ppc64le; do \
>         make run-user XARCH=$arch | grep "status: "; \
>       done

Any opinion on this ?

Thanks,
Willy
Zhangjin Wu Aug. 6, 2023, 3:11 a.m. UTC | #2
Hi, Willy

> On Sun, Aug 06, 2023 at 02:47:09AM +0800, Zhangjin Wu wrote:
> > The little-endian powerpc64le compilers provided by Ubuntu and Fedora
> > are able to compile big endian kernel and big endian nolibc-test [1].
> 
> FWIW I'm wondering why focusing on these ones which have a different
> naming from the other ones, when I think that most users rely on the
> ones maintained by Arnd there:
> 
>    https://mirrors.edge.kernel.org/pub/tools/crosstool/
>

Arnd's toolchains may be a more distribution independent ones.

> Yours is called powerpc64le while the one above is "powerpc64", it
> requires to make an exception for this one, I find this a bit odd.
> 

Yes, one is little endian output by default, another may be big endian output
by default.

> If someone wants to use their distro's cross toolchain, that's fine,
> but I think that it will depend on distros anyway and some may not
> even be provided (like loongarch) so I think it would make more sense
> to adopt the canonical naming from Arnd's toolchains above.
>

Agree very much, let's switch to Arnd's toolchains.

> It's not critical, but as you showed below, it makes building for ppc
> a little bit cumbersome: those "export" lines could be dropped when
> using the default names, and that's what we should document as the
> recommended way to test:
> 
> > For example, it is able to build 64-bit nolibc-test with the big endian
> > powerpc64-linux-gcc crosstool from [2]:
> > 
> >     $ wget -c https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-powerpc64-linux.tar.xz
> >     $ tar xvf x86_64-gcc-13.1.0-nolibc-powerpc64-linux.tar.xz
> >     $ export PATH=$PWD/gcc-13.1.0-nolibc/powerpc64-linux/bin/:$PATH
> > 
> >     $ export CROSS_COMPILE_ppc=powerpc64-linux-
> >     $ export CROSS_COMPILE_ppc64=powerpc64-linux-
> >     $ export CROSS_COMPILE_ppc64le=powerpc64-linux-
> >     $ for arch in ppc ppc64 ppc64le; do \
> >         make run-user XARCH=$arch | grep "status: "; \
> >       done
> 
> Any opinion on this ?
>

Ok, let's go this way, if the others are ok for you, could you please
drop the last two CROSS_COMPILE patches from this v6 ppc series? Thanks.

I will send v2 CROSS_COMPILE series with them, with Arnd's toolchains, the
whole CROSS_COMPILE series will be unified and become very simple, although
they need to download the toolchains manually one by one, but it is possible to
write a common script, but that is another requirement.

BR,
Zhangjin
---
[1]: https://lore.kernel.org/lkml/cover.1691259983.git.falcon@tinylab.org/
[2]: https://lore.kernel.org/lkml/cover.1691263493.git.falcon@tinylab.org/

> Thanks,
> Willy
Willy Tarreau Aug. 6, 2023, 3:18 a.m. UTC | #3
On Sun, Aug 06, 2023 at 11:11:25AM +0800, Zhangjin Wu wrote:
> > If someone wants to use their distro's cross toolchain, that's fine,
> > but I think that it will depend on distros anyway and some may not
> > even be provided (like loongarch) so I think it would make more sense
> > to adopt the canonical naming from Arnd's toolchains above.
> >
> 
> Agree very much, let's switch to Arnd's toolchains.

Fine!

> Ok, let's go this way, if the others are ok for you, could you please
> drop the last two CROSS_COMPILE patches from this v6 ppc series? Thanks.

Will do.

> I will send v2 CROSS_COMPILE series with them, with Arnd's toolchains, the
> whole CROSS_COMPILE series will be unified and become very simple, although
> they need to download the toolchains manually one by one, but it is possible to
> write a common script, but that is another requirement.

Or even wget -r or any such thing.

Cheers,
Willy
diff mbox series

Patch

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 45d231b9c5c2..b4171a754eb2 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -56,6 +56,9 @@  IMAGE            = $(IMAGE_$(XARCH))
 IMAGE_NAME       = $(notdir $(IMAGE))
 
 # CROSS_COMPILE: cross toolchain prefix by architecture
+CROSS_COMPILE_ppc       ?= powerpc-linux-gnu-
+CROSS_COMPILE_ppc64     ?= powerpc64le-linux-gnu-
+CROSS_COMPILE_ppc64le   ?= powerpc64le-linux-gnu-
 CROSS_COMPILE           ?= $(CROSS_COMPILE_$(XARCH))
 
 # make sure CC is prefixed with CROSS_COMPILE