mbox series

[RFC,0/9] Remove legacy platform bits and cleanups

Message ID 20240607114543.659306-1-stli@linux.ibm.com
Headers show
Series Remove legacy platform bits and cleanups | expand

Message

Stefan Liebler June 7, 2024, 11:42 a.m. UTC
This patch series is the result of:
"Question regarding platform-bits in ld.so.cache"
https://sourceware.org/pipermail/libc-alpha/2024-May/156793.html

According to the NEWS entry for glibc 2.37:
glibc commit "Add NEWS entry for legacy hwcaps removal"
https://sourceware.org/git/?p=glibc.git;a=commit;h=78d9a1620b840deb0880686e4159eaf70708866a
The dynamic linker no longer no longer loads shared objects from ... or
the subdirectory that corresponds to the AT_PLATFORM system name ...

According to Florian Weimer, it was an oversight and the usage of
_dl_string_platform(), _DL_PLATFORMS_COUNT and _DL_HWCAP_PLATFORM
should be removed in elf/dl-cache.c:search_cache().

This is done in the second patch of this series:
elf: Remove loading legacy hwcaps/platform entries in dynamic loader

The first patch is another oversight and HWCAP_START/HWCAP_COUNT on
x86 is not needed anymore after commit
ab40f20364f4a417a63dd51fdd943742070bfe96
"elf: Remove _dl_string_hwcap".

The remaining patches could cleanup even more things. But I've
currently marked this series as RFC as there are open questions.

- "elf: Remove _dl_string_platform"
_dl_string_platform() is now only used in the ld.so diagnostics output
on all architectures despite of powerpc where the result is stored in
tcb. Thus we could remove it everywhere else.

If it is okay for powerpc to remove the ld.so diagnostics output, the
arch-specific dl-procinfo.h files does not need _dl_string_platform()
anymore and we can just remove it.

If we keep the ld.so diagnostics output, we could just use the generic
macro-defintion in all the other arch-specific dl-procinfo.h files:
#define _dl_string_platform(str) (-1)


- "elf: Remove platform strings in dl-procinfo.c"
If _dl_string_platform() or the implementation is removed, the strings
are also not used anymore and can be removed. Of course not for powerpc.


- "elf: Remove _DL_HWCAP_PLATFORM"
Those macros are not used anymore after removal in
elf/dl-cache.c:search_cache(), _dl_string_platform().


- "elf: Remove _DL_FIRST_PLATFORM"
Those macros are not used anymore after removal in
_dl_string_platform().


- "elf: Remove _DL_PLATFORMS_COUNT"
Those macros are not used anymore after removal in
elf/dl-cache.c:search_cache() and _dl_string_platform().


- "elf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask"
The environment variable LD_HWCAP_MASK / glibc-tunable
glibc.cpu.hwcap_mask is not used anymore after removal in
elf/dl-cache.c:search_cache() despite of sparc32 where it is used in
elf_machine_matches_host().

If sparc32 does not need it anymore, we can get rid of it at all.

Otherwise we could also move LD_HWCAP_MASK / tunable
glibc.cpu.hwcap_mask to be sparc32 specific?


- "elf: Remove HWCAP_IMPORTANT"
This is only dumped in the ld.so diagnostic output and was used as
default-value for LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask.


Stefan Liebler (9):
  x86: Remove HWCAP_START and HWCAP_COUNT
  elf: Remove loading legacy hwcaps/platform entries in dynamic loader
  elf: Remove _dl_string_platform
  elf: Remove platform strings in dl-procinfo.c
  elf: Remove _DL_HWCAP_PLATFORM
  elf: Remove _DL_FIRST_PLATFORM
  elf: Remove _DL_PLATFORMS_COUNT
  elf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask
  elf: Remove HWCAP_IMPORTANT

 elf/dl-cache.c                                | 22 +------
 elf/dl-diagnostics.c                          |  3 -
 elf/dl-tunables.list                          |  7 ---
 elf/tst-env-setuid.c                          |  1 -
 manual/README.tunables                        | 12 ++--
 manual/tunables.texi                          | 11 ----
 sysdeps/alpha/dl-procinfo.c                   | 62 -------------------
 sysdeps/alpha/dl-procinfo.h                   | 24 -------
 sysdeps/csky/dl-procinfo.c                    | 62 -------------------
 sysdeps/csky/dl-procinfo.h                    | 23 -------
 sysdeps/generic/dl-procinfo.h                 |  8 ---
 sysdeps/generic/unsecvars.h                   |  1 -
 sysdeps/mips/dl-procinfo.c                    | 62 -------------------
 sysdeps/mips/dl-procinfo.h                    | 24 -------
 sysdeps/powerpc/dl-procinfo.h                 |  8 ---
 sysdeps/s390/dl-procinfo-s390.c               |  6 --
 sysdeps/s390/dl-procinfo.h                    | 29 ---------
 sysdeps/sparc/dl-procinfo.h                   | 10 ---
 sysdeps/sparc/sparc32/dl-machine.h            |  6 --
 sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h |  8 ---
 sysdeps/unix/sysv/linux/arm/dl-procinfo.h     |  7 ---
 sysdeps/x86/dl-hwcap.h                        | 25 --------
 sysdeps/x86/dl-procinfo.c                     | 21 +------
 sysdeps/x86/dl-procinfo.h                     | 22 -------
 sysdeps/x86_64/dl-procruntime.c               |  5 +-
 25 files changed, 13 insertions(+), 456 deletions(-)
 delete mode 100644 sysdeps/alpha/dl-procinfo.c
 delete mode 100644 sysdeps/csky/dl-procinfo.c
 delete mode 100644 sysdeps/mips/dl-procinfo.c

