[0/4] GLIBC_PRIVATE ABI cleanups

Message ID cover.1625591725.git.fweimer@redhat.com
Headers
Series GLIBC_PRIVATE ABI cleanups |

Message

Florian Weimer July 6, 2021, 5:22 p.m. UTC
  This is a follow-up due to the libc integration work.

I think using the libc locks is the right thing to do for now.  In the
future, we might migrate nss_db and nss_hesiod to plain
pthread_mutex_lock (no __ prefix) and use pthread_mutex_t in them.  For
nss_files/nss_dns and without libc integration for them, there might be
a minimal conformance issue here because there is (I think) a POSIX
version which specifies NSS functions but not libpthread.

__pthread_mutex_lock, __pthread_mutex_unlock are currently used by rr; I
filed at ticket explaining why I think they don't need to that for glibc
2.34 anymore:

  glibc 2.34 enablement around pthread mutex handling
  <https://github.com/rr-debugger/rr/issues/2913>

We kept the GLIBC_2.34 symbol versions for those initially because we
could not migrate all internal uses off a
__pthread_mutex_lock@@GLIBC_PRIVATE symbol, and the external users would
have bound to a GLIBC_PRIVATE symbol, so GLIBC_2.34 seemed the better
choice.

Tested on i686-linux-gnu and x86_64-linux-gnu.  Built with
build-many-glibcs.py.

Thanks,
Florian

Florian Weimer (4):
  nptl: Use internal low-level lock type for !IS_IN (libc)
  nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock,
    __pthread_mutex_unlock
  nptl: Reduce the GLIBC_PRIVATE ABI
  elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols

 dlfcn/dlerror.c                               |   1 -
 elf/Makefile                                  |  16 +--
 elf/Versions                                  |   3 -
 elf/dl-addr.c                                 |   1 -
 elf/dl-libc.c                                 |   4 -
 elf/dl-sym.c                                  |   2 -
 elf/tst-libc_dlvsym-dso.c                     |  25 ----
 elf/tst-libc_dlvsym-static.c                  |  32 -----
 elf/tst-libc_dlvsym.c                         |  34 -----
 elf/tst-libc_dlvsym.h                         | 130 ------------------
 include/dlfcn.h                               |  30 ++--
 nptl/Versions                                 |  44 ------
 nptl/pthread_barrier_init.c                   |   5 +-
 nptl/pthread_barrier_wait.c                   |   5 +-
 nptl/pthread_cond_wait.c                      |   5 +-
 nptl/pthread_mutex_lock.c                     |   5 +-
 nptl/pthread_mutex_timedlock.c                |   5 +-
 nptl/pthread_mutex_unlock.c                   |   5 +-
 nptl/pthread_testcancel.c                     |   5 +-
 sysdeps/nptl/libc-lockP.h                     |  51 +------
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   2 -
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |   2 -
 sysdeps/unix/sysv/linux/arc/libc.abilist      |   2 -
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   2 -
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   2 -
 sysdeps/unix/sysv/linux/csky/libc.abilist     |   2 -
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |   2 -
 sysdeps/unix/sysv/linux/i386/libc.abilist     |   2 -
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |   2 -
 .../sysv/linux/m68k/coldfire/libc.abilist     |   2 -
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   2 -
 .../sysv/linux/microblaze/be/libc.abilist     |   2 -
 .../sysv/linux/microblaze/le/libc.abilist     |   2 -
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |   2 -
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |   2 -
 .../sysv/linux/mips/mips64/n32/libc.abilist   |   2 -
 .../sysv/linux/mips/mips64/n64/libc.abilist   |   2 -
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |   2 -
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |   2 -
 .../powerpc/powerpc32/nofpu/libc.abilist      |   2 -
 .../linux/powerpc/powerpc64/be/libc.abilist   |   2 -
 .../linux/powerpc/powerpc64/le/libc.abilist   |   2 -
 .../unix/sysv/linux/riscv/rv32/libc.abilist   |   2 -
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |   2 -
 .../unix/sysv/linux/s390/s390-32/libc.abilist |   2 -
 .../unix/sysv/linux/s390/s390-64/libc.abilist |   2 -
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |   2 -
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   2 -
 .../sysv/linux/sparc/sparc32/libc.abilist     |   2 -
 .../sysv/linux/sparc/sparc64/libc.abilist     |   2 -
 .../unix/sysv/linux/x86_64/64/libc.abilist    |   2 -
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |   2 -
 52 files changed, 44 insertions(+), 428 deletions(-)
 delete mode 100644 elf/tst-libc_dlvsym-dso.c
 delete mode 100644 elf/tst-libc_dlvsym-static.c
 delete mode 100644 elf/tst-libc_dlvsym.c
 delete mode 100644 elf/tst-libc_dlvsym.h
  

