Commit Graph

42354 Commits

Author SHA1 Message Date
Adhemerval Zanella 6bc4b1342f stdlib: Avoid strlen plt with clang-20 2025-04-09 13:36:16 -03:00
Adhemerval Zanella ddc1ad904c bench-malloc-thread: Add libm for powf
The bench-malloc-thread.c:63 does use powf and compiler might not
optimzie it away.
2025-04-09 13:36:16 -03:00
Adhemerval Zanella 7a328725a5 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.
2025-04-09 13:36:16 -03:00
Adhemerval Zanella 60055b4d26 benchtests: Use __f128 on ilogbf128-inputs constants
The f128 is not a valid floating constant suffix on clang.
2025-04-09 13:36:15 -03:00
Adhemerval Zanella 7b4066760b 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.
2025-04-09 13:36:15 -03:00
Adhemerval Zanella 2c905d2664 aarch64: Fix gcs linker flags
clang does not work by using whitespace for defining the -z option:

$ make test t=misc/tst-gcs-disabled
[...]
clang: error: no such file or directory: 'gcs=always'

Use the usual comma separate way.
2025-04-09 13:36:15 -03:00
Adhemerval Zanella b4389f55ed Handle abort call for -fexceptions call
clang might generate an abort call when cleanup functions (set by
__attribute__ ((cleanup)) calls functions not marked as nothrow.
We can mitigate by marking some internal functions as __THROW,
but it is not possible for functions that issue used-provided
callbacks (for instance pthread_once).
2025-04-09 13:36:15 -03:00
Adhemerval Zanella b2a5c3abfd 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.
2025-04-09 13:36:14 -03:00
Adhemerval Zanella 4a9da6022e 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.
2025-04-09 13:36:14 -03:00
Adhemerval Zanella e371da6b7c elf: Fix -fsemantic-interposition for clang-20
clang-20 defaults to -Wunused-command-line-argument, which makes the
option check fails because of ununsed '-c' option.
2025-04-09 13:36:14 -03:00
Adhemerval Zanella fa83d4c15b 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).
2025-04-09 13:36:14 -03:00
Adhemerval Zanella 8bbc0864ec 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
2025-04-09 13:36:13 -03:00
Adhemerval Zanella b46a10d0a1 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
2025-04-09 13:36:13 -03:00
Adhemerval Zanella af992bb633 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
2025-04-09 13:36:13 -03:00
Adhemerval Zanella 7275d0fe5b math: Handle fabsf128 intra PLT for !__USE_EXTERN_INLINES
If compiler does not support __USE_EXTERN_INLINES we need to route
fabsf128 call to an internal symbol.
2025-04-09 13:36:13 -03:00
Adhemerval Zanella 3fff436ecf 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).
2025-04-09 13:36:12 -03:00
Adhemerval Zanella 628d34afdc 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.
2025-04-09 13:36:12 -03:00
Fangrui Song c8f302070f configure: remove overly restrictive check for clang 2025-04-09 13:36:12 -03:00
Adhemerval Zanella 71ca6b65dc riscv: Suppress clang -Wignored-attributes for feupdateenv
clang warns that the alias will be always resolve to
__GI___feupdateenv even if weak definition of __GI_feupdateenv
is overridden, which is really the intention.
2025-04-09 13:36:12 -03:00
Adhemerval Zanella 0a5bfc572f string: Suppress clang -Wignored-attributes on strlen
clang warns that the alias will be always resolve to __strlen
even if weak definition of __GI_strlen is overridden, which is
really the intention.
2025-04-09 13:36:11 -03:00
Adhemerval Zanella a85f4b3841 riscv: Do not use cfi_label when building with clang
The .cfi_label is a gas extension not supported by clang.  From a
ziglang discussion [1], it seems that it is not really required.

[1] https://github.com/ziglang/zig/issues/3340
2025-04-09 13:36:11 -03:00
Adhemerval Zanella f3f0dd5677 elf: Fix localplt issue with clang
Recent clang version optimizes some loops contructions to strlen [1],
so adds the symbol on symbol-hacks.h to call the internal __GI_strlen.

[1] facd7dfc80
2025-04-09 13:36:06 -03:00
Adhemerval Zanella d338fd509e 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] facd7dfc80
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 575dacdb4e 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 0df5083453 Check if linker sets --no-undefined-version by default
Recent lld version default to --no-undefined-version, which triggers
errors when building multiple libraries.  For ld.so 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 way version script is created with multiple missing symbols is
to simplify the build for multiple ABIs with different symbol
symbols.  For instance, __stack_chk_guard is defined by default to
avoid the need of each ABI to add this symbol on its own version
script depending of which stack protector ABI it uses.

