Message ID | 20200313030419.15843-14-vgupta@synopsys.com |
---|---|
State | New |
Headers | show |
Series | glibc port to ARC processors | expand |
On Thu, 12 Mar 2020, Vineet Gupta via Libc-alpha wrote: > +ifeq ($(subdir),debug) > +CFLAGS-backtrace.c += -funwind-tables > +endif debug/Makefile already has CFLAGS-backtrace.c += -fno-omit-frame-pointer -funwind-tables so you shouldn't need this. > +++ b/sysdeps/arc/Versions > @@ -0,0 +1,6 @@ > +libc { > + GLIBC_2.32 { > + __syscall_error; Why does __syscall_error need a public symbol version? If it's used by a library other than libc, that means it needs to be exported at some symbol version - but it only needs a public version (as opposed to GLIBC_PRIVATE) if it might be used by user programs linked with glibc (if it's used in crt*.o, lib*_nonshared.a, or inline functions in installed headers, for example - or in libgcc.a, libstdc++.a, etc. (GCC static libraries)). > + gccfloat=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep __ARC_FPU_| wc -l` > + if test "$gccfloat" != "0"; then > + echo "glibc being configured for double precision floating point" preconfigure fragments should not print this sort of debugging message with "echo". If you feel such a message is important, use preconfigure.ac and print it with AC_MSG_NOTICE.
On 3/27/20 3:47 PM, Joseph Myers wrote: > On Thu, 12 Mar 2020, Vineet Gupta via Libc-alpha wrote: > >> +ifeq ($(subdir),debug) >> +CFLAGS-backtrace.c += -funwind-tables >> +endif > > debug/Makefile already has > > CFLAGS-backtrace.c += -fno-omit-frame-pointer -funwind-tables > > so you shouldn't need this. Ok removed now. >> +++ b/sysdeps/arc/Versions >> @@ -0,0 +1,6 @@ >> +libc { >> + GLIBC_2.32 { >> + __syscall_error; > > Why does __syscall_error need a public symbol version? If it's used by a > library other than libc, that means it needs to be exported at some symbol > version - but it only needs a public version (as opposed to GLIBC_PRIVATE) > if it might be used by user programs linked with glibc (if it's used in > crt*.o, lib*_nonshared.a, or inline functions in installed headers, for > example - or in libgcc.a, libstdc++.a, etc. (GCC static libraries)). We'll historically I've preferred an out-of-line errno setter in the syscall wrappers and those are used in libpthread et all as well but not expected to be used by user programs. See my sysdeps.h > >> + gccfloat=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep __ARC_FPU_| wc -l` >> + if test "$gccfloat" != "0"; then >> + echo "glibc being configured for double precision floating point" > > preconfigure fragments should not print this sort of debugging message > with "echo". If you feel such a message is important, use preconfigure.ac > and print it with AC_MSG_NOTICE. Not really needed now, so removed.
On 3/27/20 11:42 PM, Vineet Gupta via Libc-alpha wrote: >>> +++ b/sysdeps/arc/Versions >>> @@ -0,0 +1,6 @@ >>> +libc { >>> + GLIBC_2.32 { >>> + __syscall_error; >> >> Why does __syscall_error need a public symbol version? If it's used by a >> library other than libc, that means it needs to be exported at some symbol >> version - but it only needs a public version (as opposed to GLIBC_PRIVATE) >> if it might be used by user programs linked with glibc (if it's used in >> crt*.o, lib*_nonshared.a, or inline functions in installed headers, for >> example - or in libgcc.a, libstdc++.a, etc. (GCC static libraries)). > > We'll historically I've preferred an out-of-line errno setter in the syscall > wrappers and those are used in libpthread et all as well but not expected to be > used by user programs. See my sysdeps.h Ok so this will not be called directly from user programs, but indeed could end up in non shared libs and/or inline functions in headers, so I suppose this is fine ?
On Tue, 31 Mar 2020, Vineet Gupta via Libc-alpha wrote: > On 3/27/20 11:42 PM, Vineet Gupta via Libc-alpha wrote: > >>> +++ b/sysdeps/arc/Versions > >>> @@ -0,0 +1,6 @@ > >>> +libc { > >>> + GLIBC_2.32 { > >>> + __syscall_error; > >> > >> Why does __syscall_error need a public symbol version? If it's used by a > >> library other than libc, that means it needs to be exported at some symbol > >> version - but it only needs a public version (as opposed to GLIBC_PRIVATE) > >> if it might be used by user programs linked with glibc (if it's used in > >> crt*.o, lib*_nonshared.a, or inline functions in installed headers, for > >> example - or in libgcc.a, libstdc++.a, etc. (GCC static libraries)). > > > > We'll historically I've preferred an out-of-line errno setter in the syscall > > wrappers and those are used in libpthread et all as well but not expected to be > > used by user programs. See my sysdeps.h > > Ok so this will not be called directly from user programs, but indeed > could end up in non shared libs and/or inline functions in headers, so I > suppose this is fine ? What inline function or object in lib*_nonshared.a / crt*.o / GCC static library has a reference to this symbol? If there's an inline function referring to this in an installed header, we can consider whether that inline function *should* be referring to it. Similarly if there's a reference in crt*.o / lib*_nonshared.a / GCC static libraries, we can consider if that reference *should* be there or if the function in question should actually be calling some function from libc.so that does the syscall there.
On 3/31/20 3:48 PM, Joseph Myers wrote: > On Tue, 31 Mar 2020, Vineet Gupta via Libc-alpha wrote: > >> On 3/27/20 11:42 PM, Vineet Gupta via Libc-alpha wrote: >>>>> +++ b/sysdeps/arc/Versions >>>>> @@ -0,0 +1,6 @@ >>>>> +libc { >>>>> + GLIBC_2.32 { >>>>> + __syscall_error; >>>> >>>> Why does __syscall_error need a public symbol version? If it's used by a >>>> library other than libc, that means it needs to be exported at some symbol >>>> version - but it only needs a public version (as opposed to GLIBC_PRIVATE) >>>> if it might be used by user programs linked with glibc (if it's used in >>>> crt*.o, lib*_nonshared.a, or inline functions in installed headers, for >>>> example - or in libgcc.a, libstdc++.a, etc. (GCC static libraries)). >>> >>> We'll historically I've preferred an out-of-line errno setter in the syscall >>> wrappers and those are used in libpthread et all as well but not expected to be >>> used by user programs. See my sysdeps.h >> >> Ok so this will not be called directly from user programs, but indeed >> could end up in non shared libs and/or inline functions in headers, so I >> suppose this is fine ? > > What inline function or object in lib*_nonshared.a / crt*.o / GCC static > library has a reference to this symbol? > > If there's an inline function referring to this in an installed header, we > can consider whether that inline function *should* be referring to it. > Similarly if there's a reference in crt*.o / lib*_nonshared.a / GCC static > libraries, we can consider if that reference *should* be there or if the > function in question should actually be calling some function from libc.so > that does the syscall there. The assembler macros in syscall template for generating wrappers use __syscall_error (sysdeps/unix/sysv/linux/arc/sysdep.h). If public Version is removed, I get errors like below: | arc-glibc-linux-gnu-gcc -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl, | -dynamic-linker=/lib/ld-linux-arc.so.2 -Wl,--version-script=/SCRATCH/vgupta | /gnu/build/glibcs/arc-linux-gnu/glibc/librt.map -Wl,-soname=librt.so.1 | | ... | a - mq_setattr.o | a - librt-cancellation.o | /SCRATCH/vgupta/gnu/install/compilers/arc-linux-gnu/lib/gcc/arc-glibc-linux- | gnu/10.0.1/../../../../arc-glibc-linux-gnu/bin/ld: /SCRATCH/vgupta/gnu/build | /glibcs/arc-linux-gnu/glibc/rt/librt_pic.a(mq_setattr.os): in function | `mq_setattr': | /SCRATCH/vgupta/gnu/src/glibc/rt/../sysdeps/unix/syscall-template.S:80: | undefined reference to `__syscall_error' And this change goes back to initial port (in 2016) where openssh/libcrypt.so was failing to link somewhat similarly. Looking as RISCV code, they opencode __syscall_error for !IS_IN (libc) which I was hoping to avoid.
On Apr 01 2020, Vineet Gupta via Libc-alpha wrote: > Looking as RISCV code, they opencode __syscall_error for !IS_IN (libc) which I was > hoping to avoid. But that is the right way to do it. The syscall error handler must be local to the library, it cannot afford to go through the PLT to call a function in a different library here. Andreas.
On Wed, 1 Apr 2020, Vineet Gupta via Libc-alpha wrote: > > If there's an inline function referring to this in an installed header, we > > can consider whether that inline function *should* be referring to it. > > Similarly if there's a reference in crt*.o / lib*_nonshared.a / GCC static > > libraries, we can consider if that reference *should* be there or if the > > function in question should actually be calling some function from libc.so > > that does the syscall there. > > The assembler macros in syscall template for generating wrappers use > __syscall_error (sysdeps/unix/sysv/linux/arc/sysdep.h). That's an internal header. It might be included in code used in crt*.o / lib*_nonshared.a, but can't be included from any installed header, so can't result in references in inline functions from installed headers. > If public Version is removed, I get errors like below: What if you move it to GLIBC_PRIVATE? My concern isn't that it's exported from the shared library, it's that it's exported at a public version. A public version is only needed if there are references in code that might be statically linked into user binaries that use shared libc. Which means the symbol being used in some .o or .a file that gets linked into user binaries in that case (crt*.o, lib*_nonshared.a). You can examine the symbols used by such objects after building and installing glibc.
On 4/1/20 12:58 AM, Andreas Schwab wrote: > On Apr 01 2020, Vineet Gupta via Libc-alpha wrote: > >> Looking as RISCV code, they opencode __syscall_error for !IS_IN (libc) which I was >> hoping to avoid. > > But that is the right way to do it. The syscall error handler must be > local to the library, it cannot afford to go through the PLT to call a > function in a different library here. Still, It needs to fetch (and runtime prepare) the GOT entry anyways. The real point however is having the call avoids having to know/write asm code with the errno codegen ABI for TLS model etc Well its no big deal either way, not these days anyways (Given the ARC embedded background, I've histrionically been more sensitive to code size, but that boundary seems to be getting hazy/moot-point anyways...)
On 4/1/20 10:06 AM, Joseph Myers wrote: > >> If public Version is removed, I get errors like below: > > What if you move it to GLIBC_PRIVATE? My concern isn't that it's exported > from the shared library, it's that it's exported at a public version. > > A public version is only needed if there are references in code that might > be statically linked into user binaries that use shared libc. Which means > the symbol being used in some .o or .a file that gets linked into user > binaries in that case (crt*.o, lib*_nonshared.a). You can examine the > symbols used by such objects after building and installing glibc. Moving it to GLIBC_PRIVATE seems to work too. *Before* arc-linux-readelf -a lib/libc-2.31.9000.so | grep syscall_error 1671: 0001b4b4 18 FUNC GLOBAL DEFAULT 11 __syscall_error@@GLIBC_2.32 4686: 0001b4b4 18 FUNC LOCAL DEFAULT 11 __GI___syscall_error 6286: 0001b4b4 18 FUNC GLOBAL DEFAULT 11 __syscall_error arc-linux-readelf -a lib/librt-2.31.9000.so | grep syscall_error 00008054 00001f37 R_ARC_JMP_SLOT 00000000 __syscall_error@GLIBC_2.32 + 0 31: 00000000 0 FUNC GLOBAL DEFAULT UND __syscall_error@GLIBC_2.32 (3) 198: 00000000 0 FUNC GLOBAL DEFAULT UND __syscall_error@@GLIBC_2. *Now* arc-linux-readelf -a lib/libc-2.31.9000.so | grep syscall_error 1671: 0001b4b4 18 FUNC GLOBAL DEFAULT 11 __syscall_error@@GLIBC_PRIVATE 4686: 0001b4b4 18 FUNC LOCAL DEFAULT 11 __GI___syscall_error 6286: 0001b4b4 18 FUNC GLOBAL DEFAULT 11 __syscall_error arc-linux-readelf -a lib/librt-2.31.9000.so | grep syscall_error 00008068 00002437 R_ARC_JMP_SLOT 00000000 __syscall_error@GLIBC_PRIVATE + 0 36: 00000000 0 FUNC GLOBAL DEFAULT UND __syscall_error@GLIBC_PRIVATE (4) 206: 00000000 0 FUNC GLOBAL DEFAULT UND __syscall_error@@GLIBC_PR
* Joseph Myers: > What if you move it to GLIBC_PRIVATE? My concern isn't that it's exported > from the shared library, it's that it's exported at a public version. I think it's preferable to duplicate __syscall_error in each shared object that needs it. It avoids potential strange loops if the lazy binding code itself ends up calling __syscall_error in an different object (e.g., from the DSO that implements malloc). Maybe we can make this work as long as libc.so uses an internal call, but it looks tricky. Alternatively, we can enable BIND_NOW unconditionally. Thanks, Florian
On 4/2/20 1:50 AM, Florian Weimer via Libc-alpha wrote: >> What if you move it to GLIBC_PRIVATE? My concern isn't that it's exported >> from the shared library, it's that it's exported at a public version. > > I think it's preferable to duplicate __syscall_error in each shared > object that needs it. It avoids potential strange loops if the lazy > binding code itself ends up calling __syscall_error in an different > object (e.g., from the DSO that implements malloc). > > Maybe we can make this work as long as libc.so uses an internal call, > but it looks tricky. > > Alternatively, we can enable BIND_NOW unconditionally. This seems too big of a trade-off for a seeming small optimization. If you folks feel strongly, I can drop all of this __syscall_error dance. Just let me know what approach to take.
diff --git a/sysdeps/arc/Implies b/sysdeps/arc/Implies new file mode 100644 index 000000000000..780c4e246769 --- /dev/null +++ b/sysdeps/arc/Implies @@ -0,0 +1,3 @@ +wordsize-32 +ieee754/flt-32 +ieee754/dbl-64 diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile new file mode 100644 index 000000000000..92f90798355b --- /dev/null +++ b/sysdeps/arc/Makefile @@ -0,0 +1,25 @@ +# ARC Makefile +# Copyright (C) 1993-2020 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 +# <https://www.gnu.org/licenses/>. + +# We don't support long doubles as a distinct type. We don't need to set +# this variable; it's here mostly for documentational purposes. +long-double-fcts = no + +ifeq ($(subdir),debug) +CFLAGS-backtrace.c += -funwind-tables +endif diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions new file mode 100644 index 000000000000..2d0f534b2aba --- /dev/null +++ b/sysdeps/arc/Versions @@ -0,0 +1,6 @@ +libc { + GLIBC_2.32 { + __syscall_error; + __mcount; + } +} diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure new file mode 100644 index 000000000000..52e286da2ebb --- /dev/null +++ b/sysdeps/arc/configure @@ -0,0 +1,14 @@ +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/arc. + +$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h + +libc_cv_have_sdata_section=no + +# For ARC, historically ; was used for comments and not newline +# Later # also got added to comment list, but ; couldn't be switched to +# canonical newline as there's lots of code out there which will break +libc_cv_asm_line_sep='`' +cat >>confdefs.h <<_ACEOF +#define ASM_LINE_SEP $libc_cv_asm_line_sep +_ACEOF diff --git a/sysdeps/arc/configure.ac b/sysdeps/arc/configure.ac new file mode 100644 index 000000000000..1074d312f033 --- /dev/null +++ b/sysdeps/arc/configure.ac @@ -0,0 +1,11 @@ +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local configure fragment for sysdeps/arc. + +AC_DEFINE(PI_STATIC_AND_HIDDEN) +libc_cv_have_sdata_section=no + +# For ARC, historically ; was used for comments and not newline +# Later # also got added to comment list, but ; couldn't be switched to +# canonical newline as there's lots of code out there which will break +libc_cv_asm_line_sep='`' +AC_DEFINE_UNQUOTED(ASM_LINE_SEP, $libc_cv_asm_line_sep) diff --git a/sysdeps/arc/nptl/Makefile b/sysdeps/arc/nptl/Makefile new file mode 100644 index 000000000000..6f387c53905d --- /dev/null +++ b/sysdeps/arc/nptl/Makefile @@ -0,0 +1,22 @@ +# NPTL makefile fragment for ARC. +# Copyright (C) 2005-2020 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 +# <https://www.gnu.org/licenses/>. + +ifeq ($(subdir),csu) +gen-as-const-headers += tcb-offsets.sym +endif diff --git a/sysdeps/arc/preconfigure b/sysdeps/arc/preconfigure new file mode 100644 index 000000000000..d9c5429f4050 --- /dev/null +++ b/sysdeps/arc/preconfigure @@ -0,0 +1,15 @@ +case "$machine" in +arc*) + base_machine=arc + machine=arc + + gccfloat=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep __ARC_FPU_| wc -l` + if test "$gccfloat" != "0"; then + echo "glibc being configured for double precision floating point" + with_fp_cond=1 + else + with_fp_cond=0 + fi + ;; + +esac diff --git a/sysdeps/unix/sysv/linux/arc/Implies b/sysdeps/unix/sysv/linux/arc/Implies new file mode 100644 index 000000000000..7f739a0340b6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arc/Implies @@ -0,0 +1,3 @@ +arc/nptl +unix/sysv/linux/generic/wordsize-32 +unix/sysv/linux/generic diff --git a/sysdeps/unix/sysv/linux/arc/Makefile b/sysdeps/unix/sysv/linux/arc/Makefile new file mode 100644 index 000000000000..a6c6dfc6ec64 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arc/Makefile @@ -0,0 +1,20 @@ +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext_i.sym +endif + +ifeq ($(subdir),signal) +sysdep_routines += sigrestorer +endif + +ifeq ($(subdir),misc) +# MIPS/Tile-style cacheflush routine +sysdep_headers += sys/cachectl.h +sysdep_routines += cacheflush +endif + +ifeq ($(subdir),elf) +ifeq ($(build-shared),yes) +# This is needed for DSO loading from static binaries. +sysdep-dl-routines += dl-static +endif +endif diff --git a/sysdeps/unix/sysv/linux/arc/Versions b/sysdeps/unix/sysv/linux/arc/Versions new file mode 100644 index 000000000000..292f1974b02a --- /dev/null +++ b/sysdeps/unix/sysv/linux/arc/Versions @@ -0,0 +1,16 @@ +ld { + GLIBC_PRIVATE { + # used for loading by static libraries + _dl_var_init; + } +} +libc { + GLIBC_2.32 { + _flush_cache; + cacheflush; + } + GLIBC_PRIVATE { + # A copy of sigaction lives in libpthread, and needs these. + __default_rt_sa_restorer; + } +} diff --git a/sysdeps/unix/sysv/linux/arc/configure b/sysdeps/unix/sysv/linux/arc/configure new file mode 100644 index 000000000000..56ec14357507 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arc/configure @@ -0,0 +1,4 @@ +# This file is generated from configure.in by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/unix/sysv/linux/arc. + +arch_minimum_kernel=5.1.0 diff --git a/sysdeps/unix/sysv/linux/arc/configure.ac b/sysdeps/unix/sysv/linux/arc/configure.ac new file mode 100644 index 000000000000..8af5a12cc248 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arc/configure.ac @@ -0,0 +1,4 @@ +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local configure fragment for sysdeps/unix/sysv/linux/arc. + +arch_minimum_kernel=5.1.0 diff --git a/sysdeps/unix/sysv/linux/arc/shlib-versions b/sysdeps/unix/sysv/linux/arc/shlib-versions new file mode 100644 index 000000000000..a4b961583e95 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arc/shlib-versions @@ -0,0 +1,2 @@ +DEFAULT GLIBC_2.32 +ld=ld-linux-arc.so.2
Signed-off-by: Vineet Gupta <vgupta@synopsys.com> --- sysdeps/arc/Implies | 3 +++ sysdeps/arc/Makefile | 25 ++++++++++++++++++++++ sysdeps/arc/Versions | 6 ++++++ sysdeps/arc/configure | 14 ++++++++++++ sysdeps/arc/configure.ac | 11 ++++++++++ sysdeps/arc/nptl/Makefile | 22 +++++++++++++++++++ sysdeps/arc/preconfigure | 15 +++++++++++++ sysdeps/unix/sysv/linux/arc/Implies | 3 +++ sysdeps/unix/sysv/linux/arc/Makefile | 20 +++++++++++++++++ sysdeps/unix/sysv/linux/arc/Versions | 16 ++++++++++++++ sysdeps/unix/sysv/linux/arc/configure | 4 ++++ sysdeps/unix/sysv/linux/arc/configure.ac | 4 ++++ sysdeps/unix/sysv/linux/arc/shlib-versions | 2 ++ 13 files changed, 145 insertions(+) create mode 100644 sysdeps/arc/Implies create mode 100644 sysdeps/arc/Makefile create mode 100644 sysdeps/arc/Versions create mode 100644 sysdeps/arc/configure create mode 100644 sysdeps/arc/configure.ac create mode 100644 sysdeps/arc/nptl/Makefile create mode 100644 sysdeps/arc/preconfigure create mode 100644 sysdeps/unix/sysv/linux/arc/Implies create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile create mode 100644 sysdeps/unix/sysv/linux/arc/Versions create mode 100644 sysdeps/unix/sysv/linux/arc/configure create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions