[PATCH v1 00/11] tools/nolibc: shrink arch support

Zhangjin Wu falcon at tinylab.org
Wed Jun 28 11:50:41 PDT 2023


Hi,

This patchset further improves porting of nolibc to new architectures,
it is based on our previous v5 sysret helper series [1].

It mainly shrinks the assembly _start by moving most of its operations
to a C version of _start_c() function. and also, it removes the old
sys_stat() support by using the sys_statx() instead and therefore,
removes all of the arch specific sys_stat_struct.

Tested 'run' on all of the supported architectures:

               arch/board | result
              ------------|------------
          arm/vexpress-a9 | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/arm-vexpress-a9-nolibc-test.log
                 arm/virt | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/arm-virt-nolibc-test.log
             aarch64/virt | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/aarch64-virt-nolibc-test.log
              ppc/g3beige | not supported
              ppc/ppce500 | not supported
                  i386/pc | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/i386-pc-nolibc-test.log
                x86_64/pc | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/x86_64-pc-nolibc-test.log
             mipsel/malta | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/mipsel-malta-nolibc-test.log
         loongarch64/virt | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/loongarch64-virt-nolibc-test.log
             riscv64/virt | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/riscv64-virt-nolibc-test.log
             riscv32/virt | 119 test(s) passed, 1 skipped, 22 failed. See all results in /labs/linux-lab/logging/nolibc/riscv32-virt-nolibc-test.log
    s390x/s390-ccw-virtio | 141 test(s) passed, 1 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/s390x-s390-ccw-virtio-nolibc-test.log

  Notes:
  - ppc support are ready locally, will be sent out later.
  - full riscv32/virt support are ready locally, will be sent out later.

Changes:

* tools/nolibc: remove old arch specific stat support

    Just like the __NR_statx we used in nolibc-test.c, Let's only
    reserve sys_statx() and use it to implement the stat() function.

    Remove the old sys_stat() and sys_stat_struct completely.

* tools/nolibc: add new crt.h with _start_c

    A new C version of _start_c() is added to only require a 'sp' argument
    and find the others (argc, argv, envp/environ, auxv) for us in C.

* tools/nolibc: include crt.h before arch.h

    Include crt.h before arch.h to let _start() be able to call the new
    added _start_c() in arch-<ARCH>.h.

* tools/nolibc: arm: shrink _start with _start_c
  tools/nolibc: aarch64: shrink _start with _start_c
  tools/nolibc: i386: shrink _start with _start_c
  tools/nolibc: x86_64: shrink _start with _start_c
  tools/nolibc: mips: shrink _start with _start_c
  tools/nolibc: loongarch: shrink _start with _start_c
  tools/nolibc: riscv: shrink _start with _start_c
  tools/nolibc: s390: shrink _start with _start_c

    Move most of the operations from the assembly _start() to the C
    _start_c(), only require to do minimal operations in assembly _start
    now.

With this patchset, porting nolibc to a new architecture become easier,
the powerpc porting will be added later.

Best regards,
Zhangjin
---
[1]: https://lore.kernel.org/lkml/cover.1687957589.git.falcon@tinylab.org/

Zhangjin Wu (11):
  tools/nolibc: remove old arch specific stat support
  tools/nolibc: add new crt.h with _start_c
  tools/nolibc: include crt.h before arch.h
  tools/nolibc: arm: shrink _start with _start_c
  tools/nolibc: aarch64: shrink _start with _start_c
  tools/nolibc: i386: shrink _start with _start_c
  tools/nolibc: x86_64: shrink _start with _start_c
  tools/nolibc: mips: shrink _start with _start_c
  tools/nolibc: loongarch: shrink _start with _start_c
  tools/nolibc: riscv: shrink _start with _start_c
  tools/nolibc: s390: shrink _start with _start_c

 tools/include/nolibc/Makefile         |  1 +
 tools/include/nolibc/arch-aarch64.h   | 53 ++----------------
 tools/include/nolibc/arch-arm.h       | 79 ++-------------------------
 tools/include/nolibc/arch-i386.h      | 58 +++-----------------
 tools/include/nolibc/arch-loongarch.h | 42 ++------------
 tools/include/nolibc/arch-mips.h      | 73 +++----------------------
 tools/include/nolibc/arch-riscv.h     | 65 ++--------------------
 tools/include/nolibc/arch-s390.h      | 60 ++------------------
 tools/include/nolibc/arch-x86_64.h    | 54 ++----------------
 tools/include/nolibc/crt.h            | 57 +++++++++++++++++++
 tools/include/nolibc/nolibc.h         |  1 +
 tools/include/nolibc/signal.h         |  1 +
 tools/include/nolibc/stdio.h          |  1 +
 tools/include/nolibc/stdlib.h         |  1 +
 tools/include/nolibc/sys.h            | 64 ++++------------------
 tools/include/nolibc/time.h           |  1 +
 tools/include/nolibc/types.h          |  4 +-
 tools/include/nolibc/unistd.h         |  1 +
 18 files changed, 122 insertions(+), 494 deletions(-)
 create mode 100644 tools/include/nolibc/crt.h

-- 
2.25.1




More information about the linux-riscv mailing list