Message ID | 20171220072022.26909-2-palmer@dabbelt.com |
---|---|
State | New |
Headers | show |
Series | [v2,01/15] RISC-V: Build Infastructure | expand |
On Tue, Dec 19, 2017 at 11:20:08PM -0800, Palmer Dabbelt wrote: > This patch lays out the top-level orginazition of the RISC-V port. It > contains all the Implies files as well as various other fragments of > build infastructure for the RISC-V port. This contains the only change > to a shared file: config.h.in. [...] > config.h.in | 5 + > nptl/Makefile | 4 + Well, nptl/Makefile is a shared file, too. [...] > diff --git a/nptl/Makefile b/nptl/Makefile > index 60d036a1ea42..f62d19febf1d 100644 > --- a/nptl/Makefile > +++ b/nptl/Makefile > @@ -611,6 +611,10 @@ else > librt = $(common-objpfx)rt/librt.a > endif > > +# `make check' sometimes triggers a rebuild of librt.so using this Makefile, > +# which ignores librt's dependence on libpthread > +$(common-objpfx)rt/librt.so: $(shared-thread-library) > + > $(objpfx)tst-cancel17: $(librt) > $(objpfx)tst-cancelx17: $(librt) > $(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so In fact, this looks like a fix unrelated to the RISC-V port. If this is really the case, please submit the fix separately. Thanks,
On Tue, 19 Dec 2017, Palmer Dabbelt wrote: > diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile > new file mode 100644 > index 000000000000..64060531a1d5 > --- /dev/null > +++ b/sysdeps/riscv/Makefile > @@ -0,0 +1,49 @@ > +ifneq ($(all-rtld-routines),) > +CFLAGS-rtld.c += -mno-plt My previous comments from <https://sourceware.org/ml/libc-alpha/2017-06/msg00645.html> still apply: this is too fragile (people won't think when making an architecture-independent change about whether it needs a RISC-V-specific change here) and completely lacking the required detailed explanatory comment of what the issue is and the logic for determining what files need this option (but really the logic should be implemented to avoid an architecture-specific list of architecture-independent files being needed at all). > diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions > new file mode 100644 > index 000000000000..aafa348a2395 > --- /dev/null > +++ b/sysdeps/riscv/Versions > @@ -0,0 +1,4 @@ > +libc { > + GLIBC_2.27 { > + } > +} You shouldn't need this file at all when there aren't any versions to include in it. > diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure Does your soft-float lack support for exceptions and rounding modes? If so, I'd expect a setting of with_fp_cond, and a corresponding nofpu directory or directories with Implies files pointing to ieee754/soft-fp (arranged so that always comes before the other ieee754/ directories in the sysdeps directory ordering). That's needed to get the soft-fp versions of fmaf/fma/fmal used instead of the default ones relying on exceptions and rounding modes, so its absence should show up as test failures for soft-float configurations. In future it will also similarly be needed to get soft-fp versions of TS 18661-1 narrowing functions used. Remark: it makes sense for ieee754/dbl-64/wordsize-64 to be used (before ieee754/dbl-64 in the sysdeps directory ordering) in configurations with 64-bit registers (but that's just an optimization so you may wish to defer it). > +abi-ilp32-options := -D__SIZEOF_INT__=4 abi-* options variables are no longer used with the current bits/syscall.h generation mechanism, so you should remove all settings of such variables from the patch. > diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Makefile b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile > new file mode 100644 > index 000000000000..cb60d740476d > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile > @@ -0,0 +1,4 @@ > +ifeq ($(subdir),socket) > +CFLAGS-recv.c += -fexceptions > +CFLAGS-send.c += -fexceptions > +endif I wonder if this should be made generic for all Linux ports (and removed from the mips64 Makefile as well as here).
Another observation: Since you're using ldbl-128, that presumably means _Float128 and _Float64x type names are supported with the same format as long double. So you need to add RISC-V to the list in manual/math.texi of ports for which those type names and associated interfaces are supported. I don't think you strictly need to add it to the similar lists for _Float128 and _Float64x support in the NEWS section for glibc 2.27, since the whole port is new rather than this being a new feature for an existing port in the RISC-V case. However, the patch series needs to include a patch adding a NEWS item about the port, and the port also needs to be added to the list in the README file of supported glibc configurations using the Linux kernel.
On 20/12/2017 14:21, Joseph Myers wrote: > On Tue, 19 Dec 2017, Palmer Dabbelt wrote: >> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Makefile b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile >> new file mode 100644 >> index 000000000000..cb60d740476d >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile >> @@ -0,0 +1,4 @@ >> +ifeq ($(subdir),socket) >> +CFLAGS-recv.c += -fexceptions >> +CFLAGS-send.c += -fexceptions >> +endif > > I wonder if this should be made generic for all Linux ports (and removed > from the mips64 Makefile as well as here). > We already a CFLAGS-recv.c with "-fexceptions -fasynchronous-unwind-tables" for nptl, and I think we should add it for io as well. Could you send a separately fix along with the mips64 cleanup?
On Wed, 20 Dec 2017 06:05:20 PST (-0800), ldv@altlinux.org wrote: > On Tue, Dec 19, 2017 at 11:20:08PM -0800, Palmer Dabbelt wrote: >> This patch lays out the top-level orginazition of the RISC-V port. It >> contains all the Implies files as well as various other fragments of >> build infastructure for the RISC-V port. This contains the only change >> to a shared file: config.h.in. > [...] >> config.h.in | 5 + >> nptl/Makefile | 4 + > > Well, nptl/Makefile is a shared file, too. > > [...] >> diff --git a/nptl/Makefile b/nptl/Makefile >> index 60d036a1ea42..f62d19febf1d 100644 >> --- a/nptl/Makefile >> +++ b/nptl/Makefile >> @@ -611,6 +611,10 @@ else >> librt = $(common-objpfx)rt/librt.a >> endif >> >> +# `make check' sometimes triggers a rebuild of librt.so using this Makefile, >> +# which ignores librt's dependence on libpthread >> +$(common-objpfx)rt/librt.so: $(shared-thread-library) >> + >> $(objpfx)tst-cancel17: $(librt) >> $(objpfx)tst-cancelx17: $(librt) >> $(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so > > In fact, this looks like a fix unrelated to the RISC-V port. > If this is really the case, please submit the fix separately. > > Thanks, Oh, sorry, that must have snuck in somehow after I wrote the commit message -- I did a lot of rebasing. We noticed this bug when running the test suite, I think Andrew must have fixed it because I was still using a workaround. Thanks for catching this, I'll submit a patch that's pulled out from our port.
Sorry it took a while to get back to you, I've been working through the test suite failures. On Wed, 20 Dec 2017 08:21:55 PST (-0800), joseph@codesourcery.com wrote: > On Tue, 19 Dec 2017, Palmer Dabbelt wrote: > >> diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile >> new file mode 100644 >> index 000000000000..64060531a1d5 >> --- /dev/null >> +++ b/sysdeps/riscv/Makefile >> @@ -0,0 +1,49 @@ >> +ifneq ($(all-rtld-routines),) >> +CFLAGS-rtld.c += -mno-plt > > My previous comments from > <https://sourceware.org/ml/libc-alpha/2017-06/msg00645.html> still apply: > this is too fragile (people won't think when making an > architecture-independent change about whether it needs a RISC-V-specific > change here) and completely lacking the required detailed explanatory > comment of what the issue is and the logic for determining what files need > this option (but really the logic should be implemented to avoid an > architecture-specific list of architecture-independent files being needed > at all). Ah, sorry, I missed that from last time. I thought we were doing this because we couldn't call via the PLT in ld.so because they hadn't been resolved yet, but as far as I can tell there's something else handling this. I just ran into it when looking at the check-localplt stuff (I'm currently going through the test suites). Andrew would know for sure what's going on here -- this has been in our port since ~2011 (when he added PLT support) and has never had an explanation. I feel like it's defunct: when I remove it we end up with only the PLT entries listed in check-localplt, I'd expect a lot more if everything was really emitting PLT calls. I can't figure out what's actually preventing ld.so from using PLT calls on the _dl_fixup codepath. I assume I'm missing something here? > >> diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions >> new file mode 100644 >> index 000000000000..aafa348a2395 >> --- /dev/null >> +++ b/sysdeps/riscv/Versions >> @@ -0,0 +1,4 @@ >> +libc { >> + GLIBC_2.27 { >> + } >> +} > > You shouldn't need this file at all when there aren't any versions to > include in it. IIRC some test was depending on this. I've filled all the machines with builds right now, but I'll give it another look later tonight. I've got two small patches that touch shared build system stuff already. >> diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure > > Does your soft-float lack support for exceptions and rounding modes? If > so, I'd expect a setting of with_fp_cond, and a corresponding nofpu > directory or directories with Implies files pointing to ieee754/soft-fp > (arranged so that always comes before the other ieee754/ directories in > the sysdeps directory ordering). That's needed to get the soft-fp > versions of fmaf/fma/fmal used instead of the default ones relying on > exceptions and rounding modes, so its absence should show up as test > failures for soft-float configurations. In future it will also similarly > be needed to get soft-fp versions of TS 18661-1 narrowing functions used. If I understand what's going on correctly here, we support exceptions in the soft float ABI when built with hardware floating point instructions, but otherwise we don't (we're always round nearest). I believe that means we need to set "with_fp_cond=1" when building with hardware floating point (regardless of ABI), and "with_fp_cond=0" otherwise. Does this look sane? diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure index e118a5ed28f6..6f2bc20ecd5b 100644 --- a/sysdeps/riscv/preconfigure +++ b/sysdeps/riscv/preconfigure @@ -16,12 +16,15 @@ riscv*) case "$flen" in 64) float_machine=rvd + with_fp_cond=1 ;; 32) float_machine=rvf + with_fp_cond=1 ;; "") float_machine= + with_fp_cond=0 ;; *) echo "Unable to determine FLEN" >&2 > Remark: it makes sense for ieee754/dbl-64/wordsize-64 to be used (before > ieee754/dbl-64 in the sysdeps directory ordering) in configurations with > 64-bit registers (but that's just an optimization so you may wish to defer > it). > >> +abi-ilp32-options := -D__SIZEOF_INT__=4 > > abi-* options variables are no longer used with the current bits/syscall.h > generation mechanism, so you should remove all settings of such variables > from the patch. OK, we'll remove them for the v3. > >> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Makefile b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile >> new file mode 100644 >> index 000000000000..cb60d740476d >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile >> @@ -0,0 +1,4 @@ >> +ifeq ($(subdir),socket) >> +CFLAGS-recv.c += -fexceptions >> +CFLAGS-send.c += -fexceptions >> +endif > > I wonder if this should be made generic for all Linux ports (and removed > from the mips64 Makefile as well as here). I think we got it from MIPS, but it doesn't seem like it should be ISA dependent. I'm afraid this is another thing that's been there since before I was around, but I feel like since it's not in anyone else's port it's safe to drop it from ours. Thanks for reviewing our code, and sorry it's a bit of a mess. I'll try and get something a bit more sane out for a v3, but I'm afraid it might take a few more days -- luckily with the weekend and Christmas I should have some time to actually work on this :).
On Wed, 20 Dec 2017 08:43:18 PST (-0800), joseph@codesourcery.com wrote: > Another observation: > > Since you're using ldbl-128, that presumably means _Float128 and _Float64x > type names are supported with the same format as long double. So you need > to add RISC-V to the list in manual/math.texi of ports for which those > type names and associated interfaces are supported. That's our intent. How does this look? diff --git a/manual/math.texi b/manual/math.texi index a9f2a9813832..d19a14b47dc3 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -70,7 +70,7 @@ provided for @code{_Float32}, @code{_Float64} and @code{_Float32x} on all platforms. It is also provided for @code{_Float128} and @code{_Float64x} on powerpc64le (PowerPC 64-bits little-endian), x86_64, x86, ia64, -aarch64, alpha, mips64, s390 and sparc. +aarch64, alpha, mips64, riscv, s390 and sparc. @menu * Mathematical Constants:: Precise numeric values for often-used > I don't think you strictly need to add it to the similar lists for > _Float128 and _Float64x support in the NEWS section for glibc 2.27, since > the whole port is new rather than this being a new feature for an existing > port in the RISC-V case. However, the patch series needs to include a > patch adding a NEWS item about the port, and the port also needs to be > added to the list in the README file of supported glibc configurations > using the Linux kernel. How does this look? commit 462ad608e82fa7a4c340f05dc6c300610282d8d9 Author: Palmer Dabbelt <palmer@dabbelt.com> Date: Fri Dec 22 19:33:57 2017 -0800 NEWS and README diff --git a/NEWS b/NEWS index a43ff26e83cf..a7476265ca9e 100644 --- a/NEWS +++ b/NEWS @@ -40,13 +40,13 @@ Major new features: process aborts as the result of assertion failures. * On platforms where long double has the IEEE binary128 format (aarch64, - alpha, mips64, s390 and sparc), the math library now implements _Float128 - interfaces for that type, as defined by ISO/IEC TS 18661-3:2015. These - are the same interfaces added in version 2.26 for some platforms where + alpha, mips64, riscv, s390 and sparc), the math library now implements + _Float128 interfaces for that type, as defined by ISO/IEC TS 18661-3:2015. + These are the same interfaces added in version 2.26 for some platforms where this format is supported but is not the format of long double. * On platforms with support for _Float64x (aarch64, alpha, i386, ia64, - mips64, powerpc64le, s390, sparc and x86_64), the math library now + mips64, powerpc64le, riscv, s390, sparc and x86_64), the math library now implements interfaces for that type, as defined by ISO/IEC TS 18661-3:2015. These are corresponding interfaces to those supported for _Float128. @@ -67,6 +67,17 @@ Major new features: collation ordering. Previous glibc versions used locale-specific ordering, the change might break systems that relied on that. +* Support for the RISC-V ISA running on Linux has been added. This port + requires at least binutils-2.30, gcc-7.3.0, and linux-4.15; and is supported + for the following ISA and ABI pairs: + + - rv32imac ilp32 + - rv32imafdc ilp32 + - rv32imafdc ilp32d + - rv64imac lp64 + - rv64imafdc lp64 + - rv64imafdc lp64d + Deprecated and removed features, and other changes affecting compatibility: * On GNU/Linux, the obsolete Linux constant PTRACE_SEIZE_DEVEL is no longer diff --git a/README b/README index c3d17d137887..4ab2bfc6f4c4 100644 --- a/README +++ b/README @@ -39,6 +39,8 @@ The GNU C Library supports these configurations for using Linux kernels: powerpc64*-*-linux-gnu Big-endian and little-endian. s390-*-linux-gnu s390x-*-linux-gnu + riscv32-*-linux-gnu + riscv64-*-linux-gnu sh[34]-*-linux-gnu sparc*-*-linux-gnu sparc64*-*-linux-gnu
On Fri, 22 Dec 2017, Palmer Dabbelt wrote: > If I understand what's going on correctly here, we support exceptions in the > soft float ABI when built with hardware floating point instructions, but > otherwise we don't (we're always round nearest). I believe that means we need > to set "with_fp_cond=1" when building with hardware floating point (regardless > of ABI), and "with_fp_cond=0" otherwise. > > Does this look sane? Yes, but it needs to go along with having a nofpu sysdeps directory or directories with an Implies file or files pointing to ieee754/soft-fp (make sure that the soft-float configurations do end up with ieee754/soft-fp before other ieee754 directories in their sysdeps directory ordering). > > > +abi-ilp32-options := -D__SIZEOF_INT__=4 > > > > abi-* options variables are no longer used with the current bits/syscall.h > > generation mechanism, so you should remove all settings of such variables > > from the patch. > > OK, we'll remove them for the v3. To be clear, abi-*-condition variables are still needed (used in generating gnu/lib-names.h, for example); it's just abi-*-options that are obsolete.
On Fri, 22 Dec 2017, Palmer Dabbelt wrote: > On Wed, 20 Dec 2017 08:43:18 PST (-0800), joseph@codesourcery.com wrote: > > Another observation: > > > > Since you're using ldbl-128, that presumably means _Float128 and _Float64x > > type names are supported with the same format as long double. So you need > > to add RISC-V to the list in manual/math.texi of ports for which those > > type names and associated interfaces are supported. > > That's our intent. How does this look? This seems reasonable. > How does this look? Likewise.
On Sat, 23 Dec 2017 04:44:28 PST (-0800), joseph@codesourcery.com wrote: > On Fri, 22 Dec 2017, Palmer Dabbelt wrote: > >> If I understand what's going on correctly here, we support exceptions in the >> soft float ABI when built with hardware floating point instructions, but >> otherwise we don't (we're always round nearest). I believe that means we need >> to set "with_fp_cond=1" when building with hardware floating point (regardless >> of ABI), and "with_fp_cond=0" otherwise. >> >> Does this look sane? > > Yes, but it needs to go along with having a nofpu sysdeps directory or > directories with an Implies file or files pointing to ieee754/soft-fp > (make sure that the soft-float configurations do end up with > ieee754/soft-fp before other ieee754 directories in their sysdeps > directory ordering). OK. I think we might need to reorganize our directories a bit to do that, but I'll try and figure something sane out. >> > > +abi-ilp32-options := -D__SIZEOF_INT__=4 >> > >> > abi-* options variables are no longer used with the current bits/syscall.h >> > generation mechanism, so you should remove all settings of such variables >> > from the patch. >> >> OK, we'll remove them for the v3. > > To be clear, abi-*-condition variables are still needed (used in > generating gnu/lib-names.h, for example); it's just abi-*-options that are > obsolete. Thanks -- I noticed that when going through the commit history to see what other ports had done here.
On Mon, 25 Dec 2017, Palmer Dabbelt wrote: > > Yes, but it needs to go along with having a nofpu sysdeps directory or > > directories with an Implies file or files pointing to ieee754/soft-fp > > (make sure that the soft-float configurations do end up with > > ieee754/soft-fp before other ieee754 directories in their sysdeps > > directory ordering). > > OK. I think we might need to reorganize our directories a bit to do that, but > I'll try and figure something sane out. I don't think you need much reorganization. Possible just adding sysdeps/riscv/nofpu/Implies will suffice. If it doesn't - if the sysdeps directory ordering ends up placing ieee754/soft-fp too late - then maybe you need a few sysdeps/riscv/<something>/nofpu/Implies files instead (as with MIPS, which has three such files).
diff --git a/config.h.in b/config.h.in index d928e7dd867c..b0b7cf26cb4b 100644 --- a/config.h.in +++ b/config.h.in @@ -100,6 +100,11 @@ /* AArch64 big endian ABI */ #undef HAVE_AARCH64_BE +/* RISC-V integer ABI for ld.so. */ +#undef RISCV_ABI_XLEN + +/* RISC-V floating-point ABI for ld.so. */ +#undef RISCV_ABI_FLEN /* Linux specific: minimum supported kernel version. */ #undef __LINUX_KERNEL_VERSION diff --git a/nptl/Makefile b/nptl/Makefile index 60d036a1ea42..f62d19febf1d 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -611,6 +611,10 @@ else librt = $(common-objpfx)rt/librt.a endif +# `make check' sometimes triggers a rebuild of librt.so using this Makefile, +# which ignores librt's dependence on libpthread +$(common-objpfx)rt/librt.so: $(shared-thread-library) + $(objpfx)tst-cancel17: $(librt) $(objpfx)tst-cancelx17: $(librt) $(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so diff --git a/sysdeps/riscv/Implies b/sysdeps/riscv/Implies new file mode 100644 index 000000000000..c88325b8be16 --- /dev/null +++ b/sysdeps/riscv/Implies @@ -0,0 +1,5 @@ +init_array + +ieee754/ldbl-128 +ieee754/dbl-64 +ieee754/flt-32 diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile new file mode 100644 index 000000000000..64060531a1d5 --- /dev/null +++ b/sysdeps/riscv/Makefile @@ -0,0 +1,49 @@ +ifneq ($(all-rtld-routines),) +CFLAGS-rtld.c += -mno-plt +CFLAGS-dl-load.c += -mno-plt +CFLAGS-dl-cache.c += -mno-plt +CFLAGS-dl-lookup.c += -mno-plt +CFLAGS-dl-object.c += -mno-plt +CFLAGS-dl-reloc.c += -mno-plt +CFLAGS-dl-deps.c += -mno-plt +CFLAGS-dl-runtime.c += -mno-plt +CFLAGS-dl-error.c += -mno-plt +CFLAGS-dl-init.c += -mno-plt +CFLAGS-dl-fini.c += -mno-plt +CFLAGS-dl-debug.c += -mno-plt +CFLAGS-dl-misc.c += -mno-plt +CFLAGS-dl-version.c += -mno-plt +CFLAGS-dl-profile.c += -mno-plt +CFLAGS-dl-conflict.c += -mno-plt +CFLAGS-dl-tls.c += -mno-plt +CFLAGS-dl-origin.c += -mno-plt +CFLAGS-dl-scope.c += -mno-plt +CFLAGS-dl-execstack.c += -mno-plt +CFLAGS-dl-caller.c += -mno-plt +CFLAGS-dl-open.c += -mno-plt +CFLAGS-dl-close.c += -mno-plt +CFLAGS-dl-sysdep.c += -mno-plt +CFLAGS-dl-environ.c += -mno-plt +CFLAGS-dl-minimal.c += -mno-plt +CFLAGS-dl-static.c += -mno-plt +CFLAGS-dl-brk.c += -mno-plt +CFLAGS-dl-sbrk.c += -mno-plt +CFLAGS-dl-getcwd.c += -mno-plt +CFLAGS-dl-openat64.c += -mno-plt +CFLAGS-dl-opendir.c += -mno-plt +CFLAGS-dl-fxstatat64.c += -mno-plt +endif + +CFLAGS-closedir.c += -mno-plt +CFLAGS-exit.c += -mno-plt +CFLAGS-cxa_atexit.c += -mno-plt + +ifeq ($(subdir),misc) +sysdep_headers += sys/asm.h +endif + +ASFLAGS-.os += $(pic-ccflag) + +ifeq ($(subdir),math) +CPPFLAGS += -I../soft-fp +endif diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions new file mode 100644 index 000000000000..aafa348a2395 --- /dev/null +++ b/sysdeps/riscv/Versions @@ -0,0 +1,4 @@ +libc { + GLIBC_2.27 { + } +} diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure new file mode 100644 index 000000000000..8dc92a2e7920 --- /dev/null +++ b/sysdeps/riscv/configure @@ -0,0 +1,5 @@ +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/riscv/elf. + +$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h + diff --git a/sysdeps/riscv/configure.ac b/sysdeps/riscv/configure.ac new file mode 100644 index 000000000000..34f62d4b4b82 --- /dev/null +++ b/sysdeps/riscv/configure.ac @@ -0,0 +1,4 @@ +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local configure fragment for sysdeps/riscv/elf. + +AC_DEFINE(PI_STATIC_AND_HIDDEN) diff --git a/sysdeps/riscv/nptl/Makefile b/sysdeps/riscv/nptl/Makefile new file mode 100644 index 000000000000..5a4be9b00e93 --- /dev/null +++ b/sysdeps/riscv/nptl/Makefile @@ -0,0 +1,26 @@ +# Makefile for sysdeps/riscv/nptl. +# Copyright (C) 2005-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +ifeq ($(subdir),csu) +gen-as-const-headers += tcb-offsets.sym +endif + +ifeq ($(subdir),nptl) +libpthread-sysdep_routines += nptl-sysdep +libpthread-shared-only-routines += nptl-sysdep +endif diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure new file mode 100644 index 000000000000..e118a5ed28f6 --- /dev/null +++ b/sysdeps/riscv/preconfigure @@ -0,0 +1,54 @@ +case "$machine" in +riscv*) + xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'` + flen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_flen \(.*\)/\1/p'` + float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_float_abi_\([^ ]*\) .*/\1/p'` + + case "$xlen" in + 32 | 64) + ;; + *) + echo "Unable to determine XLEN" >&2 + exit 1 + ;; + esac + + case "$flen" in + 64) + float_machine=rvd + ;; + 32) + float_machine=rvf + ;; + "") + float_machine= + ;; + *) + echo "Unable to determine FLEN" >&2 + exit 1 + ;; + esac + + case "$float_abi" in + soft) + abi_flen=0 + ;; + single) + abi_flen=32 + ;; + double) + abi_flen=64 + ;; + *) + echo "Unable to determine floating-point ABI" >&2 + exit 1 + ;; + esac + + base_machine=riscv + machine=riscv/rv$xlen/$float_machine + + $as_echo "#define RISCV_ABI_XLEN $xlen" >>confdefs.h + $as_echo "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h + ;; +esac diff --git a/sysdeps/riscv/rv32/Implies-after b/sysdeps/riscv/rv32/Implies-after new file mode 100644 index 000000000000..39a34c5f5743 --- /dev/null +++ b/sysdeps/riscv/rv32/Implies-after @@ -0,0 +1 @@ +wordsize-32 diff --git a/sysdeps/riscv/rv32/rvd/Implies b/sysdeps/riscv/rv32/rvd/Implies new file mode 100644 index 000000000000..9438838e98b9 --- /dev/null +++ b/sysdeps/riscv/rv32/rvd/Implies @@ -0,0 +1,2 @@ +riscv/rvd +riscv/rvf diff --git a/sysdeps/riscv/rv32/rvf/Implies b/sysdeps/riscv/rv32/rvf/Implies new file mode 100644 index 000000000000..66c401443b8c --- /dev/null +++ b/sysdeps/riscv/rv32/rvf/Implies @@ -0,0 +1 @@ +riscv/rvf diff --git a/sysdeps/riscv/rv64/Implies-after b/sysdeps/riscv/rv64/Implies-after new file mode 100644 index 000000000000..a8cae95f9d46 --- /dev/null +++ b/sysdeps/riscv/rv64/Implies-after @@ -0,0 +1 @@ +wordsize-64 diff --git a/sysdeps/riscv/rv64/rvd/Implies b/sysdeps/riscv/rv64/rvd/Implies new file mode 100644 index 000000000000..42fb132d12ae --- /dev/null +++ b/sysdeps/riscv/rv64/rvd/Implies @@ -0,0 +1,3 @@ +riscv/rv64/rvf +riscv/rvd +riscv/rvf diff --git a/sysdeps/riscv/rv64/rvf/Implies b/sysdeps/riscv/rv64/rvf/Implies new file mode 100644 index 000000000000..66c401443b8c --- /dev/null +++ b/sysdeps/riscv/rv64/rvf/Implies @@ -0,0 +1 @@ +riscv/rvf diff --git a/sysdeps/unix/sysv/linux/riscv/Implies b/sysdeps/unix/sysv/linux/riscv/Implies new file mode 100644 index 000000000000..6faec7011569 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/Implies @@ -0,0 +1 @@ +riscv/nptl diff --git a/sysdeps/unix/sysv/linux/riscv/Makefile b/sysdeps/unix/sysv/linux/riscv/Makefile new file mode 100644 index 000000000000..0214869e46ab --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/Makefile @@ -0,0 +1,100 @@ +ifeq ($(subdir),elf) +sysdep_routines += dl-vdso +ifeq ($(build-shared),yes) +# This is needed for DSO loading from static binaries. +sysdep-dl-routines += dl-static +endif +endif + +ifeq ($(subdir),misc) +sysdep_headers += sys/cachectl.h +sysdep_routines += flush-icache +endif + +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext_i.sym +endif + +abi-variants := ilp32 ilp32f ilp32d lp64 lp64f lp64d + +ifeq (,$(filter $(default-abi),$(abi-variants))) +$(error Unknown ABI $(default-abi), must be one of $(abi-variants)) +endif + +abi-ilp32-options := -D__SIZEOF_INT__=4 +abi-ilp32-condition := (__SIZEOF_INT__ == 4) +abi-ilp32-options += -D__SIZEOF_LONG__=4 +abi-ilp32-condition += && (__SIZEOF_LONG__ == 4) +abi-ilp32-options += -D__SIZEOF_POINTER__=4 +abi-ilp32-condition += && (__SIZEOF_POINTER__ == 4) +abi-ilp32-options += -D__riscv_float_abi_soft +abi-ilp32-condition += && (defined __riscv_float_abi_soft) +abi-ilp32-options += -U__riscv_float_abi_single +abi-ilp32-condition += && (!defined __riscv_float_abi_single) +abi-ilp32-options += -U__riscv_float_abi_double +abi-ilp32-condition += && (!defined __riscv_float_abi_double) + +abi-ilp32f-options := -D__SIZEOF_INT__=4 +abi-ilp32f-condition := (__SIZEOF_INT__ == 4) +abi-ilp32f-options += -D__SIZEOF_LONG__=4 +abi-ilp32f-condition += && (__SIZEOF_LONG__ == 4) +abi-ilp32f-options += -D__SIZEOF_POINTER__=4 +abi-ilp32f-condition += && (__SIZEOF_POINTER__ == 4) +abi-ilp32f-options += -U__riscv_float_abi_soft +abi-ilp32f-condition += && (!defined __riscv_float_abi_soft) +abi-ilp32f-options += -D__riscv_float_abi_single +abi-ilp32f-condition += && (defined __riscv_float_abi_single) +abi-ilp32f-options += -U__riscv_float_abi_double +abi-ilp32f-condition += && (!defined __riscv_float_abi_double) + +abi-ilp32d-options := -D__SIZEOF_INT__=4 +abi-ilp32d-condition := (__SIZEOF_INT__ == 4) +abi-ilp32d-options += -D__SIZEOF_LONG__=4 +abi-ilp32d-condition += && (__SIZEOF_LONG__ == 4) +abi-ilp32d-options += -D__SIZEOF_POINTER__=4 +abi-ilp32d-condition += && (__SIZEOF_POINTER__ == 4) +abi-ilp32d-options += -U__riscv_float_abi_soft +abi-ilp32d-condition += && (!defined __riscv_float_abi_soft) +abi-ilp32d-options += -U__riscv_float_abi_single +abi-ilp32d-condition += && (!defined __riscv_float_abi_single) +abi-ilp32d-options += -D__riscv_float_abi_double +abi-ilp32d-condition += && (defined __riscv_float_abi_double) + +abi-lp64-options := -D__SIZEOF_INT__=4 +abi-lp64-condition := (__SIZEOF_INT__ == 4) +abi-lp64-options += -D__SIZEOF_LONG__=8 +abi-lp64-condition += && (__SIZEOF_LONG__ == 8) +abi-lp64-options += -D__SIZEOF_POINTER__=8 +abi-lp64-condition += && (__SIZEOF_POINTER__ == 8) +abi-lp64-options += -D__riscv_float_abi_soft +abi-lp64-condition += && (defined __riscv_float_abi_soft) +abi-lp64-options += -U__riscv_float_abi_single +abi-lp64-condition += && (!defined __riscv_float_abi_single) +abi-lp64-options += -U__riscv_float_abi_double +abi-lp64-condition += && (!defined __riscv_float_abi_double) + +abi-lp64f-options := -D__SIZEOF_INT__=4 +abi-lp64f-condition := (__SIZEOF_INT__ == 4) +abi-lp64f-options += -D__SIZEOF_LONG__=8 +abi-lp64f-condition += && (__SIZEOF_LONG__ == 8) +abi-lp64f-options += -D__SIZEOF_POINTER__=8 +abi-lp64f-condition += && (__SIZEOF_POINTER__ == 8) +abi-lp64f-options += -U__riscv_float_abi_soft +abi-lp64f-condition += && (!defined __riscv_float_abi_soft) +abi-lp64f-options += -D__riscv_float_abi_single +abi-lp64f-condition += && (defined __riscv_float_abi_single) +abi-lp64f-options += -U__riscv_float_abi_double +abi-lp64f-condition += && (!defined __riscv_float_abi_double) + +abi-lp64d-options := -D__SIZEOF_INT__=4 +abi-lp64d-condition := (__SIZEOF_INT__ == 4) +abi-lp64d-options += -D__SIZEOF_LONG__=8 +abi-lp64d-condition += && (__SIZEOF_LONG__ == 8) +abi-lp64d-options += -D__SIZEOF_POINTER__=8 +abi-lp64d-condition += && (__SIZEOF_POINTER__ == 8) +abi-lp64d-options += -U__riscv_float_abi_soft +abi-lp64d-condition += && (!defined __riscv_float_abi_soft) +abi-lp64d-options += -U__riscv_float_abi_single +abi-lp64d-condition += && (!defined __riscv_float_abi_single) +abi-lp64d-options += -D__riscv_float_abi_double +abi-lp64d-condition += && (defined __riscv_float_abi_double) diff --git a/sysdeps/unix/sysv/linux/riscv/Versions b/sysdeps/unix/sysv/linux/riscv/Versions new file mode 100644 index 000000000000..f61c7e31a0ae --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/Versions @@ -0,0 +1,5 @@ +libc { + GLIBC_2.27 { + __riscv_flush_icache; + } +} diff --git a/sysdeps/unix/sysv/linux/riscv/configure b/sysdeps/unix/sysv/linux/riscv/configure new file mode 100755 index 000000000000..4dd085a7b0b6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/configure @@ -0,0 +1,210 @@ +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/unix/sysv/linux/riscv. + +arch_minimum_kernel=4.15.0 + +libc_cv_riscv_int_abi=no + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__ + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "4 8 8" >/dev/null 2>&1; then : + libc_cv_riscv_int_abi=lp64 +fi +rm -f conftest* + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__ + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "4 4 4" >/dev/null 2>&1; then : + libc_cv_riscv_int_abi=ilp32 +fi +rm -f conftest* + +if test $libc_cv_riscv_int_abi = no; then + as_fn_error $? "Unable to determine integer ABI" "$LINENO" 5 +fi + +libc_cv_riscv_float_abi=no +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __riscv_float_abi_double + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + libc_cv_riscv_float_abi=d +fi +rm -f conftest* + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __riscv_float_abi_single + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + libc_cv_riscv_float_abi=f +fi +rm -f conftest* + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __riscv_float_abi_soft + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + libc_cv_riscv_float_abi= +fi +rm -f conftest* + +if test $libc_cv_riscv_float_abi = no; then + as_fn_error $? "Unable to determine floating-point ABI" "$LINENO" 5 +fi + +config_vars="$config_vars +default-abi = $libc_cv_riscv_int_abi$libc_cv_riscv_float_abi" diff --git a/sysdeps/unix/sysv/linux/riscv/configure.ac b/sysdeps/unix/sysv/linux/riscv/configure.ac new file mode 100644 index 000000000000..b9a6207d48d6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/configure.ac @@ -0,0 +1,33 @@ +sinclude(./aclocal.m4)dnl Autoconf lossage +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local configure fragment for sysdeps/unix/sysv/linux/riscv. + +arch_minimum_kernel=4.15.0 + +libc_cv_riscv_int_abi=no +AC_EGREP_CPP(4 8 8, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__ + ], libc_cv_riscv_int_abi=lp64) +AC_EGREP_CPP(4 4 4, [__SIZEOF_INT__ __SIZEOF_LONG__ __SIZEOF_POINTER__ + ], libc_cv_riscv_int_abi=ilp32) +if test $libc_cv_riscv_int_abi = no; then + AC_MSG_ERROR([Unable to determine integer ABI]) +fi + +libc_cv_riscv_float_abi=no +AC_EGREP_CPP(yes, [#ifdef __riscv_float_abi_double + yes + #endif + ],libc_cv_riscv_float_abi=d) +AC_EGREP_CPP(yes, [#ifdef __riscv_float_abi_single + yes + #endif + ],libc_cv_riscv_float_abi=f) +AC_EGREP_CPP(yes, [#ifdef __riscv_float_abi_soft + yes + #endif + ],libc_cv_riscv_float_abi=) +if test $libc_cv_riscv_float_abi = no; then + AC_MSG_ERROR([Unable to determine floating-point ABI]) +fi + +LIBC_CONFIG_VAR([default-abi], [$libc_cv_riscv_int_abi$libc_cv_riscv_float_abi]) diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/Implies b/sysdeps/unix/sysv/linux/riscv/rv32/Implies new file mode 100644 index 000000000000..8b7deb33cd51 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/rv32/Implies @@ -0,0 +1,3 @@ +unix/sysv/linux/riscv +unix/sysv/linux/generic/wordsize-32 +unix/sysv/linux/generic diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Implies b/sysdeps/unix/sysv/linux/riscv/rv64/Implies new file mode 100644 index 000000000000..f042343bf7b4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Implies @@ -0,0 +1,3 @@ +unix/sysv/linux/riscv +unix/sysv/linux/generic +unix/sysv/linux/wordsize-64 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Makefile b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile new file mode 100644 index 000000000000..cb60d740476d --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile @@ -0,0 +1,4 @@ +ifeq ($(subdir),socket) +CFLAGS-recv.c += -fexceptions +CFLAGS-send.c += -fexceptions +endif diff --git a/sysdeps/unix/sysv/linux/riscv/shlib-versions b/sysdeps/unix/sysv/linux/riscv/shlib-versions new file mode 100644 index 000000000000..fe7322d23a94 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/shlib-versions @@ -0,0 +1,17 @@ +DEFAULT GLIBC_2.27 + +%if RISCV_ABI_XLEN == 64 && RISCV_ABI_FLEN == 64 +ld=ld-linux-riscv64-lp64d.so.1 +%elif RISCV_ABI_XLEN == 64 && RISCV_ABI_FLEN == 32 +ld=ld-linux-riscv64-lp64f.so.1 +%elif RISCV_ABI_XLEN == 64 && RISCV_ABI_FLEN == 0 +ld=ld-linux-riscv64-lp64.so.1 +%elif RISCV_ABI_XLEN == 32 && RISCV_ABI_FLEN == 64 +ld=ld-linux-riscv32-ilp32d.so.1 +%elif RISCV_ABI_XLEN == 32 && RISCV_ABI_FLEN == 32 +ld=ld-linux-riscv32-ilp32f.so.1 +%elif RISCV_ABI_XLEN == 32 && RISCV_ABI_FLEN == 0 +ld=ld-linux-riscv32-ilp32.so.1 +%else +%error cannot determine ABI +%endif