riscv32 support

Submitted by Stefan O'Rear on Sept. 3, 2020, 11:22 a.m.

Details

Reviewer None
Submitted Sept. 3, 2020, 11:22 a.m.
Last Updated Sept. 3, 2020, 9:25 p.m.
Revision 1

Cover Letter

Several changes to support architectures without time32 syscalls, and
then a riscv32 port (created by copying the riscv64 files and changing
as necessary).

Cleanup in configure is related only insofar as I spent time determining
what it did while researching musl's ARCH/SUBARCH system, and removing
the relic will slightly speed up future ports.

I don't have a great handle on how musl handles files (what should they
be called, where should they be, whether include guards should be used
and whether headers should include everything they depend on) and would
particularly welcome feedback on that.  Likewise I don't have a good
model of the musl whitespace and paren style.

Requires Linux 5.4 for full functionality due to using waitid(P_PGID,0)
to emulate waitpid(0); earlier kernels may be supported on a best-effort
basis.

Testing so far has consisted of building openembedded with TCLIBC=musl
and the patch added to the musl recipe, booting the resulting images,
and running the strace build system in the VM.  This includes systemd
with the openembedded musl compatibilty patches.  strace does not work
(it prints a spurious SIGTRAP message and then the tracee runs
untraced).  Further testing and debugging will continue.

Testing on non-riscv32 architectures also remains to be done.