Comments

Szabolcs Nagy July 7, 2021, 10:56 a.m. UTC | #1
The 07/06/2021 19:22, Florian Weimer via Libc-alpha wrote:
> This is a follow-up due to the libc integration work.
> 
> I think using the libc locks is the right thing to do for now.  In the
> future, we might migrate nss_db and nss_hesiod to plain
> pthread_mutex_lock (no __ prefix) and use pthread_mutex_t in them.  For
> nss_files/nss_dns and without libc integration for them, there might be
> a minimal conformance issue here because there is (I think) a POSIX
> version which specifies NSS functions but not libpthread.
> 
> __pthread_mutex_lock, __pthread_mutex_unlock are currently used by rr; I
> filed at ticket explaining why I think they don't need to that for glibc
> 2.34 anymore:
> 
>   glibc 2.34 enablement around pthread mutex handling
>   <https://github.com/rr-debugger/rr/issues/2913>
> 
> We kept the GLIBC_2.34 symbol versions for those initially because we
> could not migrate all internal uses off a
> __pthread_mutex_lock@@GLIBC_PRIVATE symbol, and the external users would
> have bound to a GLIBC_PRIVATE symbol, so GLIBC_2.34 seemed the better
> choice.
> 
> Tested on i686-linux-gnu and x86_64-linux-gnu.  Built with
> build-many-glibcs.py.
> 
> Thanks,
> Florian
> 
> Florian Weimer (4):
>   nptl: Use internal low-level lock type for !IS_IN (libc)
>   nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock,
>     __pthread_mutex_unlock
>   nptl: Reduce the GLIBC_PRIVATE ABI
>   elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols

after these commits on arm i see

/usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_unbind':
/work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:267: undefined reference to `__libc_do_syscall'
/usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_get_default_domain':
/work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:415: undefined reference to `__libc_do_syscall'
/usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `do_ypcall':
/work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:332: undefined reference to `__libc_do_syscall'
/usr/bin/ld: /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:319: undefined reference to `__libc_do_syscall'
/usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os): in function `get_ckey':
/work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: undefined reference to `__libc_do_syscall'
/usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os):/work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: more undefined references to `__libc_do_syscall' follow
collect2: error: ld returned 1 exit status
make[2]: *** [../Makerules:536: /work/glibc-armhf-linux/build/build/nis/libnsl.so] Error 1
make[2]: Target 'others' not remade because of errors.
make[2]: Leaving directory '/work/glibc-armhf-linux/build/glibc/nis'
make[1]: *** [Makefile:478: nis/others] Error 2
  
Florian Weimer July 7, 2021, 11:04 a.m. UTC | #2
* Szabolcs Nagy:

>> Florian Weimer (4):
>>   nptl: Use internal low-level lock type for !IS_IN (libc)
>>   nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock,
>>     __pthread_mutex_unlock
>>   nptl: Reduce the GLIBC_PRIVATE ABI
>>   elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols
>
> after these commits on arm i see
>
> /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_unbind':
> /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:267: undefined reference to `__libc_do_syscall'
> /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_get_default_domain':
> /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:415: undefined reference to `__libc_do_syscall'
> /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `do_ypcall':
> /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:332: undefined reference to `__libc_do_syscall'
> /usr/bin/ld: /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:319: undefined reference to `__libc_do_syscall'
> /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os): in function `get_ckey':
> /work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: undefined reference to `__libc_do_syscall'
> /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os):/work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: more undefined references to `__libc_do_syscall' follow
> collect2: error: ld returned 1 exit status

I did build this on arm-linux-gnueabihf with build-many-glibcs.py, so
this is very surprising.  Looking at
sysdeps/unix/sysv/linux/arm/sysdep.h, I wonder if you are building in
thumb mode, and if so, why this isn't covered by build-many-glibcs.py.

Is the comment about the r7 register still accurate?

