]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
9 days agomalloc: Extend malloc function hiding to tst-pvalloc azanella/clang
Adhemerval Zanella [Thu, 16 Oct 2025 18:24:20 +0000 (15:24 -0300)] 
malloc: Extend malloc function hiding to tst-pvalloc

clang 21 optimize-out pvalloc.

9 days agostdlib: Avoid stpcpy plt with clang
Adhemerval Zanella [Tue, 13 May 2025 13:19:49 +0000 (10:19 -0300)] 
stdlib: Avoid stpcpy plt with clang

9 days agostdlib: Avoid strlen plt with clang
Adhemerval Zanella [Mon, 7 Apr 2025 20:32:08 +0000 (17:32 -0300)] 
stdlib: Avoid strlen plt with clang

9 days agobench-malloc-thread: Add libm for powf
Adhemerval Zanella [Tue, 6 Feb 2024 19:52:45 +0000 (16:52 -0300)] 
bench-malloc-thread: Add libm for powf

The bench-malloc-thread.c:63 does use powf and compiler might not
optimzie it away.

9 days agobenchtests: Remove clang warnings
Adhemerval Zanella [Tue, 6 Feb 2024 19:52:17 +0000 (16:52 -0300)] 
benchtests: Remove clang warnings

clangs warns of the implicit cast of RAND_MAX to float:

  error: implicit conversion from 'int' to 'float' changes value from
  2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]

So make it explicit.

9 days agobenchtests: Use __f128 on ilogbf128-inputs constants
Adhemerval Zanella [Tue, 6 Feb 2024 19:51:45 +0000 (16:51 -0300)] 
benchtests: Use __f128 on ilogbf128-inputs constants

The f128 is not a valid floating constant suffix on clang.

9 days agobenchtests: Add attribute_optimize
Adhemerval Zanella [Tue, 6 Feb 2024 19:51:25 +0000 (16:51 -0300)] 
benchtests: Add attribute_optimize

Similar to tst-printf-bz18872.sh, add the attribute_optimize to avoid
build failures with compilers that do not support "GCC optimize" pragma.

9 days agox86_64: Fix mark-plt configure test
Adhemerval Zanella [Fri, 9 Feb 2024 16:36:22 +0000 (13:36 -0300)] 
x86_64: Fix mark-plt configure test

The configure check might ignore if compiler driver warns that the
option is no support, so force fatal warnings.

If fixes the elf/tst-plt-rewrite regressions when ld.lld is used.

9 days agomath: Fix potential underflow on ldbl-128 erfl
Adhemerval Zanella [Tue, 30 Jan 2024 13:45:14 +0000 (13:45 +0000)] 
math: Fix potential underflow on ldbl-128 erfl

The multiplication is only required if the branch is taken, and the
compiler might not optimize it away.

If fixes the following issues when testcase is built with clang:

FAIL: math/test-ldouble-erf
Failure: erf (-0x4p-16384): Exception "Underflow" set
Failure: erf (0x1p-10000): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf (0x4p-16384): Exception "Underflow" set
Failure: erf_downward (-0x4p-16384): Exception "Underflow" set
Failure: erf_downward (0x1p-10000): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf_downward (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf_downward (0x4p-16384): Exception "Underflow" set
Failure: erf_towardzero (-0x4p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x1p-10000): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf_towardzero (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf_towardzero (0x4p-16384): Exception "Underflow" set
Failure: erf_upward (-0x4p-16384): Exception "Underflow" set
Failure: erf_upward (0x1p-10000): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f38760a41abb84p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f38760a41abb88p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f4p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded54f8p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded5518p-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded551cp-16384): Exception "Underflow" set
Failure: erf_upward (0x3.8b7f12369ded552p-16384): Exception "Underflow" set
Failure: erf_upward (0x4p-16384): Exception "Underflow" set

Checked on aarch64-linux-gnu with gcc and clang.

9 days agostdio: Fix tst-vfprintf-user-type on clang
Adhemerval Zanella [Sat, 2 Apr 2022 02:51:04 +0000 (23:51 -0300)] 
stdio: Fix tst-vfprintf-user-type on clang

The pointer alias comparison will be optimized away by the compiler,
and gcc and clang will evaluate differently (clang evaluates as
false, while gcc as true).

9 days agox86: Do not use __builtin_isinf_sign on clang
Adhemerval Zanella [Fri, 1 Apr 2022 20:03:34 +0000 (17:03 -0300)] 
x86: Do not use __builtin_isinf_sign on clang

clang does not handle pseudo normal numbers,

It fixes the regression on test-ldouble-isinf when built with clang:

Failure: isinf (pseudo_zero): Exception "Invalid operation" set
Failure: isinf (pseudo_inf): Exception "Invalid operation" set
Failure: isinf (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf (pseudo_snan): Exception "Invalid operation" set
Failure: isinf (pseudo_unnormal): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_zero): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_inf): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_snan): Exception "Invalid operation" set
Failure: isinf_downward (pseudo_unnormal): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_zero): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_inf): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_snan): Exception "Invalid operation" set
Failure: isinf_towardzero (pseudo_unnormal): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_zero): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_inf): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_qnan): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_snan): Exception "Invalid operation" set
Failure: isinf_upward (pseudo_unnormal): Exception "Invalid operation" set

9 days agox86: Do not use __builtin_fpclassify on clang
Adhemerval Zanella [Fri, 1 Apr 2022 19:54:55 +0000 (16:54 -0300)] 
x86: Do not use __builtin_fpclassify on clang

clang does not handle pseudo normal numbers, so disable the fpclassify
and isnormal builtin optimization if clang is used.  This only affect
x86, so add a new header, fp-builtin-denormal.h, which defines whether
the architecture required to disable the optimization through a new
glibc define (__FP_BUILTIN_DENORMAL).

It fixes the regression on test-ldouble-fpclassify and test-float64x-fpclassify
when built with clang:

Failure: fpclassify (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify (pseudo_unnormal): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify_downward (pseudo_unnormal): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify_towardzero (pseudo_unnormal): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_zero): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_inf): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_qnan): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_snan): Exception "Invalid operation" set
Failure: fpclassify_upward (pseudo_unnormal): Exception "Invalid operation" set

9 days agomath: Fix isgreater* and isless* for clang
Adhemerval Zanella [Fri, 1 Apr 2022 19:35:32 +0000 (16:35 -0300)] 
math: Fix isgreater* and isless* for clang

clang does not check for unordered numbers with builtins for
_Float128 type.

It fixes multiple issues with math tests, such as:

Failure: fmax (0, qNaN): Exception "Invalid operation" set
Failure: fmax (0, -qNaN): Exception "Invalid operation" set
Failure: fmax (-0, qNaN): Exception "Invalid operation" set
Failure: fmax (-0, -qNaN): Exception "Invalid operation" set
Failure: fmax (9, qNaN): Exception "Invalid operation" set
Failure: fmax (9, -qNaN): Exception "Invalid operation" set
Failure: fmax (-9, qNaN): Exception "Invalid operation" set
Failure: fmax (-9, -qNaN): Exception "Invalid operation" set

