diff mbox series

[v3,2/7] math: Fix i386 and m68k fmod/fmodf on static build (BZ 31488)

Message ID 20240402140644.2172819-3-adhemerval.zanella@linaro.org
State New
Headers show
Series Fix some libm static issues | expand

Commit Message

Adhemerval Zanella Netto April 2, 2024, 2:06 p.m. UTC
The commit 16439f419b removed the static fmod/fmodf on i386 and m68k
with and empty w_fmod.c (required for the ABIs that uses the newly
implementation).  This patch fixes by adding the required symbols on
the arch-specific w_fmod{f}_compat.c implementation.

To statically build fmod fails on some ABI (alpha, s390, sparc) because
it does not export the ldexpf128, this is also fixed by this patch.

Checked on i686-linux-gnu and with a build for m68k-linux-gnu with
'make test t=math/test-{float,double}-modf-static build-math-static-tests=yes'.
---
 sysdeps/i386/fpu/w_fmod_compat.c         | 7 ++++---
 sysdeps/i386/fpu/w_fmodf_compat.c        | 7 ++++---
 sysdeps/ieee754/ldbl-opt/s_ldexpl.c      | 4 ++--
 sysdeps/m68k/m680x0/fpu/w_fmod_compat.c  | 5 +++--
 sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c | 7 ++++---
 5 files changed, 17 insertions(+), 13 deletions(-)

Comments

Aurelien Jarno May 11, 2024, 9:59 a.m. UTC | #1
On 2024-04-02 11:06, Adhemerval Zanella wrote:
> The commit 16439f419b removed the static fmod/fmodf on i386 and m68k
> with and empty w_fmod.c (required for the ABIs that uses the newly
> implementation).  This patch fixes by adding the required symbols on
> the arch-specific w_fmod{f}_compat.c implementation.
> 
> To statically build fmod fails on some ABI (alpha, s390, sparc) because
> it does not export the ldexpf128, this is also fixed by this patch.
> 
> Checked on i686-linux-gnu and with a build for m68k-linux-gnu with
> 'make test t=math/test-{float,double}-modf-static build-math-static-tests=yes'.
> ---
>  sysdeps/i386/fpu/w_fmod_compat.c         | 7 ++++---
>  sysdeps/i386/fpu/w_fmodf_compat.c        | 7 ++++---
>  sysdeps/ieee754/ldbl-opt/s_ldexpl.c      | 4 ++--
>  sysdeps/m68k/m680x0/fpu/w_fmod_compat.c  | 5 +++--
>  sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c | 7 ++++---
>  5 files changed, 17 insertions(+), 13 deletions(-)

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
H.J. Lu May 21, 2024, 12:40 p.m. UTC | #2
On Tue, Apr 2, 2024 at 7:06 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> The commit 16439f419b removed the static fmod/fmodf on i386 and m68k
> with and empty w_fmod.c (required for the ABIs that uses the newly
> implementation).  This patch fixes by adding the required symbols on
> the arch-specific w_fmod{f}_compat.c implementation.
>
> To statically build fmod fails on some ABI (alpha, s390, sparc) because
> it does not export the ldexpf128, this is also fixed by this patch.
>
> Checked on i686-linux-gnu and with a build for m68k-linux-gnu with
> 'make test t=math/test-{float,double}-modf-static build-math-static-tests=yes'.
> ---
>  sysdeps/i386/fpu/w_fmod_compat.c         | 7 ++++---
>  sysdeps/i386/fpu/w_fmodf_compat.c        | 7 ++++---
>  sysdeps/ieee754/ldbl-opt/s_ldexpl.c      | 4 ++--
>  sysdeps/m68k/m680x0/fpu/w_fmod_compat.c  | 5 +++--
>  sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c | 7 ++++---
>  5 files changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/sysdeps/i386/fpu/w_fmod_compat.c b/sysdeps/i386/fpu/w_fmod_compat.c
> index 5ac9995ffd..528bfc2a13 100644
> --- a/sysdeps/i386/fpu/w_fmod_compat.c
> +++ b/sysdeps/i386/fpu/w_fmod_compat.c
> @@ -7,8 +7,9 @@
>  # define LIBM_SVID_COMPAT 1
>  # undef compat_symbol
>  # define compat_symbol(a, b, c, d)
> -#endif
> -#include <math/w_fmod_compat.c>
> -#ifdef SHARED
> +# include <math/w_fmod_compat.c>
>  libm_alias_double (__fmod_compat, fmod)
> +#else
> +#include <math-type-macros-double.h>
> +#include <w_fmod_template.c>
>  #endif
> diff --git a/sysdeps/i386/fpu/w_fmodf_compat.c b/sysdeps/i386/fpu/w_fmodf_compat.c
> index cc417e07d3..5a61693e51 100644
> --- a/sysdeps/i386/fpu/w_fmodf_compat.c
> +++ b/sysdeps/i386/fpu/w_fmodf_compat.c
> @@ -7,8 +7,9 @@
>  # define LIBM_SVID_COMPAT 1
>  # undef compat_symbol
>  # define compat_symbol(a, b, c, d)
> -#endif
> -#include <math/w_fmodf_compat.c>
> -#ifdef SHARED
> +# include <math/w_fmodf_compat.c>
>  libm_alias_float (__fmod_compat, fmod)
> +#else
> +#include <math-type-macros-float.h>
> +#include <w_fmod_template.c>
>  #endif
> diff --git a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
> index 1afbe7d8ad..932cc4341c 100644
> --- a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
> +++ b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
> @@ -17,13 +17,13 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> -#if IS_IN (libc)
> +#if IS_IN (libc) && defined SHARED
>  # define declare_mgen_alias(f,t)
>  #endif
>  #include <math-type-macros-ldouble.h>
>  #include <s_ldexp_template.c>
>
> -#if IS_IN (libc)
> +#if IS_IN (libc) && defined SHARED
>  long_double_symbol (libc, __ldexpl, ldexpl);
>  long_double_symbol (libc, __wrap_scalbnl, scalbnl);
>  #endif
> diff --git a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
> index 527d4fbed2..57f38091e6 100644
> --- a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
> +++ b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
> @@ -7,8 +7,9 @@
>  # define LIBM_SVID_COMPAT 1
>  # undef compat_symbol
>  # define compat_symbol(a, b, c, d)
> -#endif
>  #include <math/w_fmod_compat.c>
> -#ifdef SHARED
>  libm_alias_double (__fmod_compat, fmod)
> +#else
> +#include <math-type-macros-double.h>
> +#include <w_fmod_template.c>
>  #endif
> diff --git a/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
> index 5043586b91..88db07f443 100644
> --- a/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
> +++ b/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
> @@ -7,8 +7,9 @@
>  # define LIBM_SVID_COMPAT 1
>  # undef compat_symbol
>  # define compat_symbol(a, b, c, d)
> -#endif
> -#include <math/w_fmodf_compat.c>
> -#ifdef SHARED
> +# include <math/w_fmodf_compat.c>
>  libm_alias_float (__fmod_compat, fmod)
> +#else
> +#include <math-type-macros-float.h>
> +#include <w_fmod_template.c>
>  #endif
> --
> 2.34.1
>