Thanks,
Florian
  
Szabolcs Nagy July 7, 2021, 11:53 a.m. UTC | #3
The 07/07/2021 13:04, Florian Weimer wrote:
> * Szabolcs Nagy:
> >> Florian Weimer (4):
> >>   nptl: Use internal low-level lock type for !IS_IN (libc)
> >>   nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock,
> >>     __pthread_mutex_unlock
> >>   nptl: Reduce the GLIBC_PRIVATE ABI
> >>   elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols
> >
> > after these commits on arm i see
> >
> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_unbind':
> > /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:267: undefined reference to `__libc_do_syscall'
> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_get_default_domain':
> > /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:415: undefined reference to `__libc_do_syscall'
> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `do_ypcall':
> > /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:332: undefined reference to `__libc_do_syscall'
> > /usr/bin/ld: /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:319: undefined reference to `__libc_do_syscall'
> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os): in function `get_ckey':
> > /work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: undefined reference to `__libc_do_syscall'
> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os):/work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: more undefined references to `__libc_do_syscall' follow
> > collect2: error: ld returned 1 exit status
> 
> I did build this on arm-linux-gnueabihf with build-many-glibcs.py, so
> this is very surprising.  Looking at
> sysdeps/unix/sysv/linux/arm/sysdep.h, I wonder if you are building in
> thumb mode, and if so, why this isn't covered by build-many-glibcs.py.
> 
> Is the comment about the r7 register still accurate?

yes it seems the compiler defaults to thumb mode:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.2.0-7ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-7ubuntu1)

and yes i think the comment about r7 is accurate
(the compiler won't allow using it) e.g. in thumb
mode musl uses inline asm like

 "mov %1,r7 ; mov r7,%2 ; svc 0 ; mov r7,%1"
  
Florian Weimer July 7, 2021, 12:44 p.m. UTC | #4
* Szabolcs Nagy:

> The 07/07/2021 13:04, Florian Weimer wrote:
>> * Szabolcs Nagy:
>> >> Florian Weimer (4):
>> >>   nptl: Use internal low-level lock type for !IS_IN (libc)
>> >>   nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock,
>> >>     __pthread_mutex_unlock
>> >>   nptl: Reduce the GLIBC_PRIVATE ABI
>> >>   elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols
>> >
>> > after these commits on arm i see
>> >
>> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_unbind':
>> > /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:267: undefined reference to `__libc_do_syscall'
>> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `__GI_yp_get_default_domain':
>> > /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:415: undefined reference to `__libc_do_syscall'
>> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(ypclnt.os): in function `do_ypcall':
>> > /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:332: undefined reference to `__libc_do_syscall'
>> > /usr/bin/ld: /work/glibc-armhf-linux/build/glibc/nis/ypclnt.c:319: undefined reference to `__libc_do_syscall'
>> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os): in function `get_ckey':
>> > /work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: undefined reference to `__libc_do_syscall'
>> > /usr/bin/ld: /work/glibc-armhf-linux/build/build/nis/libnsl_pic.a(nis_call.os):/work/glibc-armhf-linux/build/glibc/nis/nis_call.c:177: more undefined references to `__libc_do_syscall' follow
>> > collect2: error: ld returned 1 exit status
>> 
>> I did build this on arm-linux-gnueabihf with build-many-glibcs.py, so
>> this is very surprising.  Looking at
>> sysdeps/unix/sysv/linux/arm/sysdep.h, I wonder if you are building in
>> thumb mode, and if so, why this isn't covered by build-many-glibcs.py.
>> 
>> Is the comment about the r7 register still accurate?
>
> yes it seems the compiler defaults to thumb mode:

How would one select that in a glibc build?  Configure with
CC="gcc -mthumb" CXX="g++ -mthumb"?

If yes, then we should change at least one of the Arm targets to use
that.

Thanks,
Florian
  
Szabolcs Nagy July 7, 2021, 12:53 p.m. UTC | #5
The 07/07/2021 14:44, Florian Weimer wrote:
> * Szabolcs Nagy:
> > yes it seems the compiler defaults to thumb mode:
> 
> How would one select that in a glibc build?  Configure with
> CC="gcc -mthumb" CXX="g++ -mthumb"?
> 
> If yes, then we should change at least one of the Arm targets to use
> that.

yes that makes sense. adding -mthumb to CC should work.