Stefan O'Rear (14):
  Remove ARMSUBARCH relic from configure
  time64: Don't make aliases to nonexistent syscalls
  time64: Only getrlimit/setrlimit if they exist
  time64: Only gettimeofday/settimeofday if exist
  Add src/internal/statx.h
  Only call fstatat if defined
  Emulate wait4 using waitid
  riscv: Fall back to syscall __riscv_flush_icache
  riscv32: Target and subtarget detection
  riscv32: add arch headers
  riscv32: Add fenv and math
  riscv32: Add dlsym
  riscv32: Add jmp_buf and sigreturn
  riscv32: Add thread support

 arch/riscv32/atomic_arch.h             |  21 ++
 arch/riscv32/bits/alltypes.h.in        |  18 ++
 arch/riscv32/bits/fcntl.h              |  38 ++++
 arch/riscv32/bits/fenv.h               |  17 ++
 arch/riscv32/bits/float.h              |  16 ++
 arch/riscv32/bits/posix.h              |   2 +
 arch/riscv32/bits/setjmp.h             |   1 +
 arch/riscv32/bits/signal.h             | 118 ++++++++++
 arch/riscv32/bits/stat.h               |  18 ++
 arch/riscv32/bits/stdint.h             |  20 ++
 arch/riscv32/bits/syscall.h.in         | 284 +++++++++++++++++++++++++
 arch/riscv32/bits/user.h               |   5 +
 arch/riscv32/crt_arch.h                |  19 ++
 arch/riscv32/kstat.h                   |   0
 arch/riscv32/pthread_arch.h            |  13 ++
 arch/riscv32/reloc.h                   |  22 ++
 arch/riscv32/syscall_arch.h            |  78 +++++++
 configure                              |   8 +-
 src/fenv/riscv32/fenv-sf.c             |   3 +
 src/fenv/riscv32/fenv.S                |  56 +++++
 src/internal/statx.h                   |  28 +++
 src/internal/syscall.h                 |   2 +
 src/internal/wait4_waitid.h            |   1 +
 src/ldso/riscv32/dlsym.s               |   6 +
 src/linux/__wait4_waitid.c             |  52 +++++
 src/linux/cache.c                      |   1 +
 src/linux/wait4.c                      |   5 +
 src/math/riscv32/copysign.c            |  15 ++
 src/math/riscv32/copysignf.c           |  15 ++
 src/math/riscv32/fabs.c                |  15 ++
 src/math/riscv32/fabsf.c               |  15 ++
 src/math/riscv32/fma.c                 |  15 ++
 src/math/riscv32/fmaf.c                |  15 ++
 src/math/riscv32/fmax.c                |  15 ++
 src/math/riscv32/fmaxf.c               |  15 ++
 src/math/riscv32/fmin.c                |  15 ++
 src/math/riscv32/fminf.c               |  15 ++
 src/math/riscv32/sqrt.c                |  15 ++
 src/math/riscv32/sqrtf.c               |  15 ++
 src/misc/getrlimit.c                   |   6 +-
 src/misc/setrlimit.c                   |   6 +-
 src/process/waitpid.c                  |   6 +
 src/setjmp/riscv32/longjmp.S           |  42 ++++
 src/setjmp/riscv32/setjmp.S            |  41 ++++
 src/signal/riscv32/restore.s           |   8 +
 src/signal/riscv32/sigsetjmp.s         |  23 ++
 src/stat/fchmodat.c                    |  22 +-
 src/stat/fstatat.c                     |  34 +--
 src/stdio/pclose.c                     |   6 +
 src/stdio/tempnam.c                    |   7 +
 src/stdio/tmpnam.c                     |   7 +
 src/thread/riscv32/__set_thread_area.s |   6 +
 src/thread/riscv32/__unmapself.s       |   7 +
 src/thread/riscv32/clone.s             |  34 +++
 src/thread/riscv32/syscall_cp.s        |  29 +++
 src/time/__map_file.c                  |  13 +-
 src/time/clock_gettime.c               |   4 +
 src/unistd/faccessat.c                 |   6 +-
 58 files changed, 1302 insertions(+), 37 deletions(-)
 create mode 100644 arch/riscv32/atomic_arch.h
 create mode 100644 arch/riscv32/bits/alltypes.h.in
 create mode 100644 arch/riscv32/bits/fcntl.h
 create mode 100644 arch/riscv32/bits/fenv.h
 create mode 100644 arch/riscv32/bits/float.h
 create mode 100644 arch/riscv32/bits/posix.h
 create mode 100644 arch/riscv32/bits/setjmp.h
 create mode 100644 arch/riscv32/bits/signal.h
 create mode 100644 arch/riscv32/bits/stat.h
 create mode 100644 arch/riscv32/bits/stdint.h
 create mode 100644 arch/riscv32/bits/syscall.h.in
 create mode 100644 arch/riscv32/bits/user.h
 create mode 100644 arch/riscv32/crt_arch.h
 create mode 100644 arch/riscv32/kstat.h
 create mode 100644 arch/riscv32/pthread_arch.h
 create mode 100644 arch/riscv32/reloc.h
 create mode 100644 arch/riscv32/syscall_arch.h
 create mode 100644 src/fenv/riscv32/fenv-sf.c
 create mode 100644 src/fenv/riscv32/fenv.S
 create mode 100644 src/internal/statx.h
 create mode 100644 src/internal/wait4_waitid.h
 create mode 100644 src/ldso/riscv32/dlsym.s
 create mode 100644 src/linux/__wait4_waitid.c
 create mode 100644 src/math/riscv32/copysign.c
 create mode 100644 src/math/riscv32/copysignf.c
 create mode 100644 src/math/riscv32/fabs.c
 create mode 100644 src/math/riscv32/fabsf.c
 create mode 100644 src/math/riscv32/fma.c
 create mode 100644 src/math/riscv32/fmaf.c
 create mode 100644 src/math/riscv32/fmax.c
 create mode 100644 src/math/riscv32/fmaxf.c
 create mode 100644 src/math/riscv32/fmin.c
 create mode 100644 src/math/riscv32/fminf.c
 create mode 100644 src/math/riscv32/sqrt.c
 create mode 100644 src/math/riscv32/sqrtf.c
 create mode 100644 src/setjmp/riscv32/longjmp.S
 create mode 100644 src/setjmp/riscv32/setjmp.S
 create mode 100644 src/signal/riscv32/restore.s
 create mode 100644 src/signal/riscv32/sigsetjmp.s
 create mode 100644 src/thread/riscv32/__set_thread_area.s
 create mode 100644 src/thread/riscv32/__unmapself.s
 create mode 100644 src/thread/riscv32/clone.s
 create mode 100644 src/thread/riscv32/syscall_cp.s
  

Revisions