9 days agoExtend malloc function hiding to tst-memaling-2 and tst-reallocarray (BZ #32366)
Adhemerval Zanella [Wed, 2 Apr 2025 15:51:51 +0000 (12:51 -0300)] 
Extend malloc function hiding to tst-memaling-2 and tst-reallocarray (BZ #32366)

Add "tst-malloc-aux.h" on tst-memalign-2.c and extend the mechanism
to handle reallocarray as well (clang-20 also optimize-out
reallocarray).

9 days agoEnable --enable-fortify-source with clang
Adhemerval Zanella [Thu, 8 Feb 2024 13:56:30 +0000 (10:56 -0300)] 
Enable --enable-fortify-source with clang

clang generates internal calls for some _chk symbol, so add internal
aliases for them, and stub some with rtld-stubbed-symbols to avoid
ld.so linker issues.

9 days agoelf: Fix abort localplt issue with clang
Adhemerval Zanella [Tue, 25 Mar 2025 14:08:44 +0000 (11:08 -0300)] 
elf: Fix abort localplt issue with clang

9 days agonss: Suppress clang -Wstring-plus-int on __nss_shlib_revision definition
Adhemerval Zanella [Thu, 10 Mar 2022 11:31:06 +0000 (08:31 -0300)] 
nss: Suppress clang -Wstring-plus-int on __nss_shlib_revision definition

clang issues an warning that adding 'unsigned long' to a string does not
append to the string.

9 days agoaarch64: Fix tst-ifunc-arg-4 on clang-18
Adhemerval Zanella [Thu, 16 Oct 2025 19:03:27 +0000 (16:03 -0300)] 
aarch64: Fix tst-ifunc-arg-4 on clang-18

It issues:

../sysdeps/aarch64/tst-ifunc-arg-4.c:39:1: error: unused function 'resolver' [-Werror,-Wunused-function]
   39 | resolver (uint64_t arg0, const uint64_t arg1[])
      | ^~~~~~~~
1 error generated.

clang-19 and onwards do not trigger the warning.

9 days agoconfigure: remove overly restrictive check for clang
Adhemerval Zanella [Sun, 26 Sep 2021 05:03:08 +0000 (22:03 -0700)] 
configure: remove overly restrictive check for clang

The clang support is still experimental and not all testcase build
or run correctly.  Only clang 18 and onwards is supported and only
for x86_64-linux-gnu and aarch64-linux-gnu.

9 days agomath: Handle fabsf128 !__USE_EXTERN_INLINES
Adhemerval Zanella [Tue, 2 Aug 2022 18:42:14 +0000 (15:42 -0300)] 
math: Handle fabsf128 !__USE_EXTERN_INLINES

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.

9 days agoFilter out internal abort during ld.so build
Adhemerval Zanella [Fri, 1 Apr 2022 17:17:07 +0000 (14:17 -0300)] 
Filter out internal abort during ld.so build

clang might generate an abort call when cleanup functions (set by
__attribute__ ((cleanup)) calls functions not marked as nothrow.

The hurd already provides abort for the loader at
sysdeps/mach/hurd/dl-sysdep.c, and adding it rtld-stubbed-symbols
triggers duplicate symbols.

9 days agoEnable --enable-fortify-source with clang
Adhemerval Zanella [Thu, 8 Feb 2024 13:56:30 +0000 (10:56 -0300)] 
Enable --enable-fortify-source with clang

clang generates internal calls for some _chk symbol, so add internal
aliases for them, and stub some with rtld-stubbed-symbols to avoid
ld.so linker issues.

9 days agoEnable --no-undefined-version by default
Adhemerval Zanella [Mon, 24 Mar 2025 18:04:04 +0000 (15:04 -0300)] 
Enable --no-undefined-version by default

Recent lld version default to --no-undefined-version, which triggers
errors when building multiple libraries.  For ld.so on x86_64  it fails
with:

ld.lld: error: version script assignment of 'GLIBC_2.4' to symbol '__stack_chk_guard' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '__nptl_set_robust_list_avail' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '__pointer_chk_guard' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '_dl_starting_up' failed: symbol not defined

While for libc.so:

ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_clearerr' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fgetc' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fileno' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_freopen' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fscanf' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fseek' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_peekc_unlocked' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stderr_' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stdin_' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stdout_' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_pclose' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_perror' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_rewind' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_scanf' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_setbuf' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_setlinebuf' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_wdefault_setbuf' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_wfile_setbuf' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '__ctype32_tolower' failed: symbol not defined
ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '__ctype32_toupper' failed: symbol not defined
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)

The version script is created with multiple missing symbols to simplify
the build for multiple ABIs, each of which may have different symbols.
For instance, __stack_chk_guard is defined by default. This avoids
requiring each ABI to add this symbol to its version script, depending
on the stack protector ABI it uses.

The libc.so warnings do show unused symbols being defined (like
_IO_clearerr), which might trigger potential errors depending on how
symbols are exported.  However, since we already have ABI checks for
missing and extra symbols, the linker's extra checks are not really
necessary.

The --no-undefined-version is the default for ld.bfd.

9 days agoSupress unused command arguments warning with clang
Adhemerval Zanella [Tue, 25 Mar 2025 12:05:36 +0000 (09:05 -0300)] 
Supress unused command arguments warning with clang

clang 20 issues an warning for the unused '-c' argument used to create
errlist-data-aux-shared.S, errlist-data-aux.S, siglist-aux-shared.S,
and siglist-aux.S.  Filter out the '-c' from the $(compile-command.c).

9 days agoAnnotate swtich fall-through
Adhemerval Zanella [Tue, 18 Mar 2025 16:55:58 +0000 (13:55 -0300)] 
Annotate swtich fall-through

The clang default to warning for missing fall-through and it does
not support all comment-like annotation that gcc does.  Use C23
[[fallthrough]] annotation instead.
proper attribute instead.

9 days agoaarch64: Use NO_MATH_REDIRECT on pow_advsimd.c
Adhemerval Zanella [Wed, 2 Oct 2024 19:13:26 +0000 (19:13 +0000)] 
aarch64: Use NO_MATH_REDIRECT on pow_advsimd.c

clang does not optimize the fma calls, instead issuing __fma.

9 days agox86: Fix THREAD_GSCOPE_RESET_FLAG build on clang
Adhemerval Zanella [Thu, 16 Oct 2025 19:30:52 +0000 (16:30 -0300)] 
x86: Fix THREAD_GSCOPE_RESET_FLAG build on clang

clang does not support __seg_fs in asm constraint.

9 days agox86: Adapt "%v" usage on clang to emit VEX enconding
Adhemerval Zanella [Thu, 16 Oct 2025 19:23:18 +0000 (16:23 -0300)] 
x86: Adapt "%v" usage on clang to emit VEX enconding

clang does not support the %v to select the AVX encoding, nor the '%d' asm
contrain, and for AVX build it requires all 3 arguments.

This patch add a new internal header, math-inline-asm.h, that adds
functions to abstract the inline asm required differences between
gcc and clang.

9 days agox86: Fix strstr ifunc on clang
Adhemerval Zanella [Tue, 1 Apr 2025 19:22:42 +0000 (16:22 -0300)] 
x86: Fix strstr ifunc on clang

clang triggers multiple issue on how ifunc macro are used:

  ../sysdeps/x86_64/multiarch/strstr.c:38:54: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
     38 | extern __typeof (__redirect_strstr) __strstr_generic attribute_hidden;
        |                                                      ^
  ./../include/libc-symbols.h:356:43: note: expanded from macro 'attribute_hidden'
    356 | # define attribute_hidden __attribute__ ((visibility ("hidden")))
        |                                           ^
  ../string/strstr.c:76:1: note: previous definition is here
     76 | STRSTR (const char *haystack, const char *needle)
        | ^
  ../sysdeps/x86_64/multiarch/strstr.c:27:16: note: expanded from macro 'STRSTR'
     27 | #define STRSTR __strstr_generic
        |                ^
  ../sysdeps/x86_64/multiarch/strstr.c:65:43: error: redefinition of '__libc_strstr'
     65 | libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ());
        |                                           ^

And

  ../sysdeps/x86_64/multiarch/strstr.c:65:43: error: redefinition of '__libc_strstr'
     65 | libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ());
        |                                           ^
  ../sysdeps/x86_64/multiarch/strstr.c:59:13: note: previous definition is here
     59 | libc_ifunc (__libc_strstr,
        |             ^

Refactor to use a auxiliary function like other selection (for instance,
x86_64/multiarch/strcmp.c).

9 days agox86: math: Use of __libgcc_cmp_return__ iff compiler supports it
Adhemerval Zanella [Thu, 10 Mar 2022 17:41:31 +0000 (14:41 -0300)] 
x86: math: Use of __libgcc_cmp_return__ iff compiler supports it

clang does not support '__attribute__ ((mode (__libgcc_cmp_return__)))',
so use a more close related type instead fo the default 'int'.

9 days agox86: Use -mavx instead of -msse2avx
Adhemerval Zanella [Thu, 10 Mar 2022 18:05:51 +0000 (15:05 -0300)] 
x86: Use -mavx instead of -msse2avx

clang supports it from version 19 and onwards, but it should be gated
as an option to assembler (either with -Wa or -Xassembler).  Add a
test for -Wa as well if -msse2avx fully supported by the compiler.

9 days agostring: Use asm alias instead of symbol redirections for stpcpy and mempcpy
Adhemerval Zanella [Tue, 15 Mar 2022 11:41:43 +0000 (08:41 -0300)] 
string: Use asm alias instead of symbol redirections for stpcpy and mempcpy

Commit 939da411433 added symbols redirections to handle ISO C
namespace, however clang do not support to redeclare the function
prototype.

This patch replaces the symbol redirections by direct asm aliases, as
done to handle libcall generation done by compiler on some loop
optimizations.

Checked on all affected ABIs.

9 days agonss: Suppress clang -Wstring-plus-int on __nss_shlib_revision definition
Adhemerval Zanella [Thu, 10 Mar 2022 11:31:06 +0000 (08:31 -0300)] 
nss: Suppress clang -Wstring-plus-int on __nss_shlib_revision definition

clang issues an warning that adding 'unsigned long' to a string does not
append to the string.

10 days agoHandle clang -Wignored-attributes on weak aliases
Adhemerval Zanella [Wed, 24 Aug 2022 15:13:27 +0000 (12:13 -0300)] 
Handle clang -Wignored-attributes on weak aliases

Clang issues a warning for double alias redirection, indicating that thei
original symbol is used even if a weak definition attempts to override it.

For instance, in the construction:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, external_impl);
  #if SOMETHING
  weak_alias (external_impl, another_external_impl)
  #endif