Comments

Florian Weimer June 7, 2024, 12:18 p.m. UTC | #1
* Stefan Liebler:

> - "elf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask"
> The environment variable LD_HWCAP_MASK / glibc-tunable
> glibc.cpu.hwcap_mask is not used anymore after removal in
> elf/dl-cache.c:search_cache() despite of sparc32 where it is used in
> elf_machine_matches_host().

Are you sure about that?  It is used to update GLRO(dl_hwcap), and that
_rtld_global_ro member is consulted in various places.  Its value is
also returned by getauxval (AT_HWCAP).

Thanks,
Florian
Florian Weimer June 8, 2024, 11:09 a.m. UTC | #2
* Stefan Liebler:

> This patch series is the result of:
> "Question regarding platform-bits in ld.so.cache"
> https://sourceware.org/pipermail/libc-alpha/2024-May/156793.html

This series fails to build on MIPS with:

mips64-glibc-linux-gnu-gcc -mabi=32 ldconfig.c -c -std=gnu11 -fgnu89-inline  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64   -fPIE    -Wa,-execstack -D'SYSCONFDIR="/etc"' -D'LIBDIR="/usr/lib"' -D'SLIBDIR="/lib"'       -I../include -I/home/bmg/build/glibcs/mips-linux-gnu/glibc/elf  -I/home/bmg/build/glibcs/mips-linux-gnu/glibc  -I../sysdeps/unix/sysv/linux/mips/mips32/fpu  -I../sysdeps/unix/sysv/linux/mips/mips32  -I../sysdeps/unix/sysv/linux/mips  -I../sysdeps/mips/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/mips/mips32  -I../sysdeps/unix/mips  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/mips/mips32/fpu  -I../sysdeps/mips/mips32  -I../sysdeps/mips/ieee754  -I../sysdeps/mips/include -I../sysdeps/mips  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/wordsize-32  -I../sysdeps/mips/fpu  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include /home/bmg/build/glibcs/mips-linux-gnu/glibc/libc-modules.h -DMODULE_NAME=ldconfig -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o -MD -MP -MF /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o.dt -MT /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o
In file included from ../sysdeps/generic/ldsodefs.h:643,
                 from ../sysdeps/mips/ldsodefs.h:82,
                 from ../sysdeps/gnu/ldsodefs.h:46,
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                 from ../sysdeps/unix/sysv/linux/mips/ldsodefs.h:22,
                 from ../sysdeps/mips/dl-procinfo.h:22,
                 from /home/bmg/build/glibcs/mips-linux-gnu/glibc/dl-tunable-list.h:6,
                 from ../elf/dl-tunables.h:48,
                 from ./dl-hwcaps.h:25,
                 from ldconfig.c:44:
../sysdeps/unix/sysv/linux/dl-vdso-setup.c:62:22: error: ‘_dl_vdso_clock_getres’ defined but not used [-Werror=unused-variable]
   62 | PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t,
      |                      ^~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/dl-vdso-setup.c:53:22: error: ‘_dl_vdso_gettimeofday’ defined but not used [-Werror=unused-variable]
   53 | PROCINFO_CLASS int (*_dl_vdso_gettimeofday) (struct timeval *, void *) RELRO;
      |                      ^~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/dl-vdso-setup.c:49:22: error: ‘_dl_vdso_clock_gettime64’ defined but not used [-Werror=unused-variable]
   49 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime64) (clockid_t,
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/dl-vdso-setup.c:45:22: error: ‘_dl_vdso_clock_gettime’ defined but not used [-Werror=unused-variable]
   45 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime) (clockid_t,
      |                      ^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [../o-iterator.mk:9: /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o] Error 1
make[3]: Leaving directory '/home/bmg/src/glibc/elf'
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:484: elf/others] Error 2
make[1]: *** [Makefile:9: all] Error 2

