[6/6] elf: Simplify output of hwcap subdirectories in ld.so help

Message ID 20220914201509.1c642836df76f95d3c2a8f28@otheo.eu
State Superseded
Headers
Series Remove legacy hwcaps support |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit fail Patch caused testsuite regressions

Commit Message

Javier Pello Sept. 14, 2022, 6:15 p.m. UTC
  The print_hwcap_1 machinery was useful for the legacy hwcaps
subdirectories, but it is not worth the trouble now that they
are gone.

Signed-off-by: Javier Pello <devel@otheo.eu>
---
 elf/dl-usage.c | 43 +++++++------------------------------------
 1 file changed, 7 insertions(+), 36 deletions(-)
  

Comments

Carlos O'Donell Sept. 15, 2022, 8:42 a.m. UTC | #1
On Wed, Sep 14, 2022 at 08:15:09PM +0200, Javier Pello wrote:
> The print_hwcap_1 machinery was useful for the legacy hwcaps
> subdirectories, but it is not worth the trouble now that they
> are gone.

This fails pre-commit CI for i686:
https://patchwork.sourceware.org/project/glibc/patch/20220914201509.1c642836df76f95d3c2a8f28@otheo.eu/

Which architectures have you tested this on?

> Signed-off-by: Javier Pello <devel@otheo.eu>
> ---
>  elf/dl-usage.c | 43 +++++++------------------------------------
>  1 file changed, 7 insertions(+), 36 deletions(-)
> 
> diff --git a/elf/dl-usage.c b/elf/dl-usage.c
> index efd6c77c..754a6391 100644
> --- a/elf/dl-usage.c
> +++ b/elf/dl-usage.c
> @@ -104,34 +104,6 @@ print_search_path_for_help (struct dl_main_state *state)
>    print_search_path_for_help_1 (__rtld_search_dirs.dirs);
>  }
>  
> -/* Helper function for printing flags associated with a HWCAP name.  */
> -static void
> -print_hwcap_1 (bool *first, bool active, const char *label)
> -{
> -  if (active)
> -    {
> -      if (*first)
> -        {
> -          _dl_printf (" (");
> -          *first = false;
> -        }
> -      else
> -        _dl_printf (", ");
> -      _dl_printf ("%s", label);
> -    }
> -}
> -
> -/* Called after a series of print_hwcap_1 calls to emit the line
> -   terminator.  */
> -static void
> -print_hwcap_1_finish (bool *first)
> -{
> -  if (*first)
> -    _dl_printf ("\n");
> -  else
> -    _dl_printf (")\n");
> -}
> -
>  /* Print the header for print_hwcaps_subdirectories.  */
>  static void
>  print_hwcaps_subdirectories_header (bool *nothing_printed)
> @@ -165,9 +137,7 @@ print_hwcaps_subdirectories (const struct dl_main_state *state)
>      {
>        print_hwcaps_subdirectories_header (&nothing_printed);
>        print_hwcaps_subdirectories_name (&split);
> -      bool first = true;
> -      print_hwcap_1 (&first, true, "searched");
> -      print_hwcap_1_finish (&first);
> +      _dl_printf (" (searched)\n");
>      }
>  
>    /* The built-in glibc-hwcaps subdirectories.  Do the filtering
> @@ -178,13 +148,14 @@ print_hwcaps_subdirectories (const struct dl_main_state *state)
>      {
>        print_hwcaps_subdirectories_header (&nothing_printed);
>        print_hwcaps_subdirectories_name (&split);
> -      bool first = true;
> -      print_hwcap_1 (&first, mask & 1, "supported");
>        bool listed = _dl_hwcaps_contains (state->glibc_hwcaps_mask,
>                                           split.segment, split.length);
> -      print_hwcap_1 (&first, !listed, "masked");
> -      print_hwcap_1 (&first, (mask & 1) && listed, "searched");
> -      print_hwcap_1_finish (&first);
> +      if (mask & 1)
> +        _dl_printf (" (supported, %s)\n", listed ? "searched" : "masked");
> +      else if (!listed)
> +        _dl_printf (" (masked)\n");
> +      else
> +        _dl_printf ("\n");
>        mask >>= 1;
>      }
>  
> -- 
> 2.36.0
>
  
Javier Pello Sept. 15, 2022, 7:12 p.m. UTC | #2
On Thu, 15 Sep 2022 04:42:36 -0400, Carlos O'Donell wrote:

> On Wed, Sep 14, 2022 at 08:15:09PM +0200, Javier Pello wrote:
> > The print_hwcap_1 machinery was useful for the legacy hwcaps
> > subdirectories, but it is not worth the trouble now that they
> > are gone.
> 
> This fails pre-commit CI for i686:
> https://patchwork.sourceware.org/project/glibc/patch/20220914201509.1c642836df76f95d3c2a8f28@otheo.eu/

And spectacularly so, it seems.

> Which architectures have you tested this on?

On i686, ironically. And the output from make check looks fine on
my end.

I am puzzled. The output from CI suggests that the compiled libc.so
cannot be loaded, but the last patch only inlines two static
functions, only used for the output of ld.so --help. I cannot see
why the patch series would be fine after patch 5 but fail this way
after patch 6.

I will try to look into this.

Javier
  

Patch

diff --git a/elf/dl-usage.c b/elf/dl-usage.c
index efd6c77c..754a6391 100644
--- a/elf/dl-usage.c
+++ b/elf/dl-usage.c
@@ -104,34 +104,6 @@  print_search_path_for_help (struct dl_main_state *state)
   print_search_path_for_help_1 (__rtld_search_dirs.dirs);
 }
 
-/* Helper function for printing flags associated with a HWCAP name.  */
-static void
-print_hwcap_1 (bool *first, bool active, const char *label)
-{
-  if (active)
-    {
-      if (*first)
-        {
-          _dl_printf (" (");
-          *first = false;
-        }
-      else
-        _dl_printf (", ");
-      _dl_printf ("%s", label);
-    }
-}
-
-/* Called after a series of print_hwcap_1 calls to emit the line
-   terminator.  */
-static void
-print_hwcap_1_finish (bool *first)
-{
-  if (*first)
-    _dl_printf ("\n");
-  else
-    _dl_printf (")\n");
-}
-
 /* Print the header for print_hwcaps_subdirectories.  */
 static void
 print_hwcaps_subdirectories_header (bool *nothing_printed)