Clang warns that another_external_impl always resolves to __internal_impl,
even if external_impl is a weak reference. Using the internal symbol for
both aliases resolves this warning.

This issue also occurs with certain libc_hidden_def usage:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, __internal_alias)
  libc_hidden_weak (__internal_alias)

In this case, using a strong_alias is sufficient to avoid the warning
(since the alias is internal, there is no need to use a weak alias).

However, for the constructions like:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, __internal_alias)
  libc_hidden_def (__internal_alias)
  weak_alias (__internal_impl, external_alias)
  libc_hidden_def (external_alias)

Clang warns that the internal external_alias will always resolve to
__GI___internal_impl eve if a weak definition to __GI_internal_impl is
overriden.  For this case, a new macro named static_weak_alias is used
to create a strong alias for SHARED, or a weak_alias otherwise.

With these changes, there is no need to check and enable the
-Wno-ignored-attributes suppression when using clang.

10 days agoargp: Move attribute_hidden to argp-fmtstream.h
Adhemerval Zanella [Wed, 22 Oct 2025 12:52:08 +0000 (09:52 -0300)] 
argp: Move attribute_hidden to argp-fmtstream.h

The internal header redefines the some internal argp functions with
attribute_hidden, which triggers clang warning of mismatched attributes.

10 days agoargp: Expand argp_usage, _option_is_short, and _option_is_end
Adhemerval Zanella [Thu, 21 Jul 2022 17:12:01 +0000 (14:12 -0300)] 
argp: Expand argp_usage, _option_is_short, and _option_is_end

The argp code uses macro redefinitions to avoid duplicating static inline
implementations for argp_usage, _option_is_short, and _option_is_end.
However, this causes build issues with clang, as some function prototypes
are redefined to add the hidden attribute with libc_hidden_proto.

To avoid extensive changes to internal headers, just expand the function
implementations and avoid the macro redefine tricks.

10 days agomath: Don't redirect inlined builtin math functions
Adhemerval Zanella [Sun, 26 Oct 2025 21:17:07 +0000 (18:17 -0300)] 
math: Don't redirect inlined builtin math functions

When we want to inline builtin math functions, like truncf, for

  extern float truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));
  extern float __truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__));

  float (truncf) (float) asm ("__truncf");

compiler may redirect truncf calls to __truncf, instead of inlining it
(for instance, clang).  The USE_TRUNCF_BUILTIN is 1 to indicate that
truncf should be inlined.  In this case, we don't want the truncf
redirection:

  1. For each math function which may be inlined, we define

  #if USE_TRUNCF_BUILTIN
   # define NO_truncf_BUILTIN inline_truncf
   #else
   # define NO_truncf_BUILTIN truncf
   #endif

in <math-use-builtins.h>.

  2. Include <math-use-builtins.h> in include/math.h.

  3. Change MATH_REDIRECT to

   #define MATH_REDIRECT(FUNC, PREFIX, ARGS) \
    float (NO_ ## FUNC ## f ## _BUILTIN) (ARGS (float)) \
      asm (PREFIX #FUNC "f");

With this change If USE_TRUNCF_BUILTIN is 0, we get

  float (truncf) (float) asm ("__truncf");
  truncf will be redirected to __truncf.

And for USE_TRUNCF_BUILTIN 1, we get:

  float (inline_truncf) (float) asm ("__truncf");

In both cases either truncf will be inlined or the internal alias
(__truncf) will be called.

It is not required for all math-use-builtin symbol, only the one
defined in math.h.  It also allows to remove all the math-use-builtin
inclusion, since it is now implicitly included by math.h.

For MIPS, some math-use-builtin headers include sysdep.h and this
in turn includes a lot of extra headers that do not allow ldbl-128
code to override alias definition (math.h will include
some stdlib.h definition).  The math-use-builtin only requires
the __mips_isa_rev, so move the defintion to sgidefs.h.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
10 days agostdlib: Remove longlong.h
Adhemerval Zanella [Fri, 24 Oct 2025 20:39:59 +0000 (17:39 -0300)] 
stdlib: Remove longlong.h

The gmp-arch.h now provides all the required definitions.

10 days agoAdd umul_ppmm to gmp-arch.hdoc
Adhemerval Zanella [Fri, 24 Oct 2025 17:17:05 +0000 (14:17 -0300)] 
Add umul_ppmm to gmp-arch.hdoc

To enable “longlong.h” removal, the umul_ppmm is moved to a gmp-arch.h.
The generic implementation now uses a static inline, which provides
better type checking than the GNU extension to cast the asm constraint
(and it works better with clang).

Most of the architecture uses the generic implementation, which is
expanded from a macro, except for alpha, arm, hppa, x86, m68k, mips,
powerpc, and sparc.  I kept only x86 optimization, where there is no
easy way to emit mul{q}. For the rest, the compiler generates good
enough code.

10 days agoAdd add_ssaaaa and sub_ssaaaa to gmp-arch.h
Adhemerval Zanella [Fri, 24 Oct 2025 14:37:36 +0000 (11:37 -0300)] 
Add add_ssaaaa and sub_ssaaaa to gmp-arch.h

To enable “longlong.h” removal, add_ssaaaa and sub_ssaaaa are moved to
gmp-arch.h.  The generic implementation now uses a static inline.  This
provides better type checking than the GNU extension, which casts the
asm constraint. It also works better with clang.

Most architectures use the generic implementation.  This is expanded
from a macro.  Exceptions are arc, arm, hppa, x86, m68k, powerpc, and
sparc.  I kept only the x86 optimization, as there is no easy way to
emit add{q}. For all others, the compiler generates good enough code.

The strongly typed implementation required some changes.  I adjusted
_FP_W_TYPE, _FP_WS_TYPE, and _FP_I_TYPE to use the same type as
mp_limb_t on aarch64, powerpc64le, x86_64, and riscv64.  This basically
means using “long” instead of “long long.”

10 days agoAdd gmp-arch and udiv_qrnnd
Adhemerval Zanella [Fri, 24 Oct 2025 11:24:32 +0000 (08:24 -0300)] 
Add gmp-arch and udiv_qrnnd

To enable “longlong.h” removal, the udiv_qrnnd is moved to a gmp-arch.h
file.  It allows each architecture to implement its own arch-specific
optimizations. The generic implementation now uses a static inline,
which provides better type checking than the GNU extension to cast the
asm constraint (and it works better with clang).

Most of the architecture uses the generic implementation, which is
expanded from a macro, except for alpha, x86, m68k, sh, and sparc.
I kept that alpha, which uses out-of-the-line implementations and x86,
where there is no easy way to use the div{q} instruction from C code.
For the rest, the compiler generates good enough code.

The hppa also provides arch-specific implementations, but they are not
routed in “longlong.h” and thus never used.

10 days agostdlib: Remove mp_clz_tab.c
Adhemerval Zanella [Fri, 24 Oct 2025 18:23:13 +0000 (15:23 -0300)] 
stdlib: Remove mp_clz_tab.c

The count_leading_zeros is not used anymore, so there is no need to
provide the table for possible usage.  The hppa already provides
the compat symbol on libgcc-compat.c.

10 days agoReplace count_leading_zeros with stdc_leading_zeros
Adhemerval Zanella [Thu, 23 Oct 2025 17:30:15 +0000 (14:30 -0300)] 
Replace count_leading_zeros with stdc_leading_zeros

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

10 days agomalloc: Remove unused tcache_set_inactive
Adhemerval Zanella [Wed, 22 Oct 2025 20:31:23 +0000 (17:31 -0300)] 
malloc: Remove unused tcache_set_inactive

clang warns that this function is not used.

10 days agoinclude: Sync gnulib intprops
Adhemerval Zanella [Thu, 23 Oct 2025 12:12:18 +0000 (09:12 -0300)] 
include: Sync gnulib intprops

It syncs with gnulib commit 1790ef25d81983d1d25a77d452c0080345df459b.

The main change is to proper support clang by using builtins.  It
fixes a sprof build issue, where previous version uses the generic
code path when building with clang:

sprof.c:682:8: error: result of comparison of constant 288230376151711743 with expression of type 'Elf64_Half' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
  682 |           if (INT_MULTIPLY_WRAPV (ehdr2.e_shnum, sizeof (ElfW(Shdr)), &size))
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/intprops.h:415:34: note: expanded from macro 'INT_MULTIPLY_WRAPV'
  415 |    _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/intprops.h:504:45: note: expanded from macro '_GL_INT_OP_WRAPV'
  504 |     : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
../include/intprops.h:511:41: note: expanded from macro '_GL_INT_OP_WRAPV_LONGISH'
  511 |         : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  512 |                            unsigned long int, 0, ULONG_MAX)) \
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/intprops.h:533:4: note: expanded from macro '_GL_INT_OP_CALC'
  533 |   (overflow (a, b, tmin, tmax) \
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/intprops.h:608:22: note: expanded from macro '_GL_INT_MULTIPLY_RANGE_OVERFLOW'
  608 |       : (tmax) / (b) < (a)))
      |         ~~~~~~~~~~~~ ^ ~~~
