Message ID | 20170614183048.11040-2-palmer@dabbelt.com |
---|---|
State | New |
Headers | show |
On 14/06/2017 15:30, 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. > > RISC-V is a family of base ISAs with optional extensions. The base ISAs > are RV32I and RV64I, which are 32-bit and 64-bit integer-only ISAs. > Support for these live in sysdeps/riscv/rv{32,64}. In addition to these > ISAs, our glibc port supports most of the currently-defined extensions: > the A extension for atomics, the M extension for multiplication, the C > extension for compressed instructions, and the F/D extensions for > single/double precision IEEE floating-point. Most of these extensions > are handled by GCC, but glibc defines various floating-point wrappers > (in sysdeps/riscv/rv{32,64}/rv{f,d}) and emulation routines (in > sysdeps/riscv/soft-fp). > > We support running glibc-based programs on Linux, the suppor for which > lives in sysdeps/unix/sysv/linux/riscv. > --- > config.h.in | 5 ++ > sysdeps/riscv/Implies | 6 ++ > sysdeps/riscv/Makefile | 45 +++++++++++++++ > sysdeps/riscv/Versions | 5 ++ > sysdeps/riscv/configure | 86 ++++++++++++++++++++++++++++ > sysdeps/riscv/configure.in | 4 ++ > sysdeps/riscv/nptl/Makefile | 25 ++++++++ > sysdeps/riscv/preconfigure | 50 ++++++++++++++++ > sysdeps/riscv/rv32/Implies-after | 1 + > sysdeps/riscv/rv32/rvd/Implies | 2 + > sysdeps/riscv/rv32/rvf/Implies | 1 + > sysdeps/riscv/rv64/Implies-after | 1 + > sysdeps/riscv/rv64/rvd/Implies | 2 + > sysdeps/riscv/rv64/rvf/Implies | 1 + > sysdeps/riscv/soft-fp/Makefile | 3 + > sysdeps/unix/sysv/linux/riscv/Implies | 1 + > sysdeps/unix/sysv/linux/riscv/Makefile | 26 +++++++++ > sysdeps/unix/sysv/linux/riscv/configure | 7 +++ > sysdeps/unix/sysv/linux/riscv/configure.in | 8 +++ > sysdeps/unix/sysv/linux/riscv/rv32/Implies | 3 + > sysdeps/unix/sysv/linux/riscv/rv64/Implies | 3 + > sysdeps/unix/sysv/linux/riscv/rv64/Makefile | 9 +++ > sysdeps/unix/sysv/linux/riscv/shlib-versions | 17 ++++++ > 23 files changed, 311 insertions(+) > create mode 100644 sysdeps/riscv/Implies > create mode 100644 sysdeps/riscv/Makefile > create mode 100644 sysdeps/riscv/Versions > create mode 100644 sysdeps/riscv/configure > create mode 100644 sysdeps/riscv/configure.in > create mode 100644 sysdeps/riscv/nptl/Makefile > create mode 100644 sysdeps/riscv/preconfigure > create mode 100644 sysdeps/riscv/rv32/Implies-after > create mode 100644 sysdeps/riscv/rv32/rvd/Implies > create mode 100644 sysdeps/riscv/rv32/rvf/Implies > create mode 100644 sysdeps/riscv/rv64/Implies-after > create mode 100644 sysdeps/riscv/rv64/rvd/Implies > create mode 100644 sysdeps/riscv/rv64/rvf/Implies > create mode 100644 sysdeps/riscv/soft-fp/Makefile > create mode 100644 sysdeps/unix/sysv/linux/riscv/Implies > create mode 100644 sysdeps/unix/sysv/linux/riscv/Makefile > create mode 100644 sysdeps/unix/sysv/linux/riscv/configure > create mode 100644 sysdeps/unix/sysv/linux/riscv/configure.in > create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/Implies > create mode 100644 sysdeps/unix/sysv/linux/riscv/rv64/Implies > create mode 100644 sysdeps/unix/sysv/linux/riscv/rv64/Makefile > create mode 100644 sysdeps/unix/sysv/linux/riscv/shlib-versions > > diff --git a/config.h.in b/config.h.in > index 22418576a0..f870267870 100644 > --- a/config.h.in > +++ b/config.h.in > @@ -99,6 +99,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 > > /* Defined to some form of __attribute__ ((...)) if the compiler supports > a different, more efficient calling convention. */ > diff --git a/sysdeps/riscv/Implies b/sysdeps/riscv/Implies > new file mode 100644 > index 0000000000..15b9e02448 > --- /dev/null > +++ b/sysdeps/riscv/Implies > @@ -0,0 +1,6 @@ > +init_array > + > +ieee754/ldbl-128 > +ieee754/dbl-64 > +ieee754/flt-32 > +riscv/soft-fp > diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile > new file mode 100644 > index 0000000000..5a699a2e64 > --- /dev/null > +++ b/sysdeps/riscv/Makefile > @@ -0,0 +1,45 @@ > +ifneq ($(all-rtld-routines),) > +CFLAGS-rtld.c += -mno-plt Why exactly do you need no plt in loader code? > +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) > diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions > new file mode 100644 > index 0000000000..5a0c2d23f8 > --- /dev/null > +++ b/sysdeps/riscv/Versions > @@ -0,0 +1,5 @@ > +libc { > + GLIBC_2.14 { > + __memcpy_g; > + } > +} This seems wrong, risc-v won't have any GLIBC_2.14 symbols since its ABI will start from current one (2.26). > diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure > new file mode 100644 > index 0000000000..9f790ec527 > --- /dev/null > +++ b/sysdeps/riscv/configure You do not need to post auto-generated files. > @@ -0,0 +1,86 @@ > + > +# as_fn_set_status STATUS > +# ----------------------- > +# Set $? to STATUS, without forking. > +as_fn_set_status () > +{ > + return $1 > +} # as_fn_set_status > + > +# as_fn_exit STATUS > +# ----------------- > +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. > +as_fn_exit () > +{ > + set +e > + as_fn_set_status $1 > + exit $1 > +} # as_fn_exit > +if expr a : '\(a\)' >/dev/null 2>&1 && > + test "X`expr 00001 : '.*\(...\)'`" = X001; then > + as_expr=expr > +else > + as_expr=false > +fi > + > +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then > + as_basename=basename > +else > + as_basename=false > +fi > + > +as_me=`$as_basename -- "$0" || > +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ > + X"$0" : 'X\(//\)$' \| \ > + X"$0" : 'X\(/\)' \| . 2>/dev/null || > +$as_echo X/"$0" | > + sed '/^.*\/\([^/][^/]*\)\/*$/{ > + s//\1/ > + q > + } > + /^X\/\(\/\/\)$/{ > + s//\1/ > + q > + } > + /^X\/\(\/\).*/{ > + s//\1/ > + q > + } > + s/.*/./; q'` > + > + > + as_lineno_1=$LINENO as_lineno_1a=$LINENO > + as_lineno_2=$LINENO as_lineno_2a=$LINENO > + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && > + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { > + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) > + sed -n ' > + p > + /[$]LINENO/= > + ' <$as_myself | > + sed ' > + s/[$]LINENO.*/&-/ > + t lineno > + b > + :lineno > + N > + :loop > + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ > + t loop > + s/-\n.*// > + ' >$as_me.lineno && > + chmod +x "$as_me.lineno" || > + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } > + > + # Don't try to exec as it changes $[0], causing all sort of problems > + # (the dirname of $[0] is not the place where we might find the > + # original and so on. Autoconf is especially sensitive to this). > + . "./$as_me.lineno" > + # Exit status is that of the last command. > + exit > +} > + > +# This file is generated from configure.in 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.in b/sysdeps/riscv/configure.in > new file mode 100644 > index 0000000000..34f62d4b4b > --- /dev/null > +++ b/sysdeps/riscv/configure.in We do not use .in file anymore, please change to .ac ones. > @@ -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 0000000000..d0c59a5091 > --- /dev/null > +++ b/sysdeps/riscv/nptl/Makefile > @@ -0,0 +1,25 @@ > +# Copyright (C) 2005 Free Software Foundation, Inc. Missing descriptive line for new files and copyright dates seems wrong. > +# 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, write to the Free > +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > +# 02111-1307 USA. > + > +ifeq ($(subdir),csu) > +gen-as-const-headers += tcb-offsets.sym > +endif You are adding a tcb-offsets.sym rule but there is no tcb-offsets.sym file in this patch. > + > +ifeq ($(subdir),nptl) > +libpthread-sysdep_routines += nptl-sysdep > +endif Same as before. > diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure > new file mode 100644 > index 0000000000..43e2a4fac0 > --- /dev/null > +++ b/sysdeps/riscv/preconfigure > @@ -0,0 +1,50 @@ > +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 > diff --git a/sysdeps/riscv/rv32/Implies-after b/sysdeps/riscv/rv32/Implies-after > new file mode 100644 > index 0000000000..39a34c5f57 > --- /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 0000000000..9438838e98 > --- /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 0000000000..66c401443b > --- /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 0000000000..a8cae95f9d > --- /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 0000000000..9438838e98 > --- /dev/null > +++ b/sysdeps/riscv/rv64/rvd/Implies > @@ -0,0 +1,2 @@ > +riscv/rvd > +riscv/rvf > diff --git a/sysdeps/riscv/rv64/rvf/Implies b/sysdeps/riscv/rv64/rvf/Implies > new file mode 100644 > index 0000000000..66c401443b > --- /dev/null > +++ b/sysdeps/riscv/rv64/rvf/Implies > @@ -0,0 +1 @@ > +riscv/rvf > diff --git a/sysdeps/riscv/soft-fp/Makefile b/sysdeps/riscv/soft-fp/Makefile > new file mode 100644 > index 0000000000..ada13e8b70 > --- /dev/null > +++ b/sysdeps/riscv/soft-fp/Makefile > @@ -0,0 +1,3 @@ > +ifeq ($(subdir),math) > +CPPFLAGS += -I../soft-fp > +endif I would suggest you to avoid relative paths for inclusion. > diff --git a/sysdeps/unix/sysv/linux/riscv/Implies b/sysdeps/unix/sysv/linux/riscv/Implies > new file mode 100644 > index 0000000000..6faec70115 > --- /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 0000000000..a71840f70c > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/Makefile > @@ -0,0 +1,26 @@ > +ifeq ($(subdir),elf) > +ifeq ($(build-shared),yes) > +# This is needed for DSO loading from static binaries. > +sysdep-dl-routines += dl-static > +sysdep_routines += dl-static > +sysdep-rtld-routines += dl-static > +endif > +endif > + > +ifeq ($(subdir),stdlib) > +gen-as-const-headers += ucontext_i.sym > +endif Again this seems to missing a actual file target. > + > +ifeq ($(subdir),crypt) > +libcrypt-sysdep_routines += sysdep > +endif > + > +ifeq ($(subdir),nss) > +libnss_db-sysdep_routines += sysdep > +libnss_db-shared-only-routines += sysdep > +endif > + > +ifeq ($(subdir),rt) > +librt-sysdep_routines += sysdep > +librt-shared-only-routines += sysdep > +endif > diff --git a/sysdeps/unix/sysv/linux/riscv/configure b/sysdeps/unix/sysv/linux/riscv/configure > new file mode 100644 > index 0000000000..2bb3062cc3 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/configure > @@ -0,0 +1,7 @@ > +# This file is generated from configure.in by Autoconf. DO NOT EDIT! > + # Local configure fragment for sysdeps/unix/sysv/linux/riscv. > + > +if test -z "$arch_minimum_kernel"; then > + arch_minimum_kernel=3.0.0 > + libc_cv_gcc_unwind_find_fde=no > +fi > diff --git a/sysdeps/unix/sysv/linux/riscv/configure.in b/sysdeps/unix/sysv/linux/riscv/configure.in > new file mode 100644 > index 0000000000..5b48e1aed6 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/configure.in As before, change to configure.ac. > @@ -0,0 +1,8 @@ > +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. > + > +if test -z "$arch_minimum_kernel"; then > + arch_minimum_kernel=3.0.0 > + libc_cv_gcc_unwind_find_fde=no > +fi I think the minimum kernel is wrong here, as from cover letter I think it should be 4.14. > diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/Implies b/sysdeps/unix/sysv/linux/riscv/rv32/Implies > new file mode 100644 > index 0000000000..8b7deb33cd > --- /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 0000000000..f042343bf7 > --- /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 0000000000..0a37c5b9b4 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile > @@ -0,0 +1,9 @@ > +ifeq ($(subdir),socket) > +CFLAGS-recv.c += -fexceptions > +CFLAGS-send.c += -fexceptions > +endif > + > +ifeq ($(subdir),nptl) > +CFLAGS-recv.c += -fexceptions > +CFLAGS-send.c += -fexceptions > +endif Do you actually need to add this rules here? They are already covered after recv/send Linux syscall consolidation. > diff --git a/sysdeps/unix/sysv/linux/riscv/shlib-versions b/sysdeps/unix/sysv/linux/riscv/shlib-versions > new file mode 100644 > index 0000000000..66214b953e > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/shlib-versions > @@ -0,0 +1,17 @@ > +DEFAULT GLIBC_2.25 You will need to update the default version to 2.26. > + > +%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 >
On Wed, 14 Jun 2017, Palmer Dabbelt wrote: > diff --git a/sysdeps/riscv/Implies b/sysdeps/riscv/Implies > new file mode 100644 > index 0000000000..15b9e02448 > --- /dev/null > +++ b/sysdeps/riscv/Implies > @@ -0,0 +1,6 @@ > +init_array > + > +ieee754/ldbl-128 > +ieee754/dbl-64 > +ieee754/flt-32 > +riscv/soft-fp You should never need to have <arch>/Implies referencing <arch>/<subdir>; in such a case, remove the unnecessary soft-fp directory level and put sfp-machine.h directly in <arch>. See <https://sourceware.org/ml/libc-alpha/2014-10/msg00369.html>. > diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile > new file mode 100644 > index 0000000000..5a699a2e64 > --- /dev/null > +++ b/sysdeps/riscv/Makefile > @@ -0,0 +1,45 @@ > +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 I think this at least needs some explanatory comment. It feels very fragile to require lots of architecture-independent files to be built with an architecture-specific option - it's the sort of thing where people making architecture-independent changes could easily break the build accidentally without realising that their change requires the option to be added for a new file. So if you can find a way to avoid needing such an architecture-specific list of files, that would be a good idea. > diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions > new file mode 100644 > index 0000000000..5a0c2d23f8 > --- /dev/null > +++ b/sysdeps/riscv/Versions > @@ -0,0 +1,5 @@ > +libc { > + GLIBC_2.14 { > + __memcpy_g; > + } > +} No, the minimum version should be 2.26, and you shouldn't need any such special string variants (given that we've killed bits/string2.h, are about to kill bits/string.h, and such exports as there are from old string function inlines are or should soon be compat symbols). > diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure > new file mode 100644 > index 0000000000..9f790ec527 > --- /dev/null > +++ b/sysdeps/riscv/configure > @@ -0,0 +1,86 @@ > + > +# as_fn_set_status STATUS > +# ----------------------- > +# Set $? to STATUS, without forking. > +as_fn_set_status () > +{ > + return $1 > +} # as_fn_set_status Please make sure this file is regenerated. Any sysdeps configure script generated with current aclocal.m4 should not contain such functions, assuming the GLIBC_PROVIDES in aclocal.m4 is correct. > diff --git a/sysdeps/riscv/configure.in b/sysdeps/riscv/configure.in > new file mode 100644 > index 0000000000..34f62d4b4b > --- /dev/null > +++ b/sysdeps/riscv/configure.in We use configure.ac naming now, not configure.in. Since you have multiple ABI variants, you should be setting default-abi here via LIBC_CONFIG_VAR. Then sysdeps/unix/sysv/linux/riscv/Makefile should set abi-variants and appropriate options for each ABI variant (see other such Makefiles for examples) - this is used in building bits/syscall.h. > diff --git a/sysdeps/unix/sysv/linux/riscv/configure.in b/sysdeps/unix/sysv/linux/riscv/configure.in > new file mode 100644 > index 0000000000..5b48e1aed6 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/configure.in > @@ -0,0 +1,8 @@ > +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. > + > +if test -z "$arch_minimum_kernel"; then > + arch_minimum_kernel=3.0.0 > + libc_cv_gcc_unwind_find_fde=no > +fi Should use .ac naming. No need for the 'if test -z "$arch_minimum_kernel"; then'. No need to set libc_cv_gcc_unwind_find_fde=no. Should set arch_minimum_kernel=10.0.0 until the kernel port is actually in Linus's tree (of course you then need to change that locally for testing purposes). > diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Makefile b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile > new file mode 100644 > index 0000000000..0a37c5b9b4 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile > @@ -0,0 +1,9 @@ > +ifeq ($(subdir),socket) > +CFLAGS-recv.c += -fexceptions > +CFLAGS-send.c += -fexceptions > +endif > + > +ifeq ($(subdir),nptl) > +CFLAGS-recv.c += -fexceptions > +CFLAGS-send.c += -fexceptions > +endif In the nptl directory this is the default and should not be needed. > diff --git a/sysdeps/unix/sysv/linux/riscv/shlib-versions b/sysdeps/unix/sysv/linux/riscv/shlib-versions > new file mode 100644 > index 0000000000..66214b953e > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/riscv/shlib-versions > @@ -0,0 +1,17 @@ > +DEFAULT GLIBC_2.25 Should be GLIBC_2.26.
On Wed, 14 Jun 2017, Adhemerval Zanella wrote: > > diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure > > new file mode 100644 > > index 0000000000..9f790ec527 > > --- /dev/null > > +++ b/sysdeps/riscv/configure > > You do not need to post auto-generated files. But do make sure they are freshly regenerated, as this one appears out of date.
On Wed, 14 Jun 2017 13:29:17 PDT (-0700), joseph@codesourcery.com wrote: > On Wed, 14 Jun 2017, Palmer Dabbelt wrote: > >> diff --git a/sysdeps/riscv/Implies b/sysdeps/riscv/Implies >> new file mode 100644 >> index 0000000000..15b9e02448 >> --- /dev/null >> +++ b/sysdeps/riscv/Implies >> @@ -0,0 +1,6 @@ >> +init_array >> + >> +ieee754/ldbl-128 >> +ieee754/dbl-64 >> +ieee754/flt-32 >> +riscv/soft-fp > > You should never need to have <arch>/Implies referencing <arch>/<subdir>; > in such a case, remove the unnecessary soft-fp directory level and put > sfp-machine.h directly in <arch>. See > <https://sourceware.org/ml/libc-alpha/2014-10/msg00369.html>. Makes sense, I've moved everything from the subdirectory up a level https://github.com/riscv/riscv-glibc/commit/7d9fb3b962e2749b54ddd906b4df91ad854ca45e >> diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile >> new file mode 100644 >> index 0000000000..5a699a2e64 >> --- /dev/null >> +++ b/sysdeps/riscv/Makefile >> @@ -0,0 +1,45 @@ >> +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 > > I think this at least needs some explanatory comment. It feels very > fragile to require lots of architecture-independent files to be built with > an architecture-specific option - it's the sort of thing where people > making architecture-independent changes could easily break the build > accidentally without realising that their change requires the option to be > added for a new file. So if you can find a way to avoid needing such an > architecture-specific list of files, that would be a good idea. Andrew and I don't actually remember what that was for, we're hoping it's just cruft leftover from working around a bug in binutils. He's going to take a look at it. >> diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions >> new file mode 100644 >> index 0000000000..5a0c2d23f8 >> --- /dev/null >> +++ b/sysdeps/riscv/Versions >> @@ -0,0 +1,5 @@ >> +libc { >> + GLIBC_2.14 { >> + __memcpy_g; >> + } >> +} > > No, the minimum version should be 2.26, and you shouldn't need any such > special string variants (given that we've killed bits/string2.h, are about > to kill bits/string.h, and such exports as there are from old string > function inlines are or should soon be compat symbols). OK, makes sense. https://github.com/riscv/riscv-glibc/commit/bbab2031f32970763a0327925fabde969fcd9a77 >> diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure >> new file mode 100644 >> index 0000000000..9f790ec527 >> --- /dev/null >> +++ b/sysdeps/riscv/configure >> @@ -0,0 +1,86 @@ >> + >> +# as_fn_set_status STATUS >> +# ----------------------- >> +# Set $? to STATUS, without forking. >> +as_fn_set_status () >> +{ >> + return $1 >> +} # as_fn_set_status > > Please make sure this file is regenerated. Any sysdeps configure script > generated with current aclocal.m4 should not contain such functions, > assuming the GLIBC_PROVIDES in aclocal.m4 is correct. I think we missed the -I when regenerating this, it's been fixed https://github.com/riscv/riscv-glibc/commit/bcb054441d6fe79c231a8420c67da907fa1ce10f >> diff --git a/sysdeps/riscv/configure.in b/sysdeps/riscv/configure.in >> new file mode 100644 >> index 0000000000..34f62d4b4b >> --- /dev/null >> +++ b/sysdeps/riscv/configure.in > > We use configure.ac naming now, not configure.in. OK, fixed https://github.com/riscv/riscv-glibc/commit/357e0312945c6746e52e5c58ade3182f29b4eaaf https://github.com/riscv/riscv-glibc/commit/8b1b9a4f2f1db655b0d107d72b01e60210dd6329 > Since you have multiple ABI variants, you should be setting default-abi > here via LIBC_CONFIG_VAR. Then sysdeps/unix/sysv/linux/riscv/Makefile > should set abi-variants and appropriate options for each ABI variant (see > other such Makefiles for examples) - this is used in building > bits/syscall.h. OK, that makes sense. I've patterned this after aarch64 and smoke tested it. https://github.com/riscv/riscv-glibc/commit/e3944da6dfd861f4e40bb34c107d479568ba523d >> diff --git a/sysdeps/unix/sysv/linux/riscv/configure.in b/sysdeps/unix/sysv/linux/riscv/configure.in >> new file mode 100644 >> index 0000000000..5b48e1aed6 >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/riscv/configure.in >> @@ -0,0 +1,8 @@ >> +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. >> + >> +if test -z "$arch_minimum_kernel"; then >> + arch_minimum_kernel=3.0.0 >> + libc_cv_gcc_unwind_find_fde=no >> +fi > > Should use .ac naming. No need for the 'if test -z > "$arch_minimum_kernel"; then'. No need to set > libc_cv_gcc_unwind_find_fde=no. Should set arch_minimum_kernel=10.0.0 > until the kernel port is actually in Linus's tree (of course you then need > to change that locally for testing purposes). OK, makes sense https://github.com/riscv/riscv-glibc/commit/f70efbda1a01c87fb4e6e0d57138a49aa0100e88 >> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/Makefile b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile >> new file mode 100644 >> index 0000000000..0a37c5b9b4 >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile >> @@ -0,0 +1,9 @@ >> +ifeq ($(subdir),socket) >> +CFLAGS-recv.c += -fexceptions >> +CFLAGS-send.c += -fexceptions >> +endif >> + >> +ifeq ($(subdir),nptl) >> +CFLAGS-recv.c += -fexceptions >> +CFLAGS-send.c += -fexceptions >> +endif > > In the nptl directory this is the default and should not be needed. https://github.com/riscv/riscv-glibc/commit/142092fc6b6a738e067e4ce22cf420aa502b06af >> diff --git a/sysdeps/unix/sysv/linux/riscv/shlib-versions b/sysdeps/unix/sysv/linux/riscv/shlib-versions >> new file mode 100644 >> index 0000000000..66214b953e >> --- /dev/null >> +++ b/sysdeps/unix/sysv/linux/riscv/shlib-versions >> @@ -0,0 +1,17 @@ >> +DEFAULT GLIBC_2.25 > > Should be GLIBC_2.26. https://github.com/riscv/riscv-glibc/commit/d94d34ef8c20b4c7554bbe25e758642492ee1c85
On Mon, 19 Jun 2017, Palmer Dabbelt wrote: > >> diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions > >> new file mode 100644 > >> index 0000000000..5a0c2d23f8 > >> --- /dev/null > >> +++ b/sysdeps/riscv/Versions > >> @@ -0,0 +1,5 @@ > >> +libc { > >> + GLIBC_2.14 { > >> + __memcpy_g; > >> + } > >> +} > > > > No, the minimum version should be 2.26, and you shouldn't need any such > > special string variants (given that we've killed bits/string2.h, are about > > to kill bits/string.h, and such exports as there are from old string > > function inlines are or should soon be compat symbols). > > OK, makes sense. > > https://github.com/riscv/riscv-glibc/commit/bbab2031f32970763a0327925fabde969fcd9a77 I'd expect this file to go away completely, instead of listing an empty GLIBC_2.26 version. > I think we missed the -I when regenerating this, it's been fixed > > https://github.com/riscv/riscv-glibc/commit/bcb054441d6fe79c231a8420c67da907fa1ce10f It looks like your regeneration adds a blank line at the end of configure. Files ending with blank lines (or whitespace at end of lines, or spaces before tabs) can't be pushed to the glibc repository; you'll need a comment at the end of configure.ac (as in some other versions) to avoid such a blank line at the end of configure.
diff --git a/config.h.in b/config.h.in index 22418576a0..f870267870 100644 --- a/config.h.in +++ b/config.h.in @@ -99,6 +99,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 /* Defined to some form of __attribute__ ((...)) if the compiler supports a different, more efficient calling convention. */ diff --git a/sysdeps/riscv/Implies b/sysdeps/riscv/Implies new file mode 100644 index 0000000000..15b9e02448 --- /dev/null +++ b/sysdeps/riscv/Implies @@ -0,0 +1,6 @@ +init_array + +ieee754/ldbl-128 +ieee754/dbl-64 +ieee754/flt-32 +riscv/soft-fp diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile new file mode 100644 index 0000000000..5a699a2e64 --- /dev/null +++ b/sysdeps/riscv/Makefile @@ -0,0 +1,45 @@ +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) diff --git a/sysdeps/riscv/Versions b/sysdeps/riscv/Versions new file mode 100644 index 0000000000..5a0c2d23f8 --- /dev/null +++ b/sysdeps/riscv/Versions @@ -0,0 +1,5 @@ +libc { + GLIBC_2.14 { + __memcpy_g; + } +} diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure new file mode 100644 index 0000000000..9f790ec527 --- /dev/null +++ b/sysdeps/riscv/configure @@ -0,0 +1,86 @@ + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +# This file is generated from configure.in 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.in b/sysdeps/riscv/configure.in new file mode 100644 index 0000000000..34f62d4b4b --- /dev/null +++ b/sysdeps/riscv/configure.in @@ -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 0000000000..d0c59a5091 --- /dev/null +++ b/sysdeps/riscv/nptl/Makefile @@ -0,0 +1,25 @@ +# Copyright (C) 2005 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, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA. + +ifeq ($(subdir),csu) +gen-as-const-headers += tcb-offsets.sym +endif + +ifeq ($(subdir),nptl) +libpthread-sysdep_routines += nptl-sysdep +endif diff --git a/sysdeps/riscv/preconfigure b/sysdeps/riscv/preconfigure new file mode 100644 index 0000000000..43e2a4fac0 --- /dev/null +++ b/sysdeps/riscv/preconfigure @@ -0,0 +1,50 @@ +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 diff --git a/sysdeps/riscv/rv32/Implies-after b/sysdeps/riscv/rv32/Implies-after new file mode 100644 index 0000000000..39a34c5f57 --- /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 0000000000..9438838e98 --- /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 0000000000..66c401443b --- /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 0000000000..a8cae95f9d --- /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 0000000000..9438838e98 --- /dev/null +++ b/sysdeps/riscv/rv64/rvd/Implies @@ -0,0 +1,2 @@ +riscv/rvd +riscv/rvf diff --git a/sysdeps/riscv/rv64/rvf/Implies b/sysdeps/riscv/rv64/rvf/Implies new file mode 100644 index 0000000000..66c401443b --- /dev/null +++ b/sysdeps/riscv/rv64/rvf/Implies @@ -0,0 +1 @@ +riscv/rvf diff --git a/sysdeps/riscv/soft-fp/Makefile b/sysdeps/riscv/soft-fp/Makefile new file mode 100644 index 0000000000..ada13e8b70 --- /dev/null +++ b/sysdeps/riscv/soft-fp/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),math) +CPPFLAGS += -I../soft-fp +endif diff --git a/sysdeps/unix/sysv/linux/riscv/Implies b/sysdeps/unix/sysv/linux/riscv/Implies new file mode 100644 index 0000000000..6faec70115 --- /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 0000000000..a71840f70c --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/Makefile @@ -0,0 +1,26 @@ +ifeq ($(subdir),elf) +ifeq ($(build-shared),yes) +# This is needed for DSO loading from static binaries. +sysdep-dl-routines += dl-static +sysdep_routines += dl-static +sysdep-rtld-routines += dl-static +endif +endif + +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext_i.sym +endif + +ifeq ($(subdir),crypt) +libcrypt-sysdep_routines += sysdep +endif + +ifeq ($(subdir),nss) +libnss_db-sysdep_routines += sysdep +libnss_db-shared-only-routines += sysdep +endif + +ifeq ($(subdir),rt) +librt-sysdep_routines += sysdep +librt-shared-only-routines += sysdep +endif diff --git a/sysdeps/unix/sysv/linux/riscv/configure b/sysdeps/unix/sysv/linux/riscv/configure new file mode 100644 index 0000000000..2bb3062cc3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/configure @@ -0,0 +1,7 @@ +# This file is generated from configure.in by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/unix/sysv/linux/riscv. + +if test -z "$arch_minimum_kernel"; then + arch_minimum_kernel=3.0.0 + libc_cv_gcc_unwind_find_fde=no +fi diff --git a/sysdeps/unix/sysv/linux/riscv/configure.in b/sysdeps/unix/sysv/linux/riscv/configure.in new file mode 100644 index 0000000000..5b48e1aed6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/configure.in @@ -0,0 +1,8 @@ +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. + +if test -z "$arch_minimum_kernel"; then + arch_minimum_kernel=3.0.0 + libc_cv_gcc_unwind_find_fde=no +fi diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/Implies b/sysdeps/unix/sysv/linux/riscv/rv32/Implies new file mode 100644 index 0000000000..8b7deb33cd --- /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 0000000000..f042343bf7 --- /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 0000000000..0a37c5b9b4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/rv64/Makefile @@ -0,0 +1,9 @@ +ifeq ($(subdir),socket) +CFLAGS-recv.c += -fexceptions +CFLAGS-send.c += -fexceptions +endif + +ifeq ($(subdir),nptl) +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 0000000000..66214b953e --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/shlib-versions @@ -0,0 +1,17 @@ +DEFAULT GLIBC_2.25 + +%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