[PATCH v4 10/12] math: Handle fabsf128 !__USE_EXTERN_INLINES

H.J. Lu hjl.tools@gmail.com
Wed Nov 12 22:24:59 GMT 2025


On Thu, Nov 13, 2025 at 2:47 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 10/11/25 22:51, H.J. Lu wrote:
> > On Mon, Nov 10, 2025 at 9:32 PM Adhemerval Zanella
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >> clang on x86_64 fails to build s_fabsf128.c with:
> >
> > Please mention
> >
> > This is one of the known clang limitation wrt inline function and
> > attribute definition,
> > where it does not allow to 'add' new attribute if a function is already defined:
>
> I changed to:
>
> --
> math: Handle fabsf128 !__USE_EXTERN_INLINES
>
> Work around the clang limitation wrt inline function and attribute
> definition, where it does not allow to 'add' new attribute if a
> function is already defined:
>
> clang on x86_64 fails to build s_fabsf128.c with:
>
> ../sysdeps/ieee754/float128/../ldbl-128/s_fabsl.c:32:1: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
>    32 | libm_alias_ldouble (__fabs, fabs)
>       | ^
> ../sysdeps/generic/libm-alias-ldouble.h:63:38: note: expanded from macro 'libm_alias_ldouble'
>    63 | #define libm_alias_ldouble(from, to) libm_alias_ldouble_r (from, to, )
>       |                                      ^
> ../sysdeps/ieee754/float128/float128_private.h:133:43: note: expanded from macro 'libm_alias_ldouble_r'
>   133 | #define libm_alias_ldouble_r(from, to, r) libm_alias_float128_r (from, to, r)
>       |                                           ^
> ../sysdeps/ieee754/float128/s_fabsf128.c:5:3: note: expanded from macro 'libm_alias_float128_r'
>     5 |   static_weak_alias (from ## f128 ## r, to ## f128 ## r);       \
>       |   ^
> ./../include/libc-symbols.h:166:46: note: expanded from macro 'static_weak_alias'
>   166 | #  define static_weak_alias(name, aliasname) weak_alias (name, aliasname)
>       |                                              ^
> ./../include/libc-symbols.h:154:38: note: expanded from macro 'weak_alias'
>   154 | # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
>       |                                      ^
> ./../include/libc-symbols.h:156:52: note: expanded from macro '_weak_alias'
>   156 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
>       |                                                    ^
> ../include/math.h:134:1: note: previous definition is here
>   134 | fabsf128 (_Float128 x)
>
> If compiler does not support __USE_EXTERN_INLINES we need to route
> fabsf128 call to an internal symbol.
> --
>
> Ok with this commit message change?>

Yes.

> >> ../sysdeps/ieee754/float128/../ldbl-128/s_fabsl.c:32:1: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
> >>    32 | libm_alias_ldouble (__fabs, fabs)
> >>       | ^
> >> ../sysdeps/generic/libm-alias-ldouble.h:63:38: note: expanded from macro 'libm_alias_ldouble'
> >>    63 | #define libm_alias_ldouble(from, to) libm_alias_ldouble_r (from, to, )
> >>       |                                      ^
> >> ../sysdeps/ieee754/float128/float128_private.h:133:43: note: expanded from macro 'libm_alias_ldouble_r'
> >>   133 | #define libm_alias_ldouble_r(from, to, r) libm_alias_float128_r (from, to, r)
> >>       |                                           ^
> >> ../sysdeps/ieee754/float128/s_fabsf128.c:5:3: note: expanded from macro 'libm_alias_float128_r'
> >>     5 |   static_weak_alias (from ## f128 ## r, to ## f128 ## r);       \
> >>       |   ^
> >> ./../include/libc-symbols.h:166:46: note: expanded from macro 'static_weak_alias'
> >>   166 | #  define static_weak_alias(name, aliasname) weak_alias (name, aliasname)
> >>       |                                              ^
> >> ./../include/libc-symbols.h:154:38: note: expanded from macro 'weak_alias'
> >>   154 | # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
> >>       |                                      ^
> >> ./../include/libc-symbols.h:156:52: note: expanded from macro '_weak_alias'
> >>   156 |   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
> >>       |                                                    ^
> >> ../include/math.h:134:1: note: previous definition is here
> >>   134 | fabsf128 (_Float128 x)
> >>
> >> If compiler does not support __USE_EXTERN_INLINES we need to route
> >> fabsf128 call to an internal symbol.
> >> ---
> >>  include/math.h                        | 11 ++++++++---
> >>  sysdeps/ieee754/float128/s_fabsf128.c |  3 +++
> >>  2 files changed, 11 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/math.h b/include/math.h
> >> index 84d44d44dc1..2565a4723ae 100644
> >> --- a/include/math.h
> >> +++ b/include/math.h
> >> @@ -114,9 +114,11 @@ __issignalingf (float x)
> >>
> >>  # if __HAVE_DISTINCT_FLOAT128
> >>
> >> +#  ifdef __USE_EXTERN_INLINES
> >> +
> >>  /* __builtin_isinf_sign is broken in GCC < 7 for float128.  */
> >> -#  if ! __GNUC_PREREQ (7, 0)
> >> -#   include <ieee754_float128.h>
> >> +#   if ! __GNUC_PREREQ (7, 0)
> >> +#    include <ieee754_float128.h>
> >>  extern inline int
> >>  __isinff128 (_Float128 x)
> >>  {
> >> @@ -126,13 +128,16 @@ __isinff128 (_Float128 x)
> >>    lx |= -lx;
> >>    return ~(lx >> 63) & (hx >> 62);
> >>  }
> >> -#  endif
> >> +#   endif
> >>
> >>  extern inline _Float128
> >>  fabsf128 (_Float128 x)
> >>  {
> >>    return __builtin_fabsf128 (x);
> >>  }
> >> +#  else
> >> +libm_hidden_proto (fabsf128)
> >> +#  endif
> >>  # endif
> >>
> >>
> >> diff --git a/sysdeps/ieee754/float128/s_fabsf128.c b/sysdeps/ieee754/float128/s_fabsf128.c
> >> index 2c1f277653e..9d64f150402 100644
> >> --- a/sysdeps/ieee754/float128/s_fabsf128.c
> >> +++ b/sysdeps/ieee754/float128/s_fabsf128.c
> >> @@ -6,3 +6,6 @@
> >>    libm_alias_float128_other_r (from, to, r)
> >>  #endif
> >>  #include "../ldbl-128/s_fabsl.c"
> >> +#ifndef __USE_EXTERN_INLINES
> >> +libm_hidden_def (fabsf128)
> >> +#endif
> >> --
> >> 2.43.0
> >>
> >
> >
>


-- 
H.J.


More information about the Libc-alpha mailing list