My WIP static ABI check identified exp10 exp10f32x exp10f64 fmod fmodf fmodf32
fmodf32x fmodf64 are missing in i386 libm.a:

https://sourceware.org/bugzilla/show_bug.cgi?id=31775

Does your patch fix all of them?
Adhemerval Zanella Netto May 21, 2024, 12:54 p.m. UTC | #3
On 21/05/24 09:40, H.J. Lu wrote:
> On Tue, Apr 2, 2024 at 7:06 AM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> The commit 16439f419b removed the static fmod/fmodf on i386 and m68k
>> with and empty w_fmod.c (required for the ABIs that uses the newly
>> implementation).  This patch fixes by adding the required symbols on
>> the arch-specific w_fmod{f}_compat.c implementation.
>>
>> To statically build fmod fails on some ABI (alpha, s390, sparc) because
>> it does not export the ldexpf128, this is also fixed by this patch.
>>
>> Checked on i686-linux-gnu and with a build for m68k-linux-gnu with
>> 'make test t=math/test-{float,double}-modf-static build-math-static-tests=yes'.
>> ---
>>  sysdeps/i386/fpu/w_fmod_compat.c         | 7 ++++---
>>  sysdeps/i386/fpu/w_fmodf_compat.c        | 7 ++++---
>>  sysdeps/ieee754/ldbl-opt/s_ldexpl.c      | 4 ++--
>>  sysdeps/m68k/m680x0/fpu/w_fmod_compat.c  | 5 +++--
>>  sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c | 7 ++++---
>>  5 files changed, 17 insertions(+), 13 deletions(-)
>>
>> diff --git a/sysdeps/i386/fpu/w_fmod_compat.c b/sysdeps/i386/fpu/w_fmod_compat.c
>> index 5ac9995ffd..528bfc2a13 100644
>> --- a/sysdeps/i386/fpu/w_fmod_compat.c
>> +++ b/sysdeps/i386/fpu/w_fmod_compat.c
>> @@ -7,8 +7,9 @@
>>  # define LIBM_SVID_COMPAT 1
>>  # undef compat_symbol
>>  # define compat_symbol(a, b, c, d)
>> -#endif
>> -#include <math/w_fmod_compat.c>
>> -#ifdef SHARED
>> +# include <math/w_fmod_compat.c>
>>  libm_alias_double (__fmod_compat, fmod)
>> +#else
>> +#include <math-type-macros-double.h>
>> +#include <w_fmod_template.c>
>>  #endif
>> diff --git a/sysdeps/i386/fpu/w_fmodf_compat.c b/sysdeps/i386/fpu/w_fmodf_compat.c
>> index cc417e07d3..5a61693e51 100644
>> --- a/sysdeps/i386/fpu/w_fmodf_compat.c
>> +++ b/sysdeps/i386/fpu/w_fmodf_compat.c
>> @@ -7,8 +7,9 @@
>>  # define LIBM_SVID_COMPAT 1
>>  # undef compat_symbol
>>  # define compat_symbol(a, b, c, d)
>> -#endif
>> -#include <math/w_fmodf_compat.c>
>> -#ifdef SHARED
>> +# include <math/w_fmodf_compat.c>
>>  libm_alias_float (__fmod_compat, fmod)
>> +#else
>> +#include <math-type-macros-float.h>
>> +#include <w_fmod_template.c>
>>  #endif
>> diff --git a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
>> index 1afbe7d8ad..932cc4341c 100644
>> --- a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
>> +++ b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
>> @@ -17,13 +17,13 @@
>>     License along with the GNU C Library; if not, see
>>     <https://www.gnu.org/licenses/>.  */
>>
>> -#if IS_IN (libc)
>> +#if IS_IN (libc) && defined SHARED
>>  # define declare_mgen_alias(f,t)
>>  #endif
>>  #include <math-type-macros-ldouble.h>
>>  #include <s_ldexp_template.c>
>>
>> -#if IS_IN (libc)
>> +#if IS_IN (libc) && defined SHARED
>>  long_double_symbol (libc, __ldexpl, ldexpl);
>>  long_double_symbol (libc, __wrap_scalbnl, scalbnl);
>>  #endif
>> diff --git a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
>> index 527d4fbed2..57f38091e6 100644
>> --- a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
>> +++ b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
>> @@ -7,8 +7,9 @@
>>  # define LIBM_SVID_COMPAT 1
>>  # undef compat_symbol
>>  # define compat_symbol(a, b, c, d)
>> -#endif
>>  #include <math/w_fmod_compat.c>
>> -#ifdef SHARED
>>  libm_alias_double (__fmod_compat, fmod)
>> +#else
>> +#include <math-type-macros-double.h>
>> +#include <w_fmod_template.c>
>>  #endif
>> diff --git a/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
>> index 5043586b91..88db07f443 100644
>> --- a/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
>> +++ b/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
>> @@ -7,8 +7,9 @@
>>  # define LIBM_SVID_COMPAT 1
>>  # undef compat_symbol
>>  # define compat_symbol(a, b, c, d)
>> -#endif
>> -#include <math/w_fmodf_compat.c>
>> -#ifdef SHARED
>> +# include <math/w_fmodf_compat.c>
>>  libm_alias_float (__fmod_compat, fmod)
>> +#else
>> +#include <math-type-macros-float.h>
>> +#include <w_fmod_template.c>
>>  #endif
>> --
>> 2.34.1
>>
> 
> My WIP static ABI check identified exp10 exp10f32x exp10f64 fmod fmodf fmodf32
> fmodf32x fmodf64 are missing in i386 libm.a:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=31775
> 
> Does your patch fix all of them?
> 