1 error generated.

10 days agomath: Consolidate CORE-MATH double-double routines
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:33 +0000 (15:15 -0300)] 
math: Consolidate CORE-MATH double-double routines

For lgamma and tgamma the muldd, mulddd, and polydd are renamed
to muldd2, mulddd2, and polydd2 respectively.

Checked on aarch64-linux-gnu and x86_64-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Consolidate erf/erfc definitions
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:32 +0000 (15:15 -0300)] 
math: Consolidate erf/erfc definitions

The common code definitions are consolidated in s_erf_common.h
and s_erf_common.c.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Consolidate internal erf/erfc tables
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:31 +0000 (15:15 -0300)] 
math: Consolidate internal erf/erfc tables

The shared internal data definitions are consolidated in
s_erf_data.c and the erfc only one are moved to s_erfc_data.c.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use erfc from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:30 +0000 (15:15 -0300)] 
math: Use erfc from CORE-MATH

The current implementation precision shows the following accuracy, on
three ranges ([-DBL_MAX,5], [-5,5], [5,DBL_MAX]) with 10e9 uniform
randomly generated numbers for each range (first column is the
accuracy in ULP, with '0' being correctly rounded, second is the
number of samples with the corresponding precision):

* Range [-DBL_MAX, -5]
 * FE_TONEAREST
     0:      10000000000 100.00%
 * FE_UPWARD
     0:      10000000000 100.00%
 * FE_DOWNWARD
     0:      10000000000 100.00%
 * FE_TOWARDZERO
     0:      10000000000 100.00%

* Range [-5, 5]
 * FE_TONEAREST
     0:       8069309665  80.69%
     1:       1882910247  18.83%
     2:         47485296   0.47%
     3:           293749   0.00%
     4:             1043   0.00%
 * FE_UPWARD
     0:       5540301026  55.40%
     1:       2026739127  20.27%
     2:       1774882486  17.75%
     3:        567324466   5.67%
     4:         86913847   0.87%
     5:          3820789   0.04%
     6:            18259   0.00%
 * FE_DOWNWARD
     0:       5520969586  55.21%
     1:       2057293099  20.57%
     2:       1778334818  17.78%
     3:        557521494   5.58%
     4:         82473927   0.82%
     5:          3393276   0.03%
     6:            13800   0.00%
 * FE_TOWARDZERO
     0:       6220287175  62.20%
     1:       2323846149  23.24%
     2:       1251999920  12.52%
     3:        190748245   1.91%
     4:         12996232   0.13%
     5:           122279   0.00%

* Range [5, DBL_MAX]
 * FE_TONEAREST
     0:      10000000000 100.00%
 * FE_UPWARD
     0:      10000000000 100.00%
 * FE_DOWNWARD
     0:      10000000000 100.00%
 * FE_TOWARDZERO
     0:      10000000000 100.00%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master        patched   improvement
x86_64                      49.0980       267.0660      -443.94%
x86_64v2                    49.3220       257.6310      -422.34%
x86_64v3                    42.9539        84.9571       -97.79%
aarch64                     28.7266        52.9096       -84.18%
power10                     14.1673        25.1273       -77.36%

Latency                      master        patched   improvement
x86_64                      95.6640       269.7060      -181.93%
x86_64v2                    95.8296       260.4860      -171.82%
x86_64v3                    91.1658       112.7150       -23.64%
aarch64                     37.0745        58.6791       -58.27%
power10                     23.3197        31.5737       -35.39%

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use erf from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:29 +0000 (15:15 -0300)] 
math: Use erf from CORE-MATH

The current implementation precision shows the following accuracy, on
three rangeis ([-DBL_MIN, -4.2], [-4.2, 4.2], [4.2, DBL_MAX]) with
10e9 uniform randomly generated numbers for each range (first column
is the accuracy in ULP, with '0' being correctly rounded, second is the
number of samples with the corresponding precision):

* Range [-DBL_MIN, -4.2]
 * FE_TONEAREST
     0:      10000000000 100.00%
 * FE_UPWARD
     0:      10000000000 100.00%
 * FE_DOWNWARD
     0:      10000000000 100.00%
 * FE_TOWARDZERO
     0:      10000000000 100.00%

* Range [-4.2, 4.2]
 * FE_TONEAREST
     0:       9764404513  97.64%
     1:        235595487   2.36%
 * FE_UPWARD
     0:       9468013928  94.68%
     1:        531986072   5.32%
 * FE_DOWNWARD
     0:       9493787693  94.94%
     1:        506212307   5.06%
 * FE_TOWARDZERO
     0:       9585271351  95.85%
     1:        414728649   4.15%

* Range [4.2, DBL_MAX]
 * FE_TONEAREST
     0:      10000000000 100.00%
 * FE_UPWARD
     0:      10000000000 100.00%
 * FE_DOWNWARD
     0:      10000000000 100.00%
 * FE_TOWARDZERO
     0:      10000000000 100.00%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master       patched   improvement
x86_64                      38.2754       78.0311      -103.87%
x86_64v2                    38.3325       75.7555       -97.63%
x86_64v3                    34.6604       28.3182        18.30%
aarch64                     23.1499       21.4307         7.43%
power10                     12.3051       9.3766         23.80%

Latency                      master       patched   improvement
x86_64                      84.3062      121.3580       -43.95%
x86_64v2                    84.1817      117.4250       -39.49%
x86_64v3                    81.0933       70.6458        12.88%
aarch64                      35.012       29.5012        15.74%
power10                     21.7205       18.4589        15.02%

For x86_64/x86_64-v2, most performance hit came from the fma call
through the ifunc mechanism.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use tgamma from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:28 +0000 (15:15 -0300)] 
math: Use tgamma from CORE-MATH

The current implementation precision shows the following accuracy, on
one range ([-20,20]) with 10e9 uniform randomly generated numbers for
each range (first column is the accuracy in ULP, with '0' being
correctly rounded, second is the number of samples with the
corresponding precision):

* Range [-20,20]
 * FE_TONEAREST
     0:       4504877808  45.05%
     1:       4402224940  44.02%
     2:        947652295   9.48%
     3:        131076831   1.31%
     4:         13222216   0.13%
     5:           910045   0.01%
     6:            35253   0.00%
     7:              606   0.00%
     8:                6   0.00%
 * FE_UPWARD
     0:       3477307921  34.77%
     1:       4838637866  48.39%
     2:       1413942684  14.14%
     3:        240762564   2.41%
     4:         27113094   0.27%
     5:          2130934   0.02%
     6:           102599   0.00%
     7:             2324   0.00%
     8:               14   0.00%
 * FE_DOWNWARD
     0:       3923545410  39.24%
     1:       4745067290  47.45%
     2:       1137899814  11.38%
     3:        171596912   1.72%
     4:         20013805   0.20%
     5:          1773899   0.02%
     6:            99911   0.00%
     7:             2928   0.00%
     8:               31   0.00%
 * FE_TOWARDZERO
     0:       3697160741  36.97%
     1:       4731951491  47.32%
     2:       1303092738  13.03%
     3:        231969191   2.32%
     4:         32344517   0.32%
     5:          3283092   0.03%
     6:           193010   0.00%
     7:             5175   0.00%
     8:               45   0.00%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master        patched   improvement
