diff mbox series

[v2,4/6] powerpc64le: Use <gcc-macros.h> in early HWCAP check

Message ID 7540e03f5d1e4f301d53f755307d12f67eb17b0b.1642179009.git.fweimer@redhat.com
State New
Headers show
Series Reliable CPU compatibility diagnostics in ld.so | expand

Commit Message

Florian Weimer Jan. 14, 2022, 4:53 p.m. UTC
This is required so that the checks still work if $(early-cflags)
selects a different ISA level.
---
 sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Carlos O'Donell Jan. 14, 2022, 6:51 p.m. UTC | #1
On 1/14/22 11:53, Florian Weimer via Libc-alpha wrote:
> This is required so that the checks still work if $(early-cflags)
> selects a different ISA level.

LGTM. No regressions on x86_64 and i686 builders. No CI/CD regressions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 

There are a number of files we *might* have to wrap...

[carlos@athas glibc-pristine]$ grep -rl '_ARCH_PWR9' *
ChangeLog.old/ChangeLog.23
sysdeps/powerpc/fpu/fenv_libc.h
sysdeps/powerpc/fpu/math_private.h
sysdeps/powerpc/powerpc64/le/fpu/multiarch/float128-ifunc-redirect-macros.h
sysdeps/powerpc/powerpc64/le/fpu/e_sqrtf128.c
sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
sysdeps/powerpc/fpu_control.h
[carlos@athas glibc-pristine]$ vi sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
[carlos@athas glibc-pristine]$ grep -rl '_ARCH_PWR10' *
sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
[carlos@athas glibc-pristine]$ grep -rl '__FLOAT128_HARDWARE__' *
sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
[carlos@athas glibc-pristine]$ grep -rl '__PCREL__' *
sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
[carlos@athas glibc-pristine]$ grep -rl '__MMA__' *
sysdeps/powerpc/powerpc64/le/dl-hwcaps-subdirs.c
sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h

But the only one matters for early startup: dl-hwcap-check.h.


> diff --git a/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h b/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
> index 713a7f0313..b43c182683 100644
> --- a/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
> +++ b/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
> @@ -19,17 +19,18 @@
>  #ifndef _DL_HWCAP_CHECK_H
>  #define _DL_HWCAP_CHECK_H
>  
> +#include <gcc-macros.h>

OK. 5 macros need wrapping.

>  #include <ldsodefs.h>
>  
>  static inline void
>  dl_hwcap_check (void)
>  {
> -#ifdef _ARCH_PWR9
> +#ifdef GCCMACRO_ARCH_PWR9

OK. 1/5.

>    if ((GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_00) == 0)
>      _dl_fatal_printf ("\
>  Fatal glibc error: CPU lacks ISA 3.00 support (POWER9 or later required)\n");
>  #endif
> -#ifdef __FLOAT128_HARDWARE__
> +#ifdef GCCMACRO__FLOAT128_HARDWARE__

OK. 2/5.

>    if ((GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_IEEE128) == 0)
>      _dl_fatal_printf ("\
>  Fatal glibc error: CPU lacks float128 support (POWER 9 or later required)\n");
> @@ -37,12 +38,12 @@ Fatal glibc error: CPU lacks float128 support (POWER 9 or later required)\n");
>     /* This check is not actually reached when building for POWER10 and
>        running on POWER9 because there are faulting PCREL instructions
>        before this point.  */
> -#if defined _ARCH_PWR10 || defined __PCREL__
> +#if defined GCCMACRO_ARCH_PWR10 || defined GCCMACRO__PCREL__

OK. 3/5, 4/5.

>    if ((GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_1) == 0)
>      _dl_fatal_printf ("\
>  Fatal glibc error: CPU lacks ISA 3.10 support (POWER10 or later required)\n");
>  #endif
> -#ifdef __MMA__
> +#ifdef GCCMACRO__MMA__

OK. 5/5.

>    if ((GLRO (dl_hwcap2) & PPC_FEATURE2_MMA) == 0)
>      _dl_fatal_printf ("\
>  Fatal glibc error: CPU lacks MMA support (POWER10 or later required)\n");
diff mbox series

Patch

diff --git a/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h b/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
index 713a7f0313..b43c182683 100644
--- a/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
+++ b/sysdeps/powerpc/powerpc64/le/dl-hwcap-check.h
@@ -19,17 +19,18 @@ 
 #ifndef _DL_HWCAP_CHECK_H
 #define _DL_HWCAP_CHECK_H
 
+#include <gcc-macros.h>
 #include <ldsodefs.h>
 
 static inline void
 dl_hwcap_check (void)
 {
-#ifdef _ARCH_PWR9
+#ifdef GCCMACRO_ARCH_PWR9
   if ((GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_00) == 0)
     _dl_fatal_printf ("\
 Fatal glibc error: CPU lacks ISA 3.00 support (POWER9 or later required)\n");
 #endif
-#ifdef __FLOAT128_HARDWARE__
+#ifdef GCCMACRO__FLOAT128_HARDWARE__
   if ((GLRO (dl_hwcap2) & PPC_FEATURE2_HAS_IEEE128) == 0)
     _dl_fatal_printf ("\
 Fatal glibc error: CPU lacks float128 support (POWER 9 or later required)\n");
@@ -37,12 +38,12 @@  Fatal glibc error: CPU lacks float128 support (POWER 9 or later required)\n");
    /* This check is not actually reached when building for POWER10 and
       running on POWER9 because there are faulting PCREL instructions
       before this point.  */
-#if defined _ARCH_PWR10 || defined __PCREL__
+#if defined GCCMACRO_ARCH_PWR10 || defined GCCMACRO__PCREL__
   if ((GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_1) == 0)
     _dl_fatal_printf ("\
 Fatal glibc error: CPU lacks ISA 3.10 support (POWER10 or later required)\n");
 #endif
-#ifdef __MMA__
+#ifdef GCCMACRO__MMA__
   if ((GLRO (dl_hwcap2) & PPC_FEATURE2_MMA) == 0)
     _dl_fatal_printf ("\
 Fatal glibc error: CPU lacks MMA support (POWER10 or later required)\n");