@@ -165,9 +137,7 @@  print_hwcaps_subdirectories (const struct dl_main_state *state)
     {
       print_hwcaps_subdirectories_header (&nothing_printed);
       print_hwcaps_subdirectories_name (&split);
-      bool first = true;
-      print_hwcap_1 (&first, true, "searched");
-      print_hwcap_1_finish (&first);
+      _dl_printf (" (searched)\n");
     }
 
   /* The built-in glibc-hwcaps subdirectories.  Do the filtering
@@ -178,13 +148,14 @@  print_hwcaps_subdirectories (const struct dl_main_state *state)
     {
       print_hwcaps_subdirectories_header (&nothing_printed);
       print_hwcaps_subdirectories_name (&split);
-      bool first = true;
-      print_hwcap_1 (&first, mask & 1, "supported");
       bool listed = _dl_hwcaps_contains (state->glibc_hwcaps_mask,
                                          split.segment, split.length);
-      print_hwcap_1 (&first, !listed, "masked");
-      print_hwcap_1 (&first, (mask & 1) && listed, "searched");
-      print_hwcap_1_finish (&first);
+      if (mask & 1)
+        _dl_printf (" (supported, %s)\n", listed ? "searched" : "masked");
+      else if (!listed)
+        _dl_printf (" (masked)\n");
+      else
+        _dl_printf ("\n");
       mask >>= 1;
     }