The libc.so warnings does show unused symbol being defined (like
_IO_clearerr), which might trigger potential errors depending of
how symbol are exported.  However, since we do have teh ABI checks
for missing and extra symbol the linker extra checks are not really
required.  So disable them for now.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella b42c357db3 Supress unused command arguments warning with clang
clang 20 triggers an error 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 22b910444b 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
2025-04-09 08:45:23 -03:00
Adhemerval Zanella f5d572b9ed Add fall-through between switch labels annotations
The clang default to warning for missing fall-through and it does
not support all comment-like annotation that gcc does.  Use a
proper attribute instead.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 1bda585de4 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;                                   \
      |                                 ^~~~
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 6ec68090bb elf: Only defines _dl_tls_allocate_active for SHARED
clang issues:

dl-tls.c:108:1: error: unused function '_dl_tls_allocate_active' [-Werror,-Wunused-function]
  108 | _dl_tls_allocate_active (void)
      | ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 46d1761fe0 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella e75e86e03b Fix -Wno-ignored-attributes configure check 2025-04-09 08:45:23 -03:00
Adhemerval Zanella ebb17d1f13 aarch64: Use NO_MATH_REDIRECT on pow_advsimd.c
clang does not optimize the fma calls, instead issuing __fma.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 005c020d98 x86: Use __always_inline on ifunc auxiliary functions
clang does correctly propagate the no_stack_protector attribute for
inline function used in ifunc selectors.  For instance, the exp function
is expanded as:

  static inline void *
  ieee754_exp_ifunc_selector (void)
  {
    [...]
  }

  extern __typeof (__redirect_ieee754_exp) __ieee754_exp
    __attribute__ ((ifunc ("__ieee754_exp" "_ifunc")));

  static __attribute__((no_stack_protector)) __typeof (__redirect_ieee754_exp) *i
  __ieee754_exp_ifunc (void)
  {
    __typeof (__redirect_ieee754_exp) *res = ieee754_exp_ifunc_selector ();
    return res;
  };

The ifunc selection ended being compiled with -fstack-protector, and
with debug function set to the ifunc selector
(ieee754_exp_ifunc_selector) auxiliary function instead of the
selector itself.

The ifunc selector are called early, before TCB is setup, which
causes SIGSEGV for statically linked binaries.

To fix it use __always_inline instead of inline.  It should not change
code generation on gcc and it fixes the code generation issue on
clang.  It also fixes function debug information.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 9b474dfc60 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).
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 46bf26b9bb x86: math: Avoid the use of __libgcc_cmp_return__ for __gcc_CMPtype
clang does not support '__attribute__ ((mode (__libgcc_cmp_return__)))',
so use a more close related type instead fo the default 'int'.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella a199019857 x86: Use -msse2avx iff compiler supports it
clang-19 does support it, but it should be gated as an option to
assemble (either with -Wa or -Xassembler).  So add a test for -Wa
as well if -msse2avx is not supported.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella e143c8e6c7 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 1ae9eb770c 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 54a1c7b88a math: Suppress more aliases builtin type conflicts 2025-04-09 08:45:23 -03:00
Adhemerval Zanella 622fd5d011 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 24b75d5b85 posix: Defined _POSIX_VDISABLE as integer literal
The constant should be used with c_cc, which for all supported ABIs
is defined as unsigned char.  By using it as literar char constant,
clang triggers an error when compared with signal literal o ABIs that
define 'char' as unsigned.

On aarch64, clang shows:

  ../sysdeps/posix/fpathconf.c:118:21: error: right side of operator
  converted from negative value to unsigned: -1 to 18446744073709551615
  [-Werror]
  #if _POSIX_VDISABLE == -1
    ~~~~~~~~~~~~~~~ ^  ~~
2025-04-09 08:45:23 -03:00
Adhemerval Zanella 51a9a82dc0 string: Use asm alias instead of symbol redirections for stpcpy and mempcpy
Commit 939da41143 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.
2025-04-09 08:45:23 -03:00
Adhemerval Zanella b92234b8b1 math: Use -fexcess-precision=standard iff compiler supports it 2025-04-09 08:45:23 -03:00
Adhemerval Zanella f819dd3396 Use $(config-cflags-wno-ignored-attributes) on some files
clang emits an warning when a double alias redirection is used, to warn
the the original symbol will be used even when weak definition is
overridden.  Howerver, this is a common pattern for weak_alias, where
multiple alias are set to same symbol.
2025-04-09 08:45:22 -03:00
Adhemerval Zanella f3e81b42e2 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)'
2025-04-09 08:45:22 -03:00
Adhemerval Zanella 4e6572b702 math: use fabs on __ieee754_lgamma_r 2025-04-09 08:45:22 -03:00
Adhemerval Zanella e547fed5ac math: Suppress clang 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
  ^
2025-04-09 08:45:22 -03:00
Adhemerval Zanella 9aa53dede8 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>
   ^
2025-04-09 08:45:22 -03:00
Adhemerval Zanella 35fae52dfc iconvdata: Remove use of GNU old-style field designator extension
Use the C99 syntax instead.
2025-04-09 08:45:22 -03:00