[RFC,v6,00/23] RISC-V glibc port for the 32-bit

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

Message

Alistair Francis Jan. 12, 2020, 10:33 a.m.
This patch set contains the glibc port for 32-bit RISC-V.

This is based on the original work from Zong Li [1] and has been
updated to use a 64-bit time_t.

This requires a 5.4+ kernel and all of the testing has been done using
the 5.4 stable kernel.

This series will have to updated to apply to gliibc 2.32 once the
development window opens up again.

This is a list of the tests that are currently failing when running make
check:

UNSUPPORTED: assert/tst-assert-c++
UNSUPPORTED: assert/tst-assert-g++
FAIL: conform/ISO11/stdalign.h/conform
FAIL: conform/POSIX/sys/mman.h/conform
XPASS: conform/UNIX98/ndbm.h/linknamespace
XPASS: conform/XOPEN2K/ndbm.h/linknamespace
UNRESOLVED: conform/XOPEN2K8/dirent.h/linknamespace
XPASS: conform/XOPEN2K8/ndbm.h/linknamespace
XPASS: conform/XPG42/ndbm.h/linknamespace
UNSUPPORTED: crypt/cert
UNSUPPORTED: debug/tst-chk4
UNSUPPORTED: debug/tst-chk5
UNSUPPORTED: debug/tst-chk6
UNSUPPORTED: debug/tst-lfschk4
UNSUPPORTED: debug/tst-lfschk5
UNSUPPORTED: debug/tst-lfschk6
UNSUPPORTED: dlfcn/bug-atexit3
FAIL: elf/check-abi-libc
FAIL: iconvdata/iconv-test
FAIL: iconvdata/tst-tables
FAIL: io/tst-lockf
FAIL: localedata/tst-sscanf
UNSUPPORTED: malloc/tst-mallocstate
FAIL: math/atest-exp
FAIL: math/atest-exp2
FAIL: math/atest-sincos
FAIL: math/test-double-acosh
UNSUPPORTED: math/test-fesetexcept-traps
UNSUPPORTED: math/test-fexcept-traps
FAIL: math/test-idouble-sincos
FAIL: math/test-ifloat-ccos
FAIL: math/test-ifloat-remquo
FAIL: math/test-ldouble-fromfpx
UNSUPPORTED: math/test-matherr
UNSUPPORTED: math/test-matherr-2
UNSUPPORTED: math/test-nearbyint-except-2
FAIL: misc/test-errno-linux
UNSUPPORTED: misc/tst-ofdlocks-compat
UNSUPPORTED: misc/tst-pkey
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
UNSUPPORTED: nptl/tst-cancel24
UNSUPPORTED: nptl/tst-cancel24-static
UNSUPPORTED: nptl/tst-minstack-throw
UNSUPPORTED: nptl/tst-once5
UNSUPPORTED: nptl/tst-thread-exit-clobber
UNSUPPORTED: nptl/tst-thread_local1
FAIL: nss/tst-nss-files-hosts-long
UNSUPPORTED: posix/tst-glob_lstat_compat
UNSUPPORTED: posix/tst-spawn4-compat
UNSUPPORTED: resolv/tst-p_secstodate
UNSUPPORTED: resolv/tst-resolv-ai_idn
UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1
FAIL: resolv/tst-resolv-res_init-thread
FAIL: signal/tst-signal-numbers
FAIL: stdio-common/bug22
UNSUPPORTED: stdlib/tst-quick_exit
FAIL: stdlib/tst-strfrom
FAIL: stdlib/tst-strfrom-locale
FAIL: stdlib/tst-strtod-round
UNSUPPORTED: stdlib/tst-thread-quick_exit
FAIL: sunrpc/tst-udp-nonblocking
FAIL: sunrpc/tst-udp-timeout
FAIL: sysvipc/test-sysvmsg
FAIL: sysvipc/test-sysvsem
FAIL: wcsmbs/tst-wcstod-round
Summary of test results:
     28 FAIL
   4940 PASS
      1 UNRESOLVED
     37 UNSUPPORTED
     14 XFAIL
      4 XPASS

---Links---
1: https://sourceware.org/ml/libc-alpha/2018-07/msg00892.html

The latest version of my work can be found here: https://github.com/alistair23/glibc/tree/alistair/rv32.next

This specific version can be found here: https://github.com/alistair23/glibc/tree/alistair/rv32.rfc6