Yes, that the idea of this patchset:

i686-linux-gnu$ readelf -sW math/libm.a | grep -E -w 'exp10|exp10f32x|exp10f64|fmod|fmodf|fmodf32|fmodf32x|fmodf64'
    17: 00000000   160 FUNC    WEAK   DEFAULT    2 exp10f32x
    18: 00000000   160 FUNC    WEAK   DEFAULT    2 exp10f64
    19: 00000000   160 FUNC    WEAK   DEFAULT    2 exp10
    17: 00000000   140 FUNC    WEAK   DEFAULT    2 fmodf32x
    18: 00000000   140 FUNC    WEAK   DEFAULT    2 fmodf64
    19: 00000000   140 FUNC    WEAK   DEFAULT    2 fmod
    17: 00000000   140 FUNC    WEAK   DEFAULT    2 fmodf32
    18: 00000000   140 FUNC    WEAK   DEFAULT    2 fmodf
diff mbox series

Patch

diff --git a/sysdeps/i386/fpu/w_fmod_compat.c b/sysdeps/i386/fpu/w_fmod_compat.c
index 5ac9995ffd..528bfc2a13 100644
--- a/sysdeps/i386/fpu/w_fmod_compat.c
+++ b/sysdeps/i386/fpu/w_fmod_compat.c
@@ -7,8 +7,9 @@ 
 # define LIBM_SVID_COMPAT 1
 # undef compat_symbol
 # define compat_symbol(a, b, c, d)