x86_64                     237.7960       175.4090        26.24%
x86_64v2                   232.9320       163.4460        29.83%
x86_64v3                   193.0680        89.7721        53.50%
aarch64                    113.6340        56.7350        50.07%
power10                     92.0617        26.6137        71.09%

Latency                      master        patched   improvement
x86_64                     266.7190       208.0130        22.01%
x86_64v2                   263.6070       200.0280        24.12%
x86_64v3                   214.0260       146.5180        31.54%
aarch64                    114.4760        58.5235        48.88%
power10                     84.3718        35.7473        57.63%

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use lgamma from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:27 +0000 (15:15 -0300)] 
math: Use lgamma from CORE-MATH

The current implementation precision shows the following accuracy, on
one range ([-1,1]) with 10e9 uniform randomly generated numbers for
each range (first column is the accuracy in ULP, with '0' being
correctly rounded, second is the number of samples with the
corresponding precision):

* Range [-20, 20]
 * FE_TONEAREST
     0:       6701254075  67.01%
     1:       3230897408  32.31%
     2:         63986940   0.64%
     3:          3605417   0.04%
     4:           233189   0.00%
     5:            20973   0.00%
     6:             1869   0.00%
     7:              125   0.00%
     8:                4   0.00%
 * FE_UPWARDA
     0:       4207428861  42.07%
     1:       5001137116  50.01%
     2:        740542213   7.41%
     3:         49116304   0.49%
     4:          1715617   0.02%
     5:            54464   0.00%
     6:             4956   0.00%
     7:              451   0.00%
     8:               16   0.00%
     9:                2   0.00%
 * FE_DOWNWARD
     0:       4155925193  41.56%
     1:       4989821364  49.90%
     2:        770312796   7.70%
     3:         72014726   0.72%
     4:         11040522   0.11%
     5:           872811   0.01%
     6:            12480   0.00%
     7:              106   0.00%
     8:                2   0.00%
 * FE_TOWARDZERO
     0:       4225861532  42.26%
     1:       5027051105  50.27%
     2:        706443411   7.06%
     3:         39877908   0.40%
     4:           713109   0.01%
     5:            47513   0.00%
     6:             4961   0.00%
     7:              438   0.00%
     8:               23   0.00%

* Range [20, 0x5.d53649e2d4674p+1012]
 * FE_TONEAREST
     0:       7262241995  72.62%
     1:       2737758005  27.38%
 * FE_UPWARD
     0:       4690392401  46.90%
     1:       5143728216  51.44%
     2:        165879383   1.66%
 * FE_DOWNWARD
     0:       4690333331  46.90%
     1:       5143794937  51.44%
     2:        165871732   1.66%
 * FE_TOWARDZERO
     0:       4690343071  46.90%
     1:       5143786761  51.44%
     2:        165870168   1.66%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master        patched   improvement
x86_64                     112.9740       135.8640       -20.26%
x86_64v2                   111.8910       131.7590       -17.76%
x86_64v3                   108.2800        68.0935        37.11%
aarch64                     61.3759        49.2403        19.77%
power10                     42.4483        24.1943        43.00%

Latency                      master        patched   improvement
x86_64                     144.0090       167.9750       -16.64%
x86_64v2                   139.2690       167.1900       -20.05%
x86_64v3                   130.1320        96.9347        25.51%
aarch64                     66.8538        53.2747        20.31%
power10                     49.5076        29.6917        40.03%

For x86_64/x86_64-v2, most performance hit came from the fma call
through the ifunc mechanism.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Move atanh internal data to separate file
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:26 +0000 (15:15 -0300)] 
math: Move atanh internal data to separate file

The internal data definitions are moved to s_atanh_data.c.
It helps on ABIs that build the implementation multiple times for
ifunc optimizations, like x86_64.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Consolidate acosh and asinh internal table
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:25 +0000 (15:15 -0300)] 
math: Consolidate acosh and asinh internal table

The shared internal data definitions are consolidated in
s_asincosh_data.c.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use atanh from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:24 +0000 (15:15 -0300)] 
math: Use atanh from CORE-MATH

The current implementation precision shows the following accuracy, on
one range ([-1,1]) with 10e9 uniform randomly generated numbers for
each range (first column is the accuracy in ULP, with '0' being
correctly rounded, second is the number of samples with the
corresponding precision):

* Range [-1, 1]
 * FE_TONEAREST
     0:       8180011860  81.80%
     1:       1819865257  18.20%
     2:           122883   0.00%
 * FE_UPWARDA
     0:       3903695744  39.04%
     1:       4992324465  49.92%
     2:       1096319340  10.96%
     3:          7660451   0.08%
 * FE_DOWNWARDA
     0:       3904555484  39.05%
     1:       4991970864  49.92%
     2:       1095447471  10.95%
     3:          8026181   0.08%
 * FE_TOWARDZERO
     0:       7070209165  70.70%
     1:       2908447434  29.08%
     2:         21343401   0.21%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master        patched   improvement
x86_64                      26.4969        22.4625       15.23%
x86_64v2                    26.0792        22.9822       11.88%
x86_64v3                    25.6357        22.2147       13.34%
aarch64                     20.2295        19.7001        2.62%
power10                     10.0986         9.3846        7.07%

Latency                      master        patched   improvement
x86_64                      80.2311        59.9745       25.25%
x86_64v2                    79.7010        61.4066       22.95%
x86_64v3                    78.2679        58.5804       25.15%
aarch64                     34.3959        28.1523       18.15%
power10                     23.2417        18.2694       21.39%

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use asinh from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:23 +0000 (15:15 -0300)] 
math: Use asinh from CORE-MATH

The current implementation precision shows the following accuracy, on
tthree different ranges ([-DBL_MAX, -10], [-10,10], and [10, DBL_MAX))
with 10e9 uniform randomly generated numbers for each range (first
column is the accuracy in ULP, with '0' being correctly rounded, second
is the number of samples with the corresponding precision):

* range [-DBL_MAX, -10]
 * FE_TONEAREST
     0:       5164019099  51.64%
     1:       4835980901  48.36%
 * FE_UPWARD
     1:       4836053540  48.36%
     2:       5163946460  51.64%
 * FE_DOWNWARD
     1:       5163926134  51.64%
     2:       4836073866  48.36%
 * FE_TOWARDZERO
     0:       5163937001  51.64%
     1:       4836062999  48.36%

* Range [-10, 10)
 * FE_TONEAREST
     0:       8679029381  86.79%
     1:       1320934581  13.21%
     2:            36038   0.00%
 * FE_UPWARD
     0:       3965704277  39.66%
     1:       4993616710  49.94%
     2:       1039680225  10.40%
     3:           998788   0.01%
 * FE_DOWNWARD
     0:       3965806523  39.66%
     1:       4993534438  49.94%
     2:       1039601726  10.40%
     3:          1057313   0.01%
 * FE_TOWARDZEROA
     0:       7734210130  77.34%
     1:       2261868439  22.62%
     2:          3921431   0.04%

* Range [10, DBL_MAX)
 * FE_TONEAREST
     0:       5163973212  51.64%
     1:       4836026788  48.36%
 * FE_UPWARD
     0:       4835991071  48.36%
     1:       5164008929  51.64%
 * FE_DOWNWARD
     0:       5163983594  51.64%
     1:       4836016406  48.36%
 * FE_TOWARDZERO
     0:       5163993394  51.64%
     1:       4836006606  48.36%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master        patched   improvement
x86_64                      26.5178        45.3754       -71.11%
x86_64v2                    26.3167        44.7870       -70.18%
x86_64v3                    25.9109        25.4887         1.63%
aarch64                     18.0555        17.3374         3.98%
power10                     19.8535        20.5586        -3.55%