Florian
Stefan Liebler June 10, 2024, 1:23 p.m. UTC | #3
On 07.06.24 14:18, Florian Weimer wrote:
> * Stefan Liebler:
> 
>> - "elf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask"
>> The environment variable LD_HWCAP_MASK / glibc-tunable
>> glibc.cpu.hwcap_mask is not used anymore after removal in
>> elf/dl-cache.c:search_cache() despite of sparc32 where it is used in
>> elf_machine_matches_host().
> 
> Are you sure about that?  It is used to update GLRO(dl_hwcap), and that
> _rtld_global_ro member is consulted in various places.  Its value is
> also returned by getauxval (AT_HWCAP).
> 
> Thanks,
> Florian
> 
I've had a look, but did not found the place where this update happens.

I've also tried out this:
cat tst-LD_HWCAP_MASK.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/auxv.h>

int
main (int argc, char *argv[])
{
  printf ("LD_HWCAP_MASK=\"%s\" GLIBC_TUNABLES=\"%s\" %s\n"
	  "=> getauxval(AT_HWCAP)= 0x%lx\n",
	  getenv("LD_HWCAP_MASK") ?: "", getenv("GLIBC_TUNABLES") ?: "",
	  argv[0], getauxval (AT_HWCAP));
  return EXIT_SUCCESS;
}


LD_HWCAP_MASK="" GLIBC_TUNABLES="" ./tst-LD_HWCAP_MASK-s390x.old
=> getauxval(AT_HWCAP)= 0x7fffff

LD_HWCAP_MASK="0x0" GLIBC_TUNABLES="" ./tst-LD_HWCAP_MASK-s390x.old
=> getauxval(AT_HWCAP)= 0x7fffff

LD_HWCAP_MASK="0xFFFFFFFF" GLIBC_TUNABLES="" ./tst-LD_HWCAP_MASK-s390x.old
=> getauxval(AT_HWCAP)= 0x7fffff

LD_HWCAP_MASK="" GLIBC_TUNABLES="glibc.cpu.hwcap_mask=0x0"
./tst-LD_HWCAP_MASK-s390x.old
=> getauxval(AT_HWCAP)= 0x7fffff

LD_HWCAP_MASK="" GLIBC_TUNABLES="glibc.cpu.hwcap_mask=0xFFFFFFFF"
./tst-LD_HWCAP_MASK-s390x.old
=> getauxval(AT_HWCAP)= 0x7fffff



There is the e.g. GLIBC_TUNABLES=glibc.cpu.hwcaps= which let you
disable/enable the hwcaps used for glibc internal ifuncs.

Before I've implemented GLIBC_TUNABLES=glibc.cpu.hwcaps= for s390x, I've
asked on libc-alpha and Szabolcs Nagy answered this:
(see full question/answer:
Questions regarding manipulation of IFUNC selection and tunables like
glibc.cpu.hwcap_mask
https://sourceware.org/pipermail/libc-alpha/2022-August/141648.html
)
iirc LD_HWCAP_MASK was purely for the old hwcap based
lib path lookup.
...
i think hwcap_mask was not for completely hiding hwcaps
like that.


Attached to the old question is also a program which dumps the hwcaps
passed to s390x-ifunc-resolver. But it was also not changed by the
environment variables.


Please also have a look, if you find the update of GLRO(dl_hwcap).