-#endif
-#include <math/w_fmod_compat.c>
-#ifdef SHARED
+# include <math/w_fmod_compat.c>
 libm_alias_double (__fmod_compat, fmod)
+#else
+#include <math-type-macros-double.h>
+#include <w_fmod_template.c>
 #endif
diff --git a/sysdeps/i386/fpu/w_fmodf_compat.c b/sysdeps/i386/fpu/w_fmodf_compat.c
index cc417e07d3..5a61693e51 100644
--- a/sysdeps/i386/fpu/w_fmodf_compat.c
+++ b/sysdeps/i386/fpu/w_fmodf_compat.c
@@ -7,8 +7,9 @@ 
 # define LIBM_SVID_COMPAT 1
 # undef compat_symbol
 # define compat_symbol(a, b, c, d)
-#endif
-#include <math/w_fmodf_compat.c>
-#ifdef SHARED
+# include <math/w_fmodf_compat.c>
 libm_alias_float (__fmod_compat, fmod)
+#else
+#include <math-type-macros-float.h>
+#include <w_fmod_template.c>
 #endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
index 1afbe7d8ad..932cc4341c 100644
--- a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
+++ b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
@@ -17,13 +17,13 @@ 
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#if IS_IN (libc)
+#if IS_IN (libc) && defined SHARED
 # define declare_mgen_alias(f,t)
 #endif
 #include <math-type-macros-ldouble.h>
 #include <s_ldexp_template.c>
 
-#if IS_IN (libc)
+#if IS_IN (libc) && defined SHARED
 long_double_symbol (libc, __ldexpl, ldexpl);
 long_double_symbol (libc, __wrap_scalbnl, scalbnl);
 #endif
diff --git a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
index 527d4fbed2..57f38091e6 100644
--- a/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
+++ b/sysdeps/m68k/m680x0/fpu/w_fmod_compat.c
@@ -7,8 +7,9 @@ 
 # define LIBM_SVID_COMPAT 1
 # undef compat_symbol
 # define compat_symbol(a, b, c, d)
-#endif
 #include <math/w_fmod_compat.c>
-#ifdef SHARED
 libm_alias_double (__fmod_compat, fmod)
+#else
+#include <math-type-macros-double.h>
+#include <w_fmod_template.c>
 #endif
diff --git a/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c b/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
index 5043586b91..88db07f443 100644
--- a/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
+++ b/sysdeps/m68k/m680x0/fpu/w_fmodf_compat.c
@@ -7,8 +7,9 @@ 
 # define LIBM_SVID_COMPAT 1
 # undef compat_symbol
 # define compat_symbol(a, b, c, d)
-#endif
-#include <math/w_fmodf_compat.c>
-#ifdef SHARED
+# include <math/w_fmodf_compat.c>
 libm_alias_float (__fmod_compat, fmod)
+#else
+#include <math-type-macros-float.h>
+#include <w_fmod_template.c>
 #endif