Latency                      master        patched   improvement
x86_64                      82.6755        91.2026       -10.31%
x86_64v2                    82.4581        90.7152       -10.01%
x86_64v3                    80.7000        71.9454        10.85%
aarch64                     32.8320        28.8565        12.11%
power10                     44.5309        37.0096        16.89%

For x86_64/x86_64-v2, most performance hit came from the fma call
through the ifunc mechanism.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agomath: Use acosh from CORE-MATH
Adhemerval Zanella [Fri, 10 Oct 2025 18:15:22 +0000 (15:15 -0300)] 
math: Use acosh from CORE-MATH

The current implementation precision shows the following accuracy, on
two different ranges ([1,21) and [21, DBL_MAX)) with 10e9 uniform
randomly generated numbers (first column is the accuracy in ULP, with
'0' being correctly rounded, second is the number of samples with the
corresponding precision):

* range [1,21]

 * FE_TONEAREST
    0:       8931139411  89.31%
    1:       1068697545  10.69%
    2:           163044   0.00%
 * FE_UPWARD
    0:       7936620731  79.37%
    1:       2062594522  20.63%
    2:           783977   0.01%
    3:              770   0.00%
 * FE_DOWNWARD
    0:       7936459794  79.36%
    1:       2062734117  20.63%
    2:           805312   0.01%
    3:              777   0.00%
 * FE_TOWARDZERO
    0:       7910345595  79.10%
    1:       2088584522  20.89%
    2:          1069106   0.01%
    3:              777   0.00%

* Range [21, DBL_MAX)
 * FE_TONEAREST
    0:       5163888431  51.64%
    1:       4836111569  48.36%
 * FE_UPWARD
    0:       4835951885  48.36%
    1:       5164048115  51.64%
 * FE_DOWNWARD
    0:       5164048432  51.64%
    1:       4835951568  48.36%
 * FE_TOWARDZERO
    0:       5164058042  51.64%
    1:       4835941958  48.36%

The CORE-MATH implementation is correctly rounded for any rounding mode.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1) shows:

reciprocal-throughput        master       patched   improvement
x86_64                      20.9131       47.2187      -125.79%
x86_64v2                    20.8823       41.1042       -96.84%
x86_64v3                    19.0282       25.8045       -35.61%
aarch64                     14.7419       18.1535       -23.14%
power10                     8.98341       11.0423       -22.92%

Latency                      master       patched   improvement
x86_64                      75.5494       89.5979      -18.60%
x86_64v2                    74.4443       87.6292      -17.71%
x86_64v3                    71.8558       70.7086        1.60%
aarch64                     30.3361       29.2709        3.51%
power10                     20.9263       19.2482        8.02%

For x86_64/x86_64-v2, most performance hit came from the fma call
through the ifunc mechanism.

Checked on x86_64-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agoLinux: fix tst-copy_file_range-large test on 32-bit platforms.
Collin Funk [Mon, 27 Oct 2025 02:06:08 +0000 (19:06 -0700)] 
Linux: fix tst-copy_file_range-large test on 32-bit platforms.

Since SSIZE_MAX is less than UINT_MAX on 32-bit platforms we must AND
the expression with SSIZE_MAX.

Tested on x86_64 and x86.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
11 days agox86: Disable AVX Fast Unaligned Load on Hygon 1/2/3
litenglong [Fri, 17 Oct 2025 01:45:41 +0000 (09:45 +0800)] 
x86: Disable AVX Fast Unaligned Load on Hygon 1/2/3

- Performance testing revealed significant memcpy performance degradation
  when bit_arch_AVX_Fast_Unaligned_Load is enabled on Hygon 3.
- Hygon confirmed AVX performance issues in certain memory functions.
- Glibc benchmarks show SSE outperforms AVX for
  memcpy/memmove/memset/strcmp/strcpy/strlen and so on.
- Hardware differences primarily in floating-point operations don't justify
  AVX usage for memory operations.

Reviewed-by: gaoxiang <gaoxiang@kylinos.cn>
Signed-off-by: litenglong <litenglong@kylinos.cn>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
11 days agoppc64le: Power 10 rawmemchr clobbers v20 (bug #33091)
Sachin Monga [Sun, 26 Oct 2025 17:17:12 +0000 (12:17 -0500)] 
ppc64le: Power 10 rawmemchr clobbers v20 (bug #33091)

Replace non-volatile(v20) by volatile(v17)
since v20 is not restored

Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
13 days agomalloc: fix large tcache code to check for exact size match
Dev Jain [Fri, 24 Oct 2025 16:52:21 +0000 (16:52 +0000)] 
malloc: fix large tcache code to check for exact size match

The tcache is used for allocation only if an exact match is found. In the
large tcache code added in commit cbfd7988107b, we currently extract a
chunk of size greater than or equal to the size we need, but don't check
strict equality. This patch fixes that behaviour.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agoFix configure from ab22e5ec37396f6c6f29d3e3306f6fcc2ebe9d49
Adhemerval Zanella [Wed, 22 Oct 2025 20:23:12 +0000 (17:23 -0300)] 
Fix configure from ab22e5ec37396f6c6f29d3e3306f6fcc2ebe9d49

The "-Wno-unused-command-line-argument" was incorrectly added.

2 weeks agomisc: Fix clang -Wstring-plus-int warnings on syslog
Adhemerval Zanella [Fri, 29 Apr 2022 13:50:13 +0000 (10:50 -0300)] 
misc: Fix clang -Wstring-plus-int warnings on syslog

clang issues:

syslog.c:193:9: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
  193 |                       SYSLOG_HEADER (pri, timestamp, &msgoff, pid));
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
syslog.c:180:7: note: expanded from macro 'SYSLOG_HEADER'
  180 |   "[" + (pid == 0), pid, "]" + (pid == 0)

Use array indexes instead of string addition (it is simpler than
add a supress warning).

2 weeks agosprof: fix -Wformat warnings on 32-bit hosts
Collin Funk [Wed, 22 Oct 2025 08:51:09 +0000 (01:51 -0700)] 
sprof: fix -Wformat warnings on 32-bit hosts

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agovarious fixes detected with -Wdouble-promotion
Paul Zimmermann [Tue, 14 Oct 2025 07:58:20 +0000 (09:58 +0200)] 
various fixes detected with -Wdouble-promotion

Changes with respect to v1:
- added comment in e_j1f.c to explain the use of float is enough
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agoposix: Fix memory leak a memory leak in glob.
Bruno Haible [Wed, 22 Oct 2025 02:06:05 +0000 (19:06 -0700)] 
posix: Fix memory leak a memory leak in glob.

Found by Coverity in Gnulib.

* posix/glob.c (__glob): Add scratch_buffer_free invocation, to match
scratch_buffer_init invocation.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agoplot_strings.py: Replace np.complex with complex
H.J. Lu [Tue, 21 Oct 2025 23:29:03 +0000 (07:29 +0800)] 
plot_strings.py: Replace np.complex with complex

Replace np.complex with complex to fix numpy error:

AttributeError: module 'numpy' has no attribute 'complex'.
`np.complex` was a deprecated alias for the builtin `complex`. To avoid this error in existing code, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agomalloc: avoid need for tcache == NULL checks
DJ Delorie [Thu, 28 Aug 2025 20:30:30 +0000 (16:30 -0400)] 
malloc: avoid need for tcache == NULL checks

Avoid needing to check for tcache == NULL by initializing it
to a dummy read-only tcache structure.  This dummy is all zeros,
so logically it is both full (when you want to put) and empty (when
you want to get).  Also, there are two dummies, one used for
"not yet initialized" and one for "tunables say we shouldn't have
a tcache".

The net result is twofold:

1. Checks for tcache == NULL may be removed from the fast path.
    Whether this makes the fast path faster when tcache is
    disabled is TBD, but the normal case is tcache enabled.

2. no memory for tcache is allocated if tunables disable caching.

Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 weeks agosprof: check pread size and offset for overflow
DJ Delorie [Thu, 16 Oct 2025 01:37:56 +0000 (21:37 -0400)] 
sprof: check pread size and offset for overflow

Add a bit of descriptive paranoia to the values we read from
the ELF headers and use to access data.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agoSimplify powl computation for small integral y [BZ #33411]
Siddhesh Poyarekar [Sat, 11 Oct 2025 00:21:13 +0000 (20:21 -0400)] 
Simplify powl computation for small integral y [BZ #33411]

The powl implementation for x86_64 ends up multiplying X once more than
necessary and then throwing away that result.  This results in an
overflow flag being set in cases where there is no overflow.

Simplify the relevant portion by special casing the -3 to 3 range and
simply multiplying repetitively.

Resolves: BZ #33411
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed by: Paul Zimmermann <Paul.Zimmermann@inria.fr>

2 weeks agosunrpc: Fix clang build
Adhemerval Zanella [Mon, 20 Oct 2025 12:27:54 +0000 (09:27 -0300)] 
sunrpc: Fix clang build

clang-21 issues:

rtime.c:96:36: error: variable 'thetime' is uninitialized when passed as a const pointer argument here
      [-Werror,-Wuninitialized-const-pointer]
   96 |       res = __sendto (s, (char *) &thetime, sizeof (thetime), 0,
      |                                    ^~~~~~~

For SOCK_DGRAM the sendto sends an uninitialized value.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agomath: Fix compare sort function on compoundn
Adhemerval Zanella [Mon, 20 Oct 2025 12:27:53 +0000 (09:27 -0300)] 
math: Fix compare sort function on compoundn

To use the fabs function to the used type, instead of the double
variant.  it fixes a build issue with clang:

./s_compoundn_template.c:64:14: error: absolute value function 'fabs' given an argument of type 'const long double' but has parameter of type 'double' which may cause truncation of value [-Werror,-Wabsolute-value]
   64 |   FLOAT pd = fabs (*(const FLOAT *) p);
      |              ^
./s_compoundn_template.c:64:14: note: use function 'fabsl' instead
   64 |   FLOAT pd = fabs (*(const FLOAT *) p);
      |              ^~~~
      |              fabsl

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agogmon: Only used -fno-tree-loop-distribute-patterns if compiler supports it
Adhemerval Zanella [Mon, 20 Oct 2025 12:27:50 +0000 (09:27 -0300)] 
gmon: Only used -fno-tree-loop-distribute-patterns if compiler supports it

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agotermios: Suppress clang -Winitializer-overrider on ___cbaud_to_speed
Adhemerval Zanella [Mon, 20 Oct 2025 12:27:49 +0000 (09:27 -0300)] 
termios: Suppress clang -Winitializer-overrider on ___cbaud_to_speed

clang-18 and onwards issues:

../sysdeps/unix/sysv/linux/speed.c:71:23: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
   71 |       [_cbix(__B0)] = 0,
      |                       ^
../sysdeps/unix/sysv/linux/speed.c:70:34: note: previous initialization is here
   70 |       [0 ... _cbix(CBAUDMASK)] = -1,
[...]

The override is explicit used to support the same initialization on
multiple platforms (since the baud values differ on alpha and powerpc).

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agostdio: Only use __va_arg_pack if compiler supports it
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:24 +0000 (16:13 -0300)] 
stdio: Only use __va_arg_pack if compiler supports it

Otherwise route __libc_message_wrapper to __libc_message_impl.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoelf: Fix tunable handing with clang
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:22 +0000 (16:13 -0300)] 
elf: Fix tunable handing with clang

Recent clang version optimizes some loops contructions to strlen [1],
which might generate function calls when self-relocation is not
already done (on tunable parsing).  Use an out-of-line function
with __attribute_optimization_barrier__ to avoid this.

[1] https://github.com/llvm/llvm-project/pull/132572/commits/facd7dfc80d655fe49baf4bf27e144a4c890a149

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoelf: Suppress unused function clang warning for __ifunc_resolver
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:14 +0000 (16:13 -0300)] 
elf: Suppress unused function clang warning for __ifunc_resolver

The __ifunc_resolver macro expands to:

   extern __typeof (__redirect_name) name __attribute__ ((ifunc ("iname_ifunc")));
   static __typeof (__redirect_name) *name_ifunc (void) { [...] };

And although NAME_IFUNC is and alias for NAME, clang still emits
an 'unused function 'name_ifunc' [-Werror,-Wunused-function]'
warning.  The static is used to avoid name pollution on static
linkage.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agosupport: Handle clang support/dtotimespec.c on dtotimespec
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:02 +0000 (16:13 -0300)] 
support: Handle clang support/dtotimespec.c on dtotimespec

