[RFC,v2,00/20] RISC-V glibc port for the 32-bit

Message ID cover.1561421042.git.alistair.francis@wdc.com
Headers show
Series
  • RISC-V glibc port for the 32-bit
Related show

Message

Alistair Francis June 25, 2019, 12:08 a.m.
This patch set contains the glibc port for the 32-bit RISC-V.

This is based on all of the work that Zong Li has done [1].

Unfortunately the Linux ABI has changed since Zong Li's latest
submission. The RISC-V 32-bit (RV32) ABI no longer defines
__ARCH_WANT_TIME32_SYSCALLS which means there are no 32-bit versions of
time_t, off_t or any struct resource or system calls that use them.

To mitigate this I have set the RV32 port to use 64-bit time_t and off_t
(as is done in x86-32) and also changed the syscall imvocation to handle
the missing syscalls.

The first 3 patches are from Lukasz and have been sent upstream before
[2].

The 4th patch is a fixup required ontop of Lukasz's patches.

Patches 5 to 9 are generic ways of handling the missing syscall functions.
Patch 11 changes all RISC-V implementations to use 64-bit time_t and off_t.

I have tested this series by building a buildroot kernel and rootFS
using these glibc patches and an upstream 5.1.12 kernel for RV32. I see
hangs because of patch 8.

Patch 8 (waitid) seems to cause hangs that I haven't debugged yet, it
seems like we aren't handing the wait() functions correctly. Any help
with this would be great.

The last patch is a hack to forcefully rename the remaining system calls
that are causing compiller failures to the 64-bit versions. This is
obviously not the correct way to do this. I would like some feedback on
this series to find the upstream approved way to use the 64-bit
versions then I will extend that to these remaining functions.

The ChangeLog will need to be updated as well, so don't worry too much
about that.

Feedback on this series is very welcome!

1: https://sourceware.org/ml/libc-alpha/2018-07/msg00892.html
2: https://sourceware.org/ml/libc-alpha/2019-05/msg00661.html

RFC v2:
 - Add Lukasz's patches
 - Update the non HACK syscalls after feedback
 - define __ASSUME_TIME64_SYSCALLS and __ASSUME_RLIM64_SYSCALLS
 - Remove lockf64.c
 - Other smaller changes from RFC v1

--END---

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

---
 __COVER__ | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 __COVER__

diff --git a/__COVER__ b/__COVER__
new file mode 100644
index 0000000000..e69de29bb2
-- 
2.22.0



Alistair Francis (7):
  include/time.h: Fix conflicting timespec types on 32-bit
  sysdeps/nanosleep: Use clock_nanosleep_time64 if avaliable
  sysdeps/futex: Use futex_time64 if avaliable
  sysdeps/gettimeofday: Use clock_gettime64 if avaliable
  sysdeps/wait: Use waitid if avaliable
  sysdeps/getrlimit: Use prlimit64 if avaliable
  RISC-V: Use 64-bit time_t and off_t for RV32 and RV64

Lukasz Majewski (3):
  y2038: Introduce internal for glibc struct __timespec64
  y2038: Provide conversion helpers for struct __timespec64
  y2038: linux: Provide __clock_settime64 implementation

