Fix ifunc-impl-list.c build for s390

Message ID 4e5aeda7-899e-5bc6-b2d-c9e2359f4e3@codesourcery.com
State Committed
Commit 609054152fd77c9b572bb04c4af2f8da1ed0c86e
Headers
Series Fix ifunc-impl-list.c build for s390 |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Joseph Myers Feb. 16, 2023, 9:39 p.m. UTC
  Builds for s390 recently started failing with:

../sysdeps/s390/multiarch/ifunc-impl-list.c: In function '__libc_ifunc_impl_list':
../sysdeps/s390/multiarch/ifunc-impl-list.c:83:21: error: unused variable 'dl_hwcap' [-Werror=unused-variable]
   83 |   unsigned long int dl_hwcap = features->hwcap;
      |                     ^~~~~~~~

https://sourceware.org/pipermail/libc-testresults/2023q1/010855.html

Add __attribute__ ((unused)) as already done for another variable
there.

Tested with build-many-glibcs.py (compilers and glibcs) for
s390x-linux-gnu and s390-linux-gnu.

Note: s390x-linux-gnu-O3 started failing with a different error
earlier; that problem may still need to be fixed after this fix is in.

https://sourceware.org/pipermail/libc-testresults/2023q1/010829.html
  

Comments

Stefan Liebler Feb. 17, 2023, 1:46 p.m. UTC | #1
On 16.02.23 22:39, Joseph Myers wrote:
> Builds for s390 recently started failing with:
> 
> ../sysdeps/s390/multiarch/ifunc-impl-list.c: In function '__libc_ifunc_impl_list':
> ../sysdeps/s390/multiarch/ifunc-impl-list.c:83:21: error: unused variable 'dl_hwcap' [-Werror=unused-variable]
>    83 |   unsigned long int dl_hwcap = features->hwcap;
>       |                     ^~~~~~~~
> 
> https://sourceware.org/pipermail/libc-testresults/2023q1/010855.html
> 
> Add __attribute__ ((unused)) as already done for another variable
> there.
> 
> Tested with build-many-glibcs.py (compilers and glibcs) for
> s390x-linux-gnu and s390-linux-gnu.
> 
Thanks Joseph for catching it. In case of building with latest -march
argument, I've removed the last user with my recent commit:
"S390: Influence hwcaps/stfle via GLIBC_TUNABLES."
https://sourceware.org/git/?p=glibc.git;a=commit;h=41f67ccbe92b4fd09e1062b383e55e407ae5bfa1

Reviewed-by: Stefan Liebler <stli@linux.ibm.com>

> Note: s390x-linux-gnu-O3 started failing with a different error
> earlier; that problem may still need to be fixed after this fix is in.
> 
> https://sourceware.org/pipermail/libc-testresults/2023q1/010829.html
> 
I will have a look. Independently I've recognized a fail on x86_64/s390x
with -O3 starting with commit 32c7acd46401530fdbd4e98508c9baaa705f8b53
"Replace rawmemchr (s, '\0') with strchr":
In function ‘nis_local_host’,
    inlined from ‘nis_local_host’ at nis_local_names.c:147:1:
nis_local_names.c:171:11: error: ‘strncpy’ output may be truncated
copying between 0 and 1023 bytes from a string of length 1024
[-Werror=stringop-truncation]
  171 |           strncpy (cp, nis_local_directory (), NIS_MAXNAMELEN -
len -1);

But so far I had no further time to look into it.

> diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
> index 1532258af2..faa428f9ab 100644
> --- a/sysdeps/s390/multiarch/ifunc-impl-list.c
> +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
> @@ -80,7 +80,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
> 
>    /* Get hardware information.  */
>    const struct cpu_features *features = &GLRO(dl_s390_cpu_features);
> -  unsigned long int dl_hwcap = features->hwcap;
> +  unsigned long int dl_hwcap __attribute__ ((unused)) = features->hwcap;
>    const unsigned long long * __attribute__((unused)) stfle_bits
>      = features->stfle_bits;
> 
>
  
Stefan Liebler Feb. 28, 2023, 12:44 p.m. UTC | #2
On 17.02.23 14:46, Stefan Liebler via Libc-alpha wrote:
>> Note: s390x-linux-gnu-O3 started failing with a different error
>> earlier; that problem may still need to be fixed after this fix is in.
>>
>> https://sourceware.org/pipermail/libc-testresults/2023q1/010829.html
>>
> I will have a look. Independently I've recognized a fail on x86_64/s390x
> with -O3 starting with commit 32c7acd46401530fdbd4e98508c9baaa705f8b53
> "Replace rawmemchr (s, '\0') with strchr":
> In function ‘nis_local_host’,
>     inlined from ‘nis_local_host’ at nis_local_names.c:147:1:
> nis_local_names.c:171:11: error: ‘strncpy’ output may be truncated
> copying between 0 and 1023 bytes from a string of length 1024
> [-Werror=stringop-truncation]
>   171 |           strncpy (cp, nis_local_directory (), NIS_MAXNAMELEN -
> len -1);
> 
> But so far I had no further time to look into it.
Hi Joseph,
I've posted a patch to fix the earlier error with -O3.
The same error is also observable with x86_64 -O3, but s390x is the only
architecture in the build-many-script which also builds with -O3 as gcc
tends to inline more than on other architectures.

Please have a look here:
[PATCH] nis: Fix stringop-truncation warning with -O3 in nis_local_host.
https://sourceware.org/pipermail/libc-alpha/2023-February/145923.html
  

Patch

diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
index 1532258af2..faa428f9ab 100644
--- a/sysdeps/s390/multiarch/ifunc-impl-list.c
+++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
@@ -80,7 +80,7 @@  __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
 
   /* Get hardware information.  */
   const struct cpu_features *features = &GLRO(dl_s390_cpu_features);
-  unsigned long int dl_hwcap = features->hwcap;
+  unsigned long int dl_hwcap __attribute__ ((unused)) = features->hwcap;
   const unsigned long long * __attribute__((unused)) stfle_bits
     = features->stfle_bits;