clang issues:

dtotimespec.c:31:25: error: implicit conversion from 'time_t' (aka
'long') to 'double' changes value from 9223372036854775807 to
9223372036854775808 [-Werror,-Wimplicit-const-int-float-conversion]
  else if (sec >= 1.0 + TYPE_MAXIMUM (time_t))
                      ~ ^~~~~~~~~~~~~~~~~~~~~
../include/intprops.h:57:4: note: expanded from macro 'TYPE_MAXIMUM'
  ((t) (! TYPE_SIGNED (t)
\
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So explicit cast it to double.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agostdio: Fix -Wtautological-constant-out-of-range-compare on clang
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:01 +0000 (16:13 -0300)] 
stdio: Fix -Wtautological-constant-out-of-range-compare on clang

clang emits an error while building vfprintf-internal for default
case:

error: result of comparison of constant 255 with expression of type
'char' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
          if (spec <= UCHAR_MAX

The test is indeed not required for default non-wide build.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agomath: Suppress more aliases builtin type conflicts
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:00 +0000 (16:13 -0300)] 
math: Suppress more aliases builtin type conflicts

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agosupport: Use CHAR_MAX as maximum value
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:59 +0000 (16:12 -0300)] 
support: Use CHAR_MAX as maximum value

On ABIs with defined 'char' was unsigned type, clang fails to build
support_process_state.c with:

  support_process_state.c:70:21: error: result of comparison of constant  -1 with expression of type 'char' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
     70 |       if (cur_state == -1)
        |           ~~~~~~~~~ ^  ~~
  1 error generated.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agomath: Suppress clang -Wincompatible-library-redeclaration on s_llround
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:55 +0000 (16:12 -0300)] 
math: Suppress clang -Wincompatible-library-redeclaration on s_llround

Clang issues:

  ../sysdeps/ieee754/dbl-64/s_llround.c:83:30: error: incompatible
  redeclaration of library function 'lround'
  [-Werror,-Wincompatible-library-redeclaration]
  libm_alias_double (__lround, lround)
                               ^
  ../sysdeps/ieee754/dbl-64/s_llround.c:83:30: note: 'lround' is a builtin
  with type 'long (double)'

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agomath: use fabs on __ieee754_lgamma_r
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:54 +0000 (16:12 -0300)] 
math: use fabs on __ieee754_lgamma_r

clang issues:

  ../sysdeps/ieee754/dbl-64/e_lgamma_r.c:234:29: error: absolute value function 'fabsf'
  given an argument of type 'double' but has parameter of type 'float' which may cause \
  truncation of value [-Werror,-Wabsolute-value]

It should not matter because the value is 0.0, but using fabs is
simpler than adding a warning suppresion.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agomath: Suppress clang -Wabsolute-value warning on math_check_force_underflow
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:53 +0000 (16:12 -0300)] 
math: Suppress clang -Wabsolute-value warning on math_check_force_underflow

clang warns:

  ../sysdeps/x86/fpu/powl_helper.c:233:3: error: absolute value function
  '__builtin_fabsf' given an argument of type 'typeof (res)' (aka 'long
  double') but has parameter of type 'float' which may cause truncation of
  value [-Werror,-Wabsolute-value]
    math_check_force_underflow (res);
    ^
  ./math-underflow.h:45:11: note: expanded from macro
  'math_check_force_underflow'
        if (fabs_tg (force_underflow_tmp)                         \
            ^
  ./math-underflow.h:27:20: note: expanded from macro 'fabs_tg'
  #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
                     ^
  ../math/math.h:899:16: note: expanded from macro '__MATH_TG'
                 float: FUNC ## f ARGS,           \
                        ^
  <scratch space>:73:1: note: expanded from here
  __builtin_fabsf
  ^

Due the use of _Generic from TG_MATH.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agocatgets: Remove catgets/config.h
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:52 +0000 (16:12 -0300)] 
catgets: Remove catgets/config.h

It simplifies the code a bit and avoid the clang warning:

  ./config.h:12:2: error: #include_next in file found relative to primary
  source file or found by absolute path; will search from start of include
  path [-Werror,-Winclude-next-absolute-path]
  #include_next <config.h>
   ^

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoiconvdata: Fix clang -Wstring-plus-int clang warning
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:50 +0000 (16:12 -0300)] 
iconvdata: Fix clang -Wstring-plus-int clang warning