---Changelog---
RFC v6:
 - Rebase on top of accetpted patches
 - Fix issues so that the tests actually run
RFC v5:
 - Hopefully finally get the correct layout for the *64 syscalls
 - Sort out the Changelog
RFC v4:
 - Continue to fix things that weren't working
 - Update the coding style to match glibc
 - Update the __ASSUME_TIME64_SYSCALLS work to better match Lukasz's
 work
RFC v3:
 - Remove all "Hack" patches
 - Incorporate upstream comments
 - Ensure we don't break RV64
 - Lot's more testing and fixes
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

Alistair Francis (14):
  math/gen-libm-test.py: Convert to Python 3
  tst-clone3: Use __NR_futex_time64 if we don't have __NR_futex
  time: Add a timeval with a long tv_sec and tv_usec
  linux: Use 32-bit time_t for itimerval
  linux: Use 32-bit time_t for rusage
  sysdeps: Use long types with 64-bit time_t on 32-bit archs
  RISC-V: Use 64-bit time_t and off_t for RV32 and RV64
  RISC-V: Define __NR_* as __NR_*_time64/64 for 32-bit
  RISC-V: Add support for 32-bit vDSO calls
  RISC-V: Add socket-constants.h for RV32
  RISC-V: Add arch-syscall.h for RV32
  RISC-V: Add ABI lists
  RISC-V: Add the RV32 libm-test-ulps
  riscv32: Specify the arch_minimum_kernel as 5.4

Zong Li (9):
  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 32-bit
  RISC-V: Fix llrint and llround missing exceptions on RV32
  RISC-V: Build Infastructure for 32-bit
  RISC-V: Add rv32 path to RTLDLIST in ldd
  Documentation for the RISC-V 32-bit port
  Add RISC-V 32-bit target to build-many-glibcs.py

 NEWS                                          |    6 +
 README                                        |    1 +
 include/time.h                                |   29 +
 math/gen-libm-test.py                         |    2 +-
 scripts/build-many-glibcs.py                  |   15 +
 sysdeps/riscv/bits/wordsize.h                 |    4 +-
 sysdeps/riscv/nptl/bits/pthreadtypes-arch.h   |   10 +-
 sysdeps/riscv/nptl/bits/struct_rwlock.h       |   27 +-
 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/libm-test-ulps         | 2214 +++++++++++++++++
 sysdeps/riscv/rv32/rvd/libm-test-ulps-name    |    1 +
 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/sfp-machine.h                   |   27 +-
 sysdeps/riscv/sys/asm.h                       |    5 +-
 sysdeps/unix/sysv/linux/bits/sem-pad.h        |   13 +-
 .../linux/generic/wordsize-32/getitimer.c     |   42 +
 .../linux/generic/wordsize-32/getrusage.c     |   39 +
 .../linux/generic/wordsize-32/setitimer.c     |   53 +
 .../linux/generic/wordsize-32/tv32-compat.h   |   82 +
 .../sysv/linux/generic/wordsize-32/wait4.c    |   79 +
 sysdeps/unix/sysv/linux/riscv/Makefile        |    4 +-
 .../unix/sysv/linux/riscv/bits/environments.h |   85 +
 .../sysv/linux/riscv/bits/socket-constants.h  |   46 +
 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    |   90 +
 sysdeps/unix/sysv/linux/riscv/c++-types.data  |   67 +
 sysdeps/unix/sysv/linux/riscv/configure       |   40 +
 sysdeps/unix/sysv/linux/riscv/configure.ac    |   12 +
 sysdeps/unix/sysv/linux/riscv/dl-cache.h      |   17 +-
 .../unix/sysv/linux/riscv/jmp_buf-macros.h    |   53 +
 sysdeps/unix/sysv/linux/riscv/kernel_stat.h   |   23 +
 sysdeps/unix/sysv/linux/riscv/ld.abilist      |    9 +
 sysdeps/unix/sysv/linux/riscv/ldconfig.h      |    2 +-
 sysdeps/unix/sysv/linux/riscv/ldd-rewrite.sed |    2 +-
 .../sysv/linux/riscv/libBrokenLocale.abilist  |    1 +
 sysdeps/unix/sysv/linux/riscv/libanl.abilist  |    4 +
 sysdeps/unix/sysv/linux/riscv/libc.abilist    | 2095 ++++++++++++++++
 .../unix/sysv/linux/riscv/libcrypt.abilist    |    2 +
 sysdeps/unix/sysv/linux/riscv/libdl.abilist   |    9 +
 sysdeps/unix/sysv/linux/riscv/libm.abilist    |  940 +++++++
 .../unix/sysv/linux/riscv/libpthread.abilist  |  227 ++
 .../unix/sysv/linux/riscv/libresolv.abilist   |   79 +
 sysdeps/unix/sysv/linux/riscv/librt.abilist   |   35 +
 .../sysv/linux/riscv/libthread_db.abilist     |   40 +
 sysdeps/unix/sysv/linux/riscv/libutil.abilist |    6 +
 sysdeps/unix/sysv/linux/riscv/rv32/Implies    |    3 +
 .../unix/sysv/linux/riscv/rv32/arch-syscall.h |  281 +++
 sysdeps/unix/sysv/linux/riscv/shlib-versions  |   10 +-
 sysdeps/unix/sysv/linux/riscv/sysdep.h        |   94 +-
 sysdeps/unix/sysv/linux/tst-clone3.c          |    4 +
 time/bits/types/struct_timeval.h              |    8 +
 59 files changed, 7143 insertions(+), 25 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/libm-test-ulps
 create mode 100644 sysdeps/riscv/rv32/rvd/libm-test-ulps-name
 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
 create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/getitimer.c
 create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/getrusage.c
 create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/setitimer.c
 create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/tv32-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/wait4.c
 create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/environments.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/socket-constants.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/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/riscv/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/riscv/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/Implies
 create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h