Thanks,
Stefan
Stefan Liebler June 10, 2024, 1:36 p.m. UTC | #4
On 08.06.24 13:09, Florian Weimer wrote:
> * Stefan Liebler:
> 
>> This patch series is the result of:
>> "Question regarding platform-bits in ld.so.cache"
>> https://sourceware.org/pipermail/libc-alpha/2024-May/156793.html
> 
> This series fails to build on MIPS with:
> 
> mips64-glibc-linux-gnu-gcc -mabi=32 ldconfig.c -c -std=gnu11 -fgnu89-inline  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64   -fPIE    -Wa,-execstack -D'SYSCONFDIR="/etc"' -D'LIBDIR="/usr/lib"' -D'SLIBDIR="/lib"'       -I../include -I/home/bmg/build/glibcs/mips-linux-gnu/glibc/elf  -I/home/bmg/build/glibcs/mips-linux-gnu/glibc  -I../sysdeps/unix/sysv/linux/mips/mips32/fpu  -I../sysdeps/unix/sysv/linux/mips/mips32  -I../sysdeps/unix/sysv/linux/mips  -I../sysdeps/mips/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/mips/mips32  -I../sysdeps/unix/mips  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/mips/mips32/fpu  -I../sysdeps/mips/mips32  -I../sysdeps/mips/ieee754  -I../sysdeps/mips/include -I../sysdeps/mips  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/wordsize-32  -I../sysdeps/mips/fpu  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include /home/bmg/build/glibcs/mips-linux-gnu/glibc/libc-modules.h -DMODULE_NAME=ldconfig -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o -MD -MP -MF /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o.dt -MT /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o
> In file included from ../sysdeps/generic/ldsodefs.h:643,
>                  from ../sysdeps/mips/ldsodefs.h:82,
>                  from ../sysdeps/gnu/ldsodefs.h:46,
>                  from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
>                  from ../sysdeps/unix/sysv/linux/mips/ldsodefs.h:22,
>                  from ../sysdeps/mips/dl-procinfo.h:22,
>                  from /home/bmg/build/glibcs/mips-linux-gnu/glibc/dl-tunable-list.h:6,
>                  from ../elf/dl-tunables.h:48,
>                  from ./dl-hwcaps.h:25,
>                  from ldconfig.c:44:
> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:62:22: error: ‘_dl_vdso_clock_getres’ defined but not used [-Werror=unused-variable]
>    62 | PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t,
>       |                      ^~~~~~~~~~~~~~~~~~~~~
> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:53:22: error: ‘_dl_vdso_gettimeofday’ defined but not used [-Werror=unused-variable]
>    53 | PROCINFO_CLASS int (*_dl_vdso_gettimeofday) (struct timeval *, void *) RELRO;
>       |                      ^~~~~~~~~~~~~~~~~~~~~
> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:49:22: error: ‘_dl_vdso_clock_gettime64’ defined but not used [-Werror=unused-variable]
>    49 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime64) (clockid_t,
>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:45:22: error: ‘_dl_vdso_clock_gettime’ defined but not used [-Werror=unused-variable]
>    45 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime) (clockid_t,
>       |                      ^~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[3]: *** [../o-iterator.mk:9: /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o] Error 1
> make[3]: Leaving directory '/home/bmg/src/glibc/elf'
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [Makefile:484: elf/others] Error 2
> make[1]: *** [Makefile:9: all] Error 2
> 
> Florian
> 
Hi Florian,

thanks for the info. I've take a look. Seems to be related to the
removed sysdeps/mips/dl-procinfo.c with those undefs at the end:
#undef PROCINFO_DECL
#undef PROCINFO_CLASS

Bye,
Stefan
Florian Weimer June 10, 2024, 2:03 p.m. UTC | #5
* Stefan Liebler:

> Please also have a look, if you find the update of GLRO(dl_hwcap).

I tright once more, even went back in Git history, and used hardware
watchpoints, but the code I imagined is just not there.  So I think it's
okay to proceed with this (fix the MIPS issue 8-).

Thanks,
Florian
Stefan Liebler June 11, 2024, 12:13 p.m. UTC | #6
On 10.06.24 15:36, Stefan Liebler wrote:
> On 08.06.24 13:09, Florian Weimer wrote:
>> * Stefan Liebler:
>>
>>> This patch series is the result of:
>>> "Question regarding platform-bits in ld.so.cache"
>>> https://sourceware.org/pipermail/libc-alpha/2024-May/156793.html
>>
>> This series fails to build on MIPS with:
>>
>> mips64-glibc-linux-gnu-gcc -mabi=32 ldconfig.c -c -std=gnu11 -fgnu89-inline  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64   -fPIE    -Wa,-execstack -D'SYSCONFDIR="/etc"' -D'LIBDIR="/usr/lib"' -D'SLIBDIR="/lib"'       -I../include -I/home/bmg/build/glibcs/mips-linux-gnu/glibc/elf  -I/home/bmg/build/glibcs/mips-linux-gnu/glibc  -I../sysdeps/unix/sysv/linux/mips/mips32/fpu  -I../sysdeps/unix/sysv/linux/mips/mips32  -I../sysdeps/unix/sysv/linux/mips  -I../sysdeps/mips/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/mips/mips32  -I../sysdeps/unix/mips  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/mips/mips32/fpu  -I../sysdeps/mips/mips32  -I../sysdeps/mips/ieee754  -I../sysdeps/mips/include -I../sysdeps/mips  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/wordsize-32  -I../sysdeps/mips/fpu  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include /home/bmg/build/glibcs/mips-linux-gnu/glibc/libc-modules.h -DMODULE_NAME=ldconfig -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o -MD -MP -MF /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o.dt -MT /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o
>> In file included from ../sysdeps/generic/ldsodefs.h:643,
>>                  from ../sysdeps/mips/ldsodefs.h:82,
>>                  from ../sysdeps/gnu/ldsodefs.h:46,
>>                  from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
>>                  from ../sysdeps/unix/sysv/linux/mips/ldsodefs.h:22,
>>                  from ../sysdeps/mips/dl-procinfo.h:22,
>>                  from /home/bmg/build/glibcs/mips-linux-gnu/glibc/dl-tunable-list.h:6,
>>                  from ../elf/dl-tunables.h:48,
>>                  from ./dl-hwcaps.h:25,
>>                  from ldconfig.c:44:
>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:62:22: error: ‘_dl_vdso_clock_getres’ defined but not used [-Werror=unused-variable]
>>    62 | PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t,
>>       |                      ^~~~~~~~~~~~~~~~~~~~~
>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:53:22: error: ‘_dl_vdso_gettimeofday’ defined but not used [-Werror=unused-variable]
>>    53 | PROCINFO_CLASS int (*_dl_vdso_gettimeofday) (struct timeval *, void *) RELRO;
>>       |                      ^~~~~~~~~~~~~~~~~~~~~
>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:49:22: error: ‘_dl_vdso_clock_gettime64’ defined but not used [-Werror=unused-variable]
>>    49 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime64) (clockid_t,
>>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:45:22: error: ‘_dl_vdso_clock_gettime’ defined but not used [-Werror=unused-variable]
>>    45 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime) (clockid_t,
>>       |                      ^~~~~~~~~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
>> make[3]: *** [../o-iterator.mk:9: /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o] Error 1
>> make[3]: Leaving directory '/home/bmg/src/glibc/elf'
>> make[3]: *** Waiting for unfinished jobs....
>> make[2]: *** [Makefile:484: elf/others] Error 2
>> make[1]: *** [Makefile:9: all] Error 2
>>
>> Florian
>>
> Hi Florian,
> 
> thanks for the info. I've take a look. Seems to be related to the
> removed sysdeps/mips/dl-procinfo.c with those undefs at the end:
> #undef PROCINFO_DECL
> #undef PROCINFO_CLASS
> 
> Bye,
> Stefan

Okay, we have this chain:
- elf/ldconfig.c:
#define PROCINFO_CLASS static
#include <dl-hwcaps.h>
-> elf/dl-hwcaps.h
-> elf/dl-tunables.h
-> <build>/dl-tunable-list.h
-> sysdeps/mips/dl-procinfo.h:
-> sysdeps/unix/sysv/linux/mips/ldsodefs.h
-> sysdeps/unix/sysv/linux/ldsodefs.h:
-> sysdeps/gnu/ldsodefs.h
-> sysdeps/mips/ldsodefs.h
-> sysdeps/generic/ldsodefs.h:
...
#include <dl-procinfo.c>
...
# define PROCINFO_DECL
# ifndef PROCINFO_CLASS
#  define PROCINFO_CLASS EXTERN
# endif
# include <dl-vdso-setup.c>
...

Before my patch, sysdeps/mips/dl-procinfo.c contains those undefs at the
end:
#undef PROCINFO_DECL
#undef PROCINFO_CLASS
With my patch, the empty sysdeps/generic/dl-procinfo.c is used.

Thus we end up in:
static int (*_dl_vdso_...) (...) RELRO;
vs before:
extern int (*_dl_vdso_...) (...) RELRO;

The latter builds fine, while the former produces the "defined but not
used" warnings.


Thus I will adjust my patch to keep sysdeps/mips/dl-procinfo.c with only
something like this:
/* Note:
   When compiling elf/ldconfig.c, PROCINFO_CLASS is defined to static.
   This dl-procinfo.c is included in sysdeps/generic/ldsodefs.h.
   Afterwards, if not yet defined, PROCINFO_CLASS is defined to EXTERN
   just before dl-vdso-setup.c is included.  A "static" _dl_vdso_xyz
   function prototype would lead to gcc warnings/errors: defined but
   not used.  */
#undef PROCINFO_DECL
#undef PROCINFO_CLASS


My patch also removes sysdeps/alpha/dl-procinfo.c and
sysdeps/csky/dl-procinfo.c with those #undef's at the end. But alpha and
csky do not define the vdso HAVE_XYZ_VSYSCALL macros and thus do not end
up with those errors.
(At the end of dl-vdso-setup.c, PROCINFO_DECL and PROCINFO_CLASS are
also undefined)

I run build-many-glibcs.py from scratch which lasts some time.
Afterwards I'll send a V2 series.

Thanks,
Stefan
Stefan Liebler June 11, 2024, 12:24 p.m. UTC | #7
On 10.06.24 16:03, Florian Weimer wrote:
> * Stefan Liebler:
> 
>> Please also have a look, if you find the update of GLRO(dl_hwcap).
> 
> I tright once more, even went back in Git history, and used hardware
> watchpoints, but the code I imagined is just not there.  So I think it's
> okay to proceed with this (fix the MIPS issue 8-).
> 
> Thanks,
> Florian
> 
Sounds great. Thanks for digging.
Stefan Liebler June 12, 2024, 7:50 a.m. UTC | #8
On 11.06.24 14:13, Stefan Liebler wrote:
> On 10.06.24 15:36, Stefan Liebler wrote:
>> On 08.06.24 13:09, Florian Weimer wrote:
>>> * Stefan Liebler:
>>>
>>>> This patch series is the result of:
>>>> "Question regarding platform-bits in ld.so.cache"
>>>> https://sourceware.org/pipermail/libc-alpha/2024-May/156793.html
>>>
>>> This series fails to build on MIPS with:
>>>
>>> mips64-glibc-linux-gnu-gcc -mabi=32 ldconfig.c -c -std=gnu11 -fgnu89-inline  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64   -fPIE    -Wa,-execstack -D'SYSCONFDIR="/etc"' -D'LIBDIR="/usr/lib"' -D'SLIBDIR="/lib"'       -I../include -I/home/bmg/build/glibcs/mips-linux-gnu/glibc/elf  -I/home/bmg/build/glibcs/mips-linux-gnu/glibc  -I../sysdeps/unix/sysv/linux/mips/mips32/fpu  -I../sysdeps/unix/sysv/linux/mips/mips32  -I../sysdeps/unix/sysv/linux/mips  -I../sysdeps/mips/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/mips/mips32  -I../sysdeps/unix/mips  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/mips/mips32/fpu  -I../sysdeps/mips/mips32  -I../sysdeps/mips/ieee754  -I../sysdeps/mips/include -I../sysdeps/mips  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/wordsize-32  -I../sysdeps/mips/fpu  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include /home/bmg/build/glibcs/mips-linux-gnu/glibc/libc-modules.h -DMODULE_NAME=ldconfig -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o -MD -MP -MF /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o.dt -MT /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o
>>> In file included from ../sysdeps/generic/ldsodefs.h:643,
>>>                  from ../sysdeps/mips/ldsodefs.h:82,
>>>                  from ../sysdeps/gnu/ldsodefs.h:46,
>>>                  from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
>>>                  from ../sysdeps/unix/sysv/linux/mips/ldsodefs.h:22,
>>>                  from ../sysdeps/mips/dl-procinfo.h:22,
>>>                  from /home/bmg/build/glibcs/mips-linux-gnu/glibc/dl-tunable-list.h:6,
>>>                  from ../elf/dl-tunables.h:48,
>>>                  from ./dl-hwcaps.h:25,
>>>                  from ldconfig.c:44:
>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:62:22: error: ‘_dl_vdso_clock_getres’ defined but not used [-Werror=unused-variable]
>>>    62 | PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t,
>>>       |                      ^~~~~~~~~~~~~~~~~~~~~
>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:53:22: error: ‘_dl_vdso_gettimeofday’ defined but not used [-Werror=unused-variable]
>>>    53 | PROCINFO_CLASS int (*_dl_vdso_gettimeofday) (struct timeval *, void *) RELRO;
>>>       |                      ^~~~~~~~~~~~~~~~~~~~~
>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:49:22: error: ‘_dl_vdso_clock_gettime64’ defined but not used [-Werror=unused-variable]
>>>    49 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime64) (clockid_t,
>>>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:45:22: error: ‘_dl_vdso_clock_gettime’ defined but not used [-Werror=unused-variable]
>>>    45 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime) (clockid_t,
>>>       |                      ^~~~~~~~~~~~~~~~~~~~~~
>>> cc1: all warnings being treated as errors
>>> make[3]: *** [../o-iterator.mk:9: /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o] Error 1
>>> make[3]: Leaving directory '/home/bmg/src/glibc/elf'
>>> make[3]: *** Waiting for unfinished jobs....
>>> make[2]: *** [Makefile:484: elf/others] Error 2
>>> make[1]: *** [Makefile:9: all] Error 2
>>>
>>> Florian
>>>
>> Hi Florian,
>>
>> thanks for the info. I've take a look. Seems to be related to the
>> removed sysdeps/mips/dl-procinfo.c with those undefs at the end:
>> #undef PROCINFO_DECL
>> #undef PROCINFO_CLASS
>>
>> Bye,
>> Stefan
> 
> Okay, we have this chain:
> - elf/ldconfig.c:
> #define PROCINFO_CLASS static
> #include <dl-hwcaps.h>
> -> elf/dl-hwcaps.h
> -> elf/dl-tunables.h
> -> <build>/dl-tunable-list.h
> -> sysdeps/mips/dl-procinfo.h:
> -> sysdeps/unix/sysv/linux/mips/ldsodefs.h
> -> sysdeps/unix/sysv/linux/ldsodefs.h:
> -> sysdeps/gnu/ldsodefs.h
> -> sysdeps/mips/ldsodefs.h
> -> sysdeps/generic/ldsodefs.h:
> ...
> #include <dl-procinfo.c>
> ...
> # define PROCINFO_DECL
> # ifndef PROCINFO_CLASS
> #  define PROCINFO_CLASS EXTERN
> # endif
> # include <dl-vdso-setup.c>
> ...
> 
> Before my patch, sysdeps/mips/dl-procinfo.c contains those undefs at the
> end:
> #undef PROCINFO_DECL
> #undef PROCINFO_CLASS
> With my patch, the empty sysdeps/generic/dl-procinfo.c is used.
> 
> Thus we end up in:
> static int (*_dl_vdso_...) (...) RELRO;
> vs before:
> extern int (*_dl_vdso_...) (...) RELRO;
> 
> The latter builds fine, while the former produces the "defined but not
> used" warnings.
> 
> 
> Thus I will adjust my patch to keep sysdeps/mips/dl-procinfo.c with only
> something like this:
> /* Note:
>    When compiling elf/ldconfig.c, PROCINFO_CLASS is defined to static.
>    This dl-procinfo.c is included in sysdeps/generic/ldsodefs.h.
>    Afterwards, if not yet defined, PROCINFO_CLASS is defined to EXTERN
>    just before dl-vdso-setup.c is included.  A "static" _dl_vdso_xyz
>    function prototype would lead to gcc warnings/errors: defined but
>    not used.  */
> #undef PROCINFO_DECL
> #undef PROCINFO_CLASS
> 
> 
> My patch also removes sysdeps/alpha/dl-procinfo.c and
> sysdeps/csky/dl-procinfo.c with those #undef's at the end. But alpha and
> csky do not define the vdso HAVE_XYZ_VSYSCALL macros and thus do not end
> up with those errors.
> (At the end of dl-vdso-setup.c, PROCINFO_DECL and PROCINFO_CLASS are
> also undefined)
> 
> I run build-many-glibcs.py from scratch which lasts some time.
> Afterwards I'll send a V2 series.
> 
> Thanks,
> Stefan

I've successfully run build-many-glibcs.py from scratch - all PASSed -
and I send a V2 with the MIPS-fix:
[V2] elf: Remove platform strings in dl-procinfo.c
https://sourceware.org/pipermail/libc-alpha/2024-June/157391.html

Adhemerval has already reviewed the remaining patches. As soon as this
V2 is also reviewed, I can push the series.

Thanks,
Stefan
Stefan Liebler June 18, 2024, 8:55 a.m. UTC | #9
On 12.06.24 09:50, Stefan Liebler wrote:
> On 11.06.24 14:13, Stefan Liebler wrote:
>> On 10.06.24 15:36, Stefan Liebler wrote:
>>> On 08.06.24 13:09, Florian Weimer wrote:
>>>> * Stefan Liebler:
>>>>
>>>>> This patch series is the result of:
>>>>> "Question regarding platform-bits in ld.so.cache"
>>>>> https://sourceware.org/pipermail/libc-alpha/2024-May/156793.html
>>>>
>>>> This series fails to build on MIPS with:
>>>>
>>>> mips64-glibc-linux-gnu-gcc -mabi=32 ldconfig.c -c -std=gnu11 -fgnu89-inline  -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64   -fPIE    -Wa,-execstack -D'SYSCONFDIR="/etc"' -D'LIBDIR="/usr/lib"' -D'SLIBDIR="/lib"'       -I../include -I/home/bmg/build/glibcs/mips-linux-gnu/glibc/elf  -I/home/bmg/build/glibcs/mips-linux-gnu/glibc  -I../sysdeps/unix/sysv/linux/mips/mips32/fpu  -I../sysdeps/unix/sysv/linux/mips/mips32  -I../sysdeps/unix/sysv/linux/mips  -I../sysdeps/mips/nptl  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/mips/mips32  -I../sysdeps/unix/mips  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/mips/mips32/fpu  -I../sysdeps/mips/mips32  -I../sysdeps/mips/ieee754  -I../sysdeps/mips/include -I../sysdeps/mips  -I../sysdeps/ieee754/flt-32  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/wordsize-32  -I../sysdeps/mips/fpu  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I.   -D_LIBC_REENTRANT -include /home/bmg/build/glibcs/mips-linux-gnu/glibc/libc-modules.h -DMODULE_NAME=ldconfig -include ../include/libc-symbols.h  -DPIC     -DTOP_NAMESPACE=glibc -o /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o -MD -MP -MF /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o.dt -MT /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o
>>>> In file included from ../sysdeps/generic/ldsodefs.h:643,
>>>>                  from ../sysdeps/mips/ldsodefs.h:82,
>>>>                  from ../sysdeps/gnu/ldsodefs.h:46,
>>>>                  from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
>>>>                  from ../sysdeps/unix/sysv/linux/mips/ldsodefs.h:22,
>>>>                  from ../sysdeps/mips/dl-procinfo.h:22,
>>>>                  from /home/bmg/build/glibcs/mips-linux-gnu/glibc/dl-tunable-list.h:6,
>>>>                  from ../elf/dl-tunables.h:48,
>>>>                  from ./dl-hwcaps.h:25,
>>>>                  from ldconfig.c:44:
>>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:62:22: error: ‘_dl_vdso_clock_getres’ defined but not used [-Werror=unused-variable]
>>>>    62 | PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t,
>>>>       |                      ^~~~~~~~~~~~~~~~~~~~~
>>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:53:22: error: ‘_dl_vdso_gettimeofday’ defined but not used [-Werror=unused-variable]
>>>>    53 | PROCINFO_CLASS int (*_dl_vdso_gettimeofday) (struct timeval *, void *) RELRO;
>>>>       |                      ^~~~~~~~~~~~~~~~~~~~~
>>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:49:22: error: ‘_dl_vdso_clock_gettime64’ defined but not used [-Werror=unused-variable]
>>>>    49 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime64) (clockid_t,
>>>>       |                      ^~~~~~~~~~~~~~~~~~~~~~~~
>>>> ../sysdeps/unix/sysv/linux/dl-vdso-setup.c:45:22: error: ‘_dl_vdso_clock_gettime’ defined but not used [-Werror=unused-variable]
>>>>    45 | PROCINFO_CLASS int (*_dl_vdso_clock_gettime) (clockid_t,
>>>>       |                      ^~~~~~~~~~~~~~~~~~~~~~
>>>> cc1: all warnings being treated as errors
>>>> make[3]: *** [../o-iterator.mk:9: /home/bmg/build/glibcs/mips-linux-gnu/glibc/elf/ldconfig.o] Error 1
>>>> make[3]: Leaving directory '/home/bmg/src/glibc/elf'
>>>> make[3]: *** Waiting for unfinished jobs....
>>>> make[2]: *** [Makefile:484: elf/others] Error 2
>>>> make[1]: *** [Makefile:9: all] Error 2
>>>>
>>>> Florian
>>>>
>>> Hi Florian,
>>>
>>> thanks for the info. I've take a look. Seems to be related to the
>>> removed sysdeps/mips/dl-procinfo.c with those undefs at the end:
>>> #undef PROCINFO_DECL
>>> #undef PROCINFO_CLASS
>>>
>>> Bye,
>>> Stefan
>>
>> Okay, we have this chain:
>> - elf/ldconfig.c:
>> #define PROCINFO_CLASS static
>> #include <dl-hwcaps.h>
>> -> elf/dl-hwcaps.h
>> -> elf/dl-tunables.h
>> -> <build>/dl-tunable-list.h
>> -> sysdeps/mips/dl-procinfo.h:
>> -> sysdeps/unix/sysv/linux/mips/ldsodefs.h
>> -> sysdeps/unix/sysv/linux/ldsodefs.h:
>> -> sysdeps/gnu/ldsodefs.h
>> -> sysdeps/mips/ldsodefs.h
>> -> sysdeps/generic/ldsodefs.h:
>> ...
>> #include <dl-procinfo.c>
>> ...
>> # define PROCINFO_DECL
>> # ifndef PROCINFO_CLASS
>> #  define PROCINFO_CLASS EXTERN
>> # endif
>> # include <dl-vdso-setup.c>
>> ...
>>
>> Before my patch, sysdeps/mips/dl-procinfo.c contains those undefs at the
>> end:
>> #undef PROCINFO_DECL
>> #undef PROCINFO_CLASS
>> With my patch, the empty sysdeps/generic/dl-procinfo.c is used.
>>
>> Thus we end up in:
>> static int (*_dl_vdso_...) (...) RELRO;
>> vs before:
>> extern int (*_dl_vdso_...) (...) RELRO;
>>
>> The latter builds fine, while the former produces the "defined but not
>> used" warnings.
>>
>>
>> Thus I will adjust my patch to keep sysdeps/mips/dl-procinfo.c with only
>> something like this:
>> /* Note:
>>    When compiling elf/ldconfig.c, PROCINFO_CLASS is defined to static.
>>    This dl-procinfo.c is included in sysdeps/generic/ldsodefs.h.
>>    Afterwards, if not yet defined, PROCINFO_CLASS is defined to EXTERN
>>    just before dl-vdso-setup.c is included.  A "static" _dl_vdso_xyz
>>    function prototype would lead to gcc warnings/errors: defined but
>>    not used.  */
>> #undef PROCINFO_DECL
>> #undef PROCINFO_CLASS
>>
>>
>> My patch also removes sysdeps/alpha/dl-procinfo.c and
>> sysdeps/csky/dl-procinfo.c with those #undef's at the end. But alpha and
>> csky do not define the vdso HAVE_XYZ_VSYSCALL macros and thus do not end
>> up with those errors.
>> (At the end of dl-vdso-setup.c, PROCINFO_DECL and PROCINFO_CLASS are
>> also undefined)
>>
>> I run build-many-glibcs.py from scratch which lasts some time.
>> Afterwards I'll send a V2 series.
>>
>> Thanks,
>> Stefan
> 
> I've successfully run build-many-glibcs.py from scratch - all PASSed -
> and I send a V2 with the MIPS-fix:
> [V2] elf: Remove platform strings in dl-procinfo.c
> https://sourceware.org/pipermail/libc-alpha/2024-June/157391.html
> 
> Adhemerval has already reviewed the remaining patches. As soon as this
> V2 is also reviewed, I can push the series.
> 
> Thanks,
> Stefan

Adhemerval has also reviewed
[V2] elf: Remove platform strings in dl-procinfo.c

Thus I've committed the series.

Thanks,
Stefan