Zong Li (10):
  Documentation for the RISC-V 32-bit port
  RISC-V: Support dynamic loader for the 32-bit
  RISC-V: Add path of library directories for the 32-bit
  RISC-V: The ABI implementation for the 32-bit
  RISC-V: Hard float support for the 32 bit
  RISC-V: Regenerate ULPs of RISC-V
  RISC-V: Add ABI lists
  RISC-V: Build Infastructure for the 32-bit
  RISC-V: Fix llrint and llround missing exceptions on RV32
  Add RISC-V 32-bit target to build-many-glibcs.py

 ChangeLog                                     |  115 +
 NEWS                                          |    6 +
 README                                        |    1 +
 include/time.h                                |  119 +
 nptl/thrd_sleep.c                             |   19 +-
 scripts/build-many-glibcs.py                  |   15 +
 sysdeps/riscv/bits/wordsize.h                 |    4 +-
 sysdeps/riscv/nofpu/libm-test-ulps            |   16 +-
 sysdeps/riscv/nptl/bits/pthreadtypes-arch.h   |   25 +-
 sysdeps/riscv/preconfigure                    |    6 +-
 sysdeps/riscv/rv32/Implies-after              |    1 +
 .../riscv/rv32/fix-fp-int-convert-overflow.h  |   38 +
 sysdeps/riscv/rv32/rvd/Implies                |    3 +
 sysdeps/riscv/rv32/rvd/s_lrint.c              |   31 +
 sysdeps/riscv/rv32/rvd/s_lround.c             |   31 +
 sysdeps/riscv/rv32/rvf/Implies                |    1 +
 sysdeps/riscv/rv32/rvf/s_lrintf.c             |   31 +
 sysdeps/riscv/rv32/rvf/s_lroundf.c            |   31 +
 sysdeps/riscv/{rv64 => }/rvd/libm-test-ulps   |   56 +-
 .../riscv/{rv64 => }/rvd/libm-test-ulps-name  |    0
 sysdeps/riscv/sfp-machine.h                   |   27 +-
 sysdeps/riscv/sys/asm.h                       |    5 +-
 sysdeps/unix/sysv/linux/clock_settime.c       |   37 +-
 sysdeps/unix/sysv/linux/getrlimit.c           |    9 +
 sysdeps/unix/sysv/linux/gettimeofday.c        |   28 +
 sysdeps/unix/sysv/linux/lowlevellock-futex.h  |   28 +-
 sysdeps/unix/sysv/linux/nanosleep.c           |   12 +
 sysdeps/unix/sysv/linux/nanosleep_nocancel.c  |   11 +
 sysdeps/unix/sysv/linux/riscv/Makefile        |    4 +-
 .../unix/sysv/linux/riscv/bits/environments.h |   85 +
 sysdeps/unix/sysv/linux/riscv/bits/time64.h   |   36 +
 sysdeps/unix/sysv/linux/riscv/bits/timesize.h |   22 +
 .../unix/sysv/linux/riscv/bits/typesizes.h    |   89 +
 sysdeps/unix/sysv/linux/riscv/configure       |   39 +
 sysdeps/unix/sysv/linux/riscv/configure.ac    |    8 +
 sysdeps/unix/sysv/linux/riscv/dl-cache.h      |   17 +-
 sysdeps/unix/sysv/linux/riscv/ldconfig.h      |    2 +-
 sysdeps/unix/sysv/linux/riscv/rv32/Implies    |    3 +
 .../unix/sysv/linux/riscv/rv32/c++-types.data |   67 +
 .../sysv/linux/riscv/rv32/jmp_buf-macros.h    |   53 +
 sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist |    9 +
 .../linux/riscv/rv32/libBrokenLocale.abilist  |    1 +
 .../unix/sysv/linux/riscv/rv32/libanl.abilist |    4 +
 .../unix/sysv/linux/riscv/rv32/libc.abilist   | 2101 +++++++++++++++++
 .../sysv/linux/riscv/rv32/libcrypt.abilist    |    2 +
 .../unix/sysv/linux/riscv/rv32/libdl.abilist  |    9 +
 .../unix/sysv/linux/riscv/rv32/libm.abilist   | 1021 ++++++++
 .../sysv/linux/riscv/rv32/libpthread.abilist  |  235 ++
 .../sysv/linux/riscv/rv32/libresolv.abilist   |   79 +
 .../unix/sysv/linux/riscv/rv32/librt.abilist  |   35 +
 .../linux/riscv/rv32/libthread_db.abilist     |   40 +
 .../sysv/linux/riscv/rv32/libutil.abilist     |    6 +
 sysdeps/unix/sysv/linux/riscv/shlib-versions  |   10 +-
 sysdeps/unix/sysv/linux/wait.c                |   21 +-
 sysdeps/unix/sysv/linux/waitpid.c             |   54 +
 sysdeps/unix/sysv/linux/waitpid_nocancel.c    |   53 +
 56 files changed, 4745 insertions(+), 66 deletions(-)
 create mode 100644 sysdeps/riscv/rv32/Implies-after
 create mode 100644 sysdeps/riscv/rv32/fix-fp-int-convert-overflow.h
 create mode 100644 sysdeps/riscv/rv32/rvd/Implies
 create mode 100644 sysdeps/riscv/rv32/rvd/s_lrint.c
 create mode 100644 sysdeps/riscv/rv32/rvd/s_lround.c
 create mode 100644 sysdeps/riscv/rv32/rvf/Implies
 create mode 100644 sysdeps/riscv/rv32/rvf/s_lrintf.c
 create mode 100644 sysdeps/riscv/rv32/rvf/s_lroundf.c
 rename sysdeps/riscv/{rv64 => }/rvd/libm-test-ulps (98%)
 rename sysdeps/riscv/{rv64 => }/rvd/libm-test-ulps-name (100%)
 create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/environments.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/time64.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/timesize.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/typesizes.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/Implies
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/libutil.abilist

-- 
2.22.0

Comments

Florian Weimer June 25, 2019, 11:15 a.m. | #1
* Alistair Francis:

> To mitigate this I have set the RV32 port to use 64-bit time_t and off_t

> (as is done in x86-32) and also changed the syscall imvocation to handle

> the missing syscalls.

>

> The first 3 patches are from Lukasz and have been sent upstream before

> [2].

>

> The 4th patch is a fixup required ontop of Lukasz's patches.


I think if the port has a 64-bit time_t only, you really should not need
Lukasz's patches.  What's problematic about the x86-64 x32 approach?

Thanks,
Florian
Arnd Bergmann June 25, 2019, 12:07 p.m. | #2
On Tue, Jun 25, 2019 at 1:16 PM Florian Weimer <fweimer@redhat.com> wrote:
>

> * Alistair Francis:

>

> > To mitigate this I have set the RV32 port to use 64-bit time_t and off_t

> > (as is done in x86-32) and also changed the syscall imvocation to handle

> > the missing syscalls.

> >

> > The first 3 patches are from Lukasz and have been sent upstream before

> > [2].

> >

> > The 4th patch is a fixup required ontop of Lukasz's patches.

>

> I think if the port has a 64-bit time_t only, you really should not need

> Lukasz's patches.  What's problematic about the x86-64 x32 approach?


x32 is really different from everything else at the kernel level. It's
an odd mix of the old __NR_* macros with data structures from the
64-bit kernel, while rv32 behaves just like all the other architectures
as long as you use the new data types. I would hope that nds32
and rv32 can implement the syscall interface in the same way,
and all future glibc ports can follow that. This will also share all the
code with the existing 32-bit architectures except that those
need a runtime fallback (until you stop stupporting kernels earlier
than linux-5.1, maybe in 5 to 10 years from now?).

      Arnd
Jim Wilson July 4, 2019, 8:47 a.m. | #3
On Tue, Jun 25, 2019 at 8:11 AM Alistair Francis
<alistair.francis@wdc.com> wrote:
> This is based on all of the work that Zong Li has done [1].


FYI Zong Li works for SiFive now.  I added his new email address to
the cc-list.  I don't know if he will have much time to help though,
as he has already been given a development assignment.

Jim