clang issues an warning adding '{unsigned} int' to a string does not
append to the string.

Use array indexes instead of string addition (it is simpler than
add a supress warning).

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoelf: Fix clang -Wstring-plus-int on rtld.c
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:48 +0000 (16:12 -0300)] 
elf: Fix clang -Wstring-plus-int on rtld.c

clang issues an warning adding 'const unsigned char' to a string
does not append to the string.

Use array indexes instead of string addition (it is simpler than
add a warning suppression).

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agosunrpc: Suppress clang -Wgnu-variable-sized-type-not-at-end warning on struct cmessage
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:47 +0000 (16:12 -0300)] 
sunrpc: Suppress clang -Wgnu-variable-sized-type-not-at-end warning on struct cmessage

clang issues:

svc_unix.c:318:18: error: field 'cmsg' with variable sized type 'struct cmsghdr' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
  318 |   struct cmsghdr cmsg;
      |                  ^

The __msgread explicitly expects that 'struct ucred' is after the 'cmsg',
so suppress the warning.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agonptl: Fix Wincompatible-pointer-types on clang
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:41 +0000 (16:12 -0300)] 
nptl: Fix Wincompatible-pointer-types on clang

clang 18 issues:

pthread_join_common.c:32:3: error: incompatible pointer types passing 'struct pthread **' to parameter of type 'void **' [-Werror,-Wincompatible-pointer-types]
   32 |   atomic_compare_exchange_weak_acquire (&arg, &self, NULL);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/atomic.h:188:39: note: expanded from macro 'atomic_compare_exchange_weak_acquire'
  188 |   __atomic_compare_exchange_n ((mem), (expected), (desired), 1,

Use a void * type instead.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoSuppress -Wmaybe-uninitialized only for gcc
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:40 +0000 (16:12 -0300)] 
Suppress -Wmaybe-uninitialized only for gcc

The warning is not supported by clang.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoconfigure: Use -Wno-maybe-uninitialized iff compiler supports it
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:39 +0000 (16:12 -0300)] 
configure: Use -Wno-maybe-uninitialized iff compiler supports it

clang does not support the flag.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agoDisable __USE_EXTERN_INLINES for clang
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:38 +0000 (16:12 -0300)] 
Disable __USE_EXTERN_INLINES for clang

clang does not allow to redefine attributes after function declaration.
Although it work for external usage, its breaks the build for internal
symbol that glibc provides as optimization (for instance bsearch
with stdlib-bsearch.h or __cmsg_nxthdr).

Disable such optimization for clang while building glibc.

Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agomalloc: Do not call madvise if heap's oldsize >= THP size
Dev Jain [Fri, 17 Oct 2025 14:18:43 +0000 (19:48 +0530)] 
malloc: Do not call madvise if heap's oldsize >= THP size

Linux handles virtual memory in Virtual Memory Areas (VMAs). The
madvise(MADV_HUGEPAGE) call works on a VMA granularity, which sets the
VM_HUGEPAGE flag on the VMA. This flag is invariant of the mprotect()
syscall which is used in growing the secondary heaps. Therefore, we
need to call madvise() only when we are sure that VM_HUGEPAGE was not
previously set, which is only in the case when h->size < mp_.thp_pagesize.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agomicroblaze: fix __syscall_cancel_arch (BZ 33547)
Luc Michel [Fri, 17 Oct 2025 09:27:12 +0000 (11:27 +0200)] 
microblaze: fix __syscall_cancel_arch (BZ 33547)

The __syscall_cancel_arch function has an epilogue that does not match
the prologue. The stack is not used and the return address still lies in
r15 when reaching the epilogue. Fix the epilogue by simply returning
from the function.

Signed-off-by: Luc Michel <luc.michel@amd.com>
Tested-by: gopi@sankhya.com
Reviewed-by: Neal Frager <neal.frager@amd.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agolocale: Fix implicit conversion on collate_finish
Adhemerval Zanella [Fri, 17 Oct 2025 19:12:49 +0000 (16:12 -0300)] 
locale: Fix implicit conversion on collate_finish

Clang issues:

programs/ld-collate.c:1824:55: error: implicit conversion from 'unsigned
long' to 'unsigned int' changes value from 18446744073709551615 to
4294967295 [-Werror,-Wconstant-conversion]
  collate->undefined.used_in_level = need_undefined ? ~0ul : 0;
                                   ~                  ^~~~

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agoposix: Only enable -Wmaybe-uninitialized suppression on gcc
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:26 +0000 (16:13 -0300)] 
posix: Only enable -Wmaybe-uninitialized suppression on gcc

clang does not support this option.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agomalloc: Use INT_ADD_OVERFLOW instead of __builtin_add_overflow_p
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:25 +0000 (16:13 -0300)] 
malloc: Use INT_ADD_OVERFLOW instead of __builtin_add_overflow_p

clang does not support the __builtin_*_overflow_p builtins, on gcc
the macros will call __builtin_*_overflow_p.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 weeks agoAdjust stdint for clang-20
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:21 +0000 (16:13 -0300)] 
Adjust stdint for clang-20

clang 20 adds both __INT64_C and __UINT64_C as builtins, but different
than gcc it does not undef them in its stdint wrapper.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoBuild glibc with -ftrapping-math
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:18 +0000 (16:13 -0300)] 
Build glibc with -ftrapping-math

GCC enables it by default, clang in the other hand sets -fno-trapping-math.
This is required to fix some math and stdlib tests that explicit raises
floating point exceptions:

math/test-double-canonicalize.out
testing double (without inline functions)
Failure: canonicalize (max_value): Exception "Overflow" set
Failure: canonicalize (max_value): Exception "Inexact" set
Failure: canonicalize (-max_value): Exception "Overflow" set
Failure: canonicalize (-max_value): Exception "Inexact" set
Failure: canonicalize_downward (max_value): Exception "Overflow" set
Failure: canonicalize_downward (max_value): Exception "Inexact" set
Failure: canonicalize_downward (-max_value): Exception "Overflow" set
Failure: canonicalize_downward (-max_value): Exception "Inexact" set
Failure: canonicalize_towardzero (max_value): Exception "Overflow" set
Failure: canonicalize_towardzero (max_value): Exception "Inexact" set
Failure: canonicalize_towardzero (-max_value): Exception "Overflow" set
Failure: canonicalize_towardzero (-max_value): Exception "Inexact" set
Failure: canonicalize_upward (max_value): Exception "Overflow" set
Failure: canonicalize_upward (max_value): Exception "Inexact" set
Failure: canonicalize_upward (-max_value): Exception "Overflow" set
Failure: canonicalize_upward (-max_value): Exception "Inexact" set

test-float-catanh.out
testing float (without inline functions)
Failure: Real part of: catanh (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_downward (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_towardzero (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
Failure: Real part of: catanh_upward (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agolinux: Fix function point cast on vDSO handling
Adhemerval Zanella [Fri, 17 Oct 2025 19:13:16 +0000 (16:13 -0300)] 
linux: Fix function point cast on vDSO handling

There is no need to cast to avoid, both pointer already have the
expected type.

It fixes the clang -Wpointer-type-mismatch error:

../sysdeps/unix/sysv/linux/gettimeofday.c:43:6: error: pointer type mismatch ('int (*)(struct timeval *, void *)' and 'void *') [-Werror,-Wpointer-type-mismatch]
   41 | libc_ifunc (__gettimeofday,
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   42 |             GLRO(dl_vdso_gettimeofday) != NULL
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   43 |             ? VDSO_IFUNC_RET (GLRO(dl_vdso_gettimeofday))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   44 |             : (void*) __gettimeofday_syscall)
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:789:53: note: expanded from macro 'libc_ifunc'
  789 | #define libc_ifunc(name, expr) __ifunc (name, name, expr, void, INIT_ARCH)
      |                                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:705:34: note: expanded from macro '__ifunc'
  705 |   __ifunc_args (type_name, name, expr, init, arg)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
./../include/libc-symbols.h:677:38: note: expanded from macro '__ifunc_args'
  677 |   __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__);  \
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:667:33: note: expanded from macro '__ifunc_resolver'
  667 |     __typeof (type_name) *res = expr;                                   \
      |                                 ^~~~

Reviewed-by: Sam James <sam@gentoo.org>