-- 
2.24.1

Comments

Joseph Myers Jan. 12, 2020, 2:44 p.m. | #1
On Sun, 12 Jan 2020, Alistair Francis wrote:

> This is a list of the tests that are currently failing when running make

> check:


Could you give more details for the FAILing tests of why they are failing?

> FAIL: conform/ISO11/stdalign.h/conform

> FAIL: conform/POSIX/sys/mman.h/conform


No ports should be added where any compilation tests are failing.  You 
need to fix all the compilation tests so that build-many-glibcs.py results 
can remain clean.

-- 
Joseph S. Myers
joseph@codesourcery.com
Alistair Francis Jan. 14, 2020, 7:30 a.m. | #2
On Mon, Jan 13, 2020 at 12:44 AM Joseph Myers <joseph@codesourcery.com> wrote:
>

> On Sun, 12 Jan 2020, Alistair Francis wrote:

>

> > This is a list of the tests that are currently failing when running make

> > check:

>

> Could you give more details for the FAILing tests of why they are failing?

>

> > FAIL: conform/ISO11/stdalign.h/conform

> > FAIL: conform/POSIX/sys/mman.h/conform

>

> No ports should be added where any compilation tests are failing.  You

> need to fix all the compilation tests so that build-many-glibcs.py results

> can remain clean.


Yep.

The errors I get are strange though, I'm not sure how to debug:

# cat conform/ISO11/stdalign.h/conform.out
Traceback (most recent call last):
  File "conformtest.py", line 26, in <module>
    import tempfile
  File "/usr/lib/python3.7/tempfile.py", line 45, in <module>
    from random import Random as _Random
  File "/usr/lib/python3.7/random.py", line 58, in <module>
    NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
ValueError: math domain error

# cat conform/POSIX/sys/mman.h/conform.out
Traceback (most recent call last):
  File "conformtest.py", line 26, in <module>
    import tempfile
  File "/usr/lib/python3.7/tempfile.py", line 45, in <module>
    from random import Random as _Random
  File "/usr/lib/python3.7/random.py", line 58, in <module>
    NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
ZeroDivisionError: float division by zero

Alistair

>

> --

> Joseph S. Myers

> joseph@codesourcery.com
Joseph Myers Jan. 14, 2020, 10:08 p.m. | #3
On Tue, 14 Jan 2020, Alistair Francis wrote:

> Yep.

> 

> The errors I get are strange though, I'm not sure how to debug:

> 

> # cat conform/ISO11/stdalign.h/conform.out

> Traceback (most recent call last):

>   File "conformtest.py", line 26, in <module>

>     import tempfile

>   File "/usr/lib/python3.7/tempfile.py", line 45, in <module>

>     from random import Random as _Random

>   File "/usr/lib/python3.7/random.py", line 58, in <module>

>     NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)

> ValueError: math domain error


That suggests you've got a broken python installation.  If you're doing 
native testing on RV32, I suggest doing cross-testing (using 
cross-test-ssh.sh) instead, so that python runs on a known-good build 
system, until the RV32 system is stable enough.

-- 
Joseph S. Myers
joseph@codesourcery.com
Alistair Francis Jan. 15, 2020, 4:30 a.m. | #4
On Wed, Jan 15, 2020 at 8:08 AM Joseph Myers <joseph@codesourcery.com> wrote:
>

> On Tue, 14 Jan 2020, Alistair Francis wrote:

>

> > Yep.

> >

> > The errors I get are strange though, I'm not sure how to debug:

> >

> > # cat conform/ISO11/stdalign.h/conform.out

> > Traceback (most recent call last):

> >   File "conformtest.py", line 26, in <module>

> >     import tempfile

> >   File "/usr/lib/python3.7/tempfile.py", line 45, in <module>

> >     from random import Random as _Random

> >   File "/usr/lib/python3.7/random.py", line 58, in <module>

> >     NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)

> > ValueError: math domain error

>

> That suggests you've got a broken python installation.  If you're doing

> native testing on RV32, I suggest doing cross-testing (using

> cross-test-ssh.sh) instead, so that python runs on a known-good build

> system, until the RV32 system is stable enough.


Thanks for the tip!

When running on my x86_64 machine and using this command to run the
tests on RV32:

make test-wrapper='/slow-scratch/alistair/software/glibc/scripts/cross-test-ssh.sh
--ssh "ssh -p 2222" --timeoutfactor 100 root@127.0.0.1' tests

I get this result:

FAIL: elf/check-abi-libc
Summary of test results:
      1 FAIL
   1204 PASS
     15 XFAIL

The failure for elf/check-abi-libc.out is:

--- ../sysdeps/unix/sysv/linux/riscv/libc.abilist       2020-01-14
16:27:58.805195715 -0800
+++ /slow-scratch/alistair/software/glibc/build/libc.symlist
2020-01-14 18:48:08.711608082 -0800
@@ -510 +510 @@ GLIBC_2.31 _mcount F
-GLIBC_2.31 _nl_default_dirname D 0x12
+GLIBC_2.31 _nl_default_dirname D 0x16

I have tried making this change before, but then the test case fails
when running ./scripts/build-many-glibcs.py

Any ideas why there are conflicting values for _nl_default_dirname and
which one should it be?

Also, as it seems like all the conform tests are passing when run via
cross compile can I assume the failure is related to Python and mark
it as passing?

Alistair

>

> --

> Joseph S. Myers

> joseph@codesourcery.com
Joseph Myers Jan. 15, 2020, 9:50 p.m. | #5
On Wed, 15 Jan 2020, Alistair Francis wrote:

> --- ../sysdeps/unix/sysv/linux/riscv/libc.abilist       2020-01-14

> 16:27:58.805195715 -0800

> +++ /slow-scratch/alistair/software/glibc/build/libc.symlist

> 2020-01-14 18:48:08.711608082 -0800

> @@ -510 +510 @@ GLIBC_2.31 _mcount F

> -GLIBC_2.31 _nl_default_dirname D 0x12

> +GLIBC_2.31 _nl_default_dirname D 0x16


You need to use --prefix=/usr; the length of the prefix affect the ABI.

-- 
Joseph S. Myers
joseph@codesourcery.com
Alistair Francis Jan. 15, 2020, 11:50 p.m. | #6
On Thu, Jan 16, 2020 at 7:50 AM Joseph Myers <joseph@codesourcery.com> wrote:
>

> On Wed, 15 Jan 2020, Alistair Francis wrote:

>

> > --- ../sysdeps/unix/sysv/linux/riscv/libc.abilist       2020-01-14

> > 16:27:58.805195715 -0800

> > +++ /slow-scratch/alistair/software/glibc/build/libc.symlist

> > 2020-01-14 18:48:08.711608082 -0800

> > @@ -510 +510 @@ GLIBC_2.31 _mcount F

> > -GLIBC_2.31 _nl_default_dirname D 0x12

> > +GLIBC_2.31 _nl_default_dirname D 0x16

>

> You need to use --prefix=/usr; the length of the prefix affect the ABI.


Ah, thanks.

So it looks like all the conform tests are passing :)

I'm running the full suit of tests via cross compiling with NFS mount
as well. When the 2.32 window opens up I should be ready to go.

Thanks for all of your help Joseph.

Alistair

>

> --

> Joseph S. Myers

> joseph@codesourcery.com