]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
6 months agonew inputs with large errors for [a]cospi, [a]sinpi, [a]tanpi, atan2pi
Paul Zimmermann [Fri, 20 Dec 2024 09:41:38 +0000 (10:41 +0100)] 
new inputs with large errors for [a]cospi, [a]sinpi, [a]tanpi, atan2pi

These inputs were generated with the programs from
https://gitlab.inria.fr/zimmerma/math_accuracy,
with rounding to nearest:

* for univariate binary32 functions by exhaustive search
* for other functions with the "threshold" parameter up to 10^6

6 months agostdlib: fix lint failure
Sam James [Thu, 2 Jan 2025 17:09:14 +0000 (17:09 +0000)] 
stdlib: fix lint failure

Fixes: d5bceac99d24af1131b90027dab267e437b65cd1
6 months agostdlib: random_r: fix unaligned access in initstate and initstate_r [BZ #30584]
Sam James [Tue, 10 Dec 2024 01:21:46 +0000 (01:21 +0000)] 
stdlib: random_r: fix unaligned access in initstate and initstate_r [BZ #30584]

The initstate{,_r} interfaces are documented in BSD as needing an aligned
array of 32-bit values, but neither POSIX nor glibc's own documentation
require it to be aligned. glibc's documentation says it "should" be a power
of 2, but not must.

Use memcpy to read and write to `state` to handle such an unaligned
argument.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoassert: Remove the use of %n from __assert_fail_base (BZ #32456)
Adhemerval Zanella [Mon, 30 Dec 2024 19:36:18 +0000 (16:36 -0300)] 
assert: Remove the use of %n from __assert_fail_base (BZ #32456)

The require size for mmap can be inferred from __vasprintf return
value.  It also fixes tst-assert-2 when building with --enable-fortify,
where even if the format is not translated, __readonly_area fails
because malloc can not be used.

Checked on aarch64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoTranslations: Regenerate libc.pot
Adhemerval Zanella [Mon, 30 Dec 2024 19:36:17 +0000 (16:36 -0300)] 
Translations: Regenerate libc.pot

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoelf: Remove the remaining uses of GET_ADDR_OFFSET
Florian Weimer [Thu, 2 Jan 2025 12:45:27 +0000 (13:45 +0100)] 
elf: Remove the remaining uses of GET_ADDR_OFFSET

Expand the macro where it is used in static definitions of
__tls_get_addr.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agoelf: Use TLS_DTV_OFFSET in __tls_get_addr
Florian Weimer [Thu, 2 Jan 2025 12:45:27 +0000 (13:45 +0100)] 
elf: Use TLS_DTV_OFFSET in __tls_get_addr

This fixes commit 5e249192cac7354af02a7347a0d8c984e0c88ed3 ("elf:
Remove the GET_ADDR_ARGS and related macros from the TLS code"):
GET_ADDR_ARGS was indeed unused, but GET_ADDR_OFFSET was used
on several targets, those that define TLS_DTV_OFFSET.  Instead
of reintroducing GET_ADDR_OFFSET, use TLS_DTV_OFFSET directly,
now that it is defined on all targets.

In the new tls_get_addr_adjust helper function, add a cast to
uintptr_t to help the s390 case, where the offset can be positive or
negative, depending on the addresses malloc returns.  The cast avoids
pointer wraparound/overflow.  The outer uintptr_t cast is needed
to suppress a warning on x86-64 x32 about mismatched integer/pointer
sizes.

Eventually this offset should be folded into the DTV addresses
themselves, to eliminate the subtraction on the TLS fast path.
This will require an adjustment to libthread_db because the
debugger interface currently returns unadjusted pointers.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agos390: Define TLS_DTV_OFFSET instead of GET_ADDR_OFFSET
Florian Weimer [Thu, 2 Jan 2025 12:45:27 +0000 (13:45 +0100)] 
s390: Define TLS_DTV_OFFSET instead of GET_ADDR_OFFSET

This will be used in __tls_get_addr to adjust the returned pointer
value.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agoelf: Introduce generic <dl-tls.h>
Florian Weimer [Thu, 2 Jan 2025 12:45:27 +0000 (13:45 +0100)] 
elf: Introduce generic <dl-tls.h>

On arc, the definition of TLS_DTV_UNALLOCATED now comes from
<dl-dtv.h>.

For x86-64 x32, a separate version is needed because unsigned long int
is 32 bits on this target.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agopowerpc: Update acosf ulps
Florian Weimer [Thu, 2 Jan 2025 10:56:42 +0000 (11:56 +0100)] 
powerpc: Update acosf ulps

As seen on powerpc64le-linux-gnu with GCC 11 defaulting to POWER9
instructions.

6 months agohtl: move pthread_mutexattr_setprioceiling, pthread_mutexattr_getprioceiling into...
gfleury [Tue, 31 Dec 2024 13:49:09 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_setprioceiling, pthread_mutexattr_getprioceiling into libc.

Message-ID: <20241231134909.1166440-9-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_{setrobust, setrobust_np}, pthread_mutexattr_{getrobust...
gfleury [Tue, 31 Dec 2024 13:49:08 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_{setrobust, setrobust_np}, pthread_mutexattr_{getrobust, getrobust_np} into libc.

Message-ID: <20241231134909.1166440-8-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_setpshared, pthread_mutexattr_getpshared into libc.
gfleury [Tue, 31 Dec 2024 13:49:07 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_setpshared, pthread_mutexattr_getpshared into libc.

Message-ID: <20241231134909.1166440-7-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_settype, pthread_mutexattr_gettype into libc.
gfleury [Tue, 31 Dec 2024 13:49:06 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_settype, pthread_mutexattr_gettype into libc.

Message-ID: <20241231134909.1166440-6-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_setprotocol into libc.
Samuel Thibault [Wed, 1 Jan 2025 22:51:53 +0000 (23:51 +0100)] 
htl: move pthread_mutexattr_setprotocol into libc.

Message-ID: <20241231134909.1166440-5-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_getprotocol into libc.
gfleury [Tue, 31 Dec 2024 13:49:04 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_getprotocol into libc.

Message-ID: <20241231134909.1166440-4-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_destroy into libc.
gfleury [Tue, 31 Dec 2024 13:49:03 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_destroy into libc.

Message-ID: <20241231134909.1166440-3-gfleury@disroot.org>

6 months agohtl: move pthread_mutexattr_init into libc.
gfleury [Tue, 31 Dec 2024 13:49:02 +0000 (15:49 +0200)] 
htl: move pthread_mutexattr_init into libc.

Message-ID: <20241231134909.1166440-2-gfleury@disroot.org>

6 months agobits/socket.h: Update to recent BSD definition
Samuel Thibault [Wed, 1 Jan 2025 21:07:42 +0000 (22:07 +0100)] 
bits/socket.h: Update to recent BSD definition

The old BSD 4.4 definition (not used by Linux) was not 64b-proof: the
cmsg_data field is supposed to CMSG_ALIGN'ed (as can be also seen in the
CMSG_LEN macro).

Suggested-by: Diego Nieto Cid <dnietoc@gmail.com>
6 months agoDon't update copyright notices in Linux licenses
Paul Eggert [Wed, 1 Jan 2025 20:16:06 +0000 (12:16 -0800)] 
Don't update copyright notices in Linux licenses

* scripts/update-copyrights: Do not update copyright notices
in licenses imported from the Linux kernel.
This should prevent glitches such as those fixed in my
recent commit.

6 months agoFix license typo induced by update-copyrighyt
Paul Eggert [Wed, 1 Jan 2025 19:07:29 +0000 (11:07 -0800)] 
Fix license typo induced by update-copyrighyt

6 months agoUpdate copyright dates not handled by scripts/update-copyrights
Paul Eggert [Wed, 1 Jan 2025 18:31:31 +0000 (10:31 -0800)] 
Update copyright dates not handled by scripts/update-copyrights

I've updated copyright dates in glibc for 2025.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.

6 months agoUpdate copyright in generated files by running "make"
Paul Eggert [Wed, 1 Jan 2025 18:25:08 +0000 (10:25 -0800)] 
Update copyright in generated files by running "make"

6 months agoUpdate copyright dates with scripts/update-copyrights
Paul Eggert [Wed, 1 Jan 2025 18:14:45 +0000 (10:14 -0800)] 
Update copyright dates with scripts/update-copyrights

6 months agoPass glibc pre-commit checks
Paul Eggert [Wed, 1 Jan 2025 19:16:35 +0000 (11:16 -0800)] 
Pass glibc pre-commit checks

This is needed for the next patch which updates copyright dates.
* assert/test-assert-2.c: Remove trailing white space.
* elf/tst-startup-errno.c: Remove trailing empty lines.

6 months agomlock, mlock2, munlock: Tell the compiler we don't dereference the pointer
Xi Ruoyao [Thu, 26 Dec 2024 04:51:18 +0000 (12:51 +0800)] 
mlock, mlock2, munlock: Tell the compiler we don't dereference the pointer

Since https://gcc.gnu.org/r11-959, the compiler emits
-Wmaybe-uninitialized if a const pointer to an uninitialized buffer is
passed.  Tell the compiler we don't dereference the pointer to remove
the false alarm.

Link: https://gcc.gnu.org/PR118194
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoelf: Add glibc.rtld.execstack
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:45 +0000 (14:36 -0300)] 
elf: Add glibc.rtld.execstack

The new tunable can be used to control whether executable stacks are
allowed from either the main program or dependencies.  The default is
to allow executable stacks.

The executable stacks default permission is checked agains the one
provided by the PT_GNU_STACK from program headers (if present).  The
tunable also disables the stack permission change if any dependency
requires an executable stack at loading time.

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

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoelf: Add tst-execstack-prog-static
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:44 +0000 (14:36 -0300)] 
elf: Add tst-execstack-prog-static

Similar to tst-execstack-prog, check if executable stacks works for
statically linked programs.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoelf: Do not change stack permission on dlopen/dlmopen
Adhemerval Zanella [Thu, 28 Nov 2024 17:36:43 +0000 (14:36 -0300)] 
elf: Do not change stack permission on dlopen/dlmopen

If some shared library loaded with dlopen/dlmopen requires an executable
stack, either implicitly because of a missing GNU_STACK ELF header
(where the ABI default flags implies in the executable bit) or explicitly
because of the executable bit from GNU_STACK; the loader will try to set
the both the main thread and all thread stacks (from the pthread cache)
as executable.

Besides the issue where any __nptl_change_stack_perm failure does not
undo the previous executable transition (meaning that if the library
fails to load, there can be thread stacks with executable stacks), this
behavior was used on a CVE [1] as a vector for RCE.

This patch changes that if a shared library requires an executable
stack, and the current stack is not executable, dlopen fails.  The
change is done only for dynamically loaded modules, if the program
or any dependency requires an executable stack, the loader will still
change the main thread before program execution and any thread created
with default stack configuration.

[1] https://www.qualys.com/2023/07/19/cve-2023-38408/rce-openssh-forwarded-ssh-agent.txt

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

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoelf: Cleanup and improve tst-execstack
Adhemerval Zanella [Thu, 26 Dec 2024 14:25:28 +0000 (11:25 -0300)] 
elf: Cleanup and improve tst-execstack

Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoUse GCC 14 branch in build-many-glibcs.py
H.J. Lu [Tue, 31 Dec 2024 07:56:23 +0000 (15:56 +0800)] 
Use GCC 14 branch in build-many-glibcs.py

Tested with build-many-glibcs.py with

--exclude m68k-linux-gnu-coldfire-soft

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoINSTALL, NEWS: Document requirement of gawk with MPFR support
Andreas K. Hüttel [Fri, 27 Dec 2024 18:31:07 +0000 (19:31 +0100)] 
INSTALL, NEWS: Document requirement of gawk with MPFR support

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
6 months agoMention CORE-MATH optimize routines on NEWS
Adhemerval Zanella [Thu, 26 Dec 2024 12:11:06 +0000 (09:11 -0300)] 
Mention CORE-MATH optimize routines on NEWS

Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
6 months agox86-64: Reorder dynamic linker list in ldd script (bug 32508)
Florian Weimer [Mon, 30 Dec 2024 11:41:51 +0000 (12:41 +0100)] 
x86-64: Reorder dynamic linker list in ldd script (bug 32508)

Move the x86-64 loader first, before the i386 and x32 loaders.  In
most cases, it's the loader the script needs.  This avoids an error
message if the i386 loader does not work.

The effect of this change to the generated ldd script looks like this:

-RTLDLIST="/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2 /libx32/ld-linux-x32.so.2"
+RTLDLIST="/lib64/ld-linux-x86-64.so.2 /lib/ld-linux.so.2 /libx32/ld-linux-x32.so.2"

Reviewed-by: Sam James <sam@gentoo.org>
6 months agonptl: hppa: replace __get_cr27 with __thread_pointer
Michael Jeanson [Fri, 27 Dec 2024 16:41:02 +0000 (17:41 +0100)] 
nptl: hppa: replace __get_cr27 with __thread_pointer

The addition of the new thread_pointer.h header on HPPA resulted in
duplicated inline asm to get the current thread pointer from the cr27
register.

Include thread_pointer.h in tls.h and replace __get/set_cr27() with
__set_/thread_pointer() with the appropriate casts.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
6 months agonptl: Add <thread_pointer.h> for hppa
Michael Jeanson [Fri, 27 Dec 2024 16:41:02 +0000 (17:41 +0100)] 
nptl: Add <thread_pointer.h> for hppa

This will be required by the rseq extensible ABI implementation on all
Linux architectures exposing the '__rseq_size' and '__rseq_offset'
symbols to set the initial value of the 'cpu_id' field which can be used
by applications to test if rseq is available and registered. As long as
the symbols are exposed it is valid for an application to perform this
test even if rseq is not yet implemented in libc for this architecture.

Compile tested with build-many-glibcs.py but I don't have access to any
hardware to run the tests.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
6 months agolibio: asprintf should write NULL upon failure
Florian Weimer [Fri, 27 Dec 2024 08:17:41 +0000 (09:17 +0100)] 
libio: asprintf should write NULL upon failure

This was suggested most recently by Solar Designer, noting
that code replacing vsprintf with vasprintf in a security fix
was subtly wrong:

  Re: GStreamer Security Advisory 2024-0003: Orc compiler
  stack-based buffer overflow
  <https://www.openwall.com/lists/oss-security/2024/07/26/2>

Previous libc-alpha discussions:

  I: [PATCH] asprintf error handling fix
  <https://inbox.sourceware.org/libc-alpha/20011205185828.GA8376@ldv.office.alt-linux.org/>

  asprintf() issue
  <https://inbox.sourceware.org/libc-alpha/CANSoFxt-cdc-+C4u-rTENMtY4X9RpRSuv+axDswSPxbDgag8_Q@mail.gmail.com/>

I don't think we need a compatibility symbol for this.  As the
GStreamer example shows, this change is much more likely to fix bugs
than cause compatibility issues.

Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
Suggested-by: Archie Cobbs <archie.cobbs@gmail.com>
Suggested-by: Solar Designer <solar@openwall.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agonptl: More useful padding in struct pthread
Florian Weimer [Tue, 17 Dec 2024 08:20:20 +0000 (09:20 +0100)] 
nptl: More useful padding in struct pthread

The previous use of padding within a union made it impossible to
re-use the padding for GLIBC_PRIVATE ABI preservation because
tcbhead_t could use up all of the padding (as was historically the
case on x86-64).  Allocating padding unconditionally addresses this
issue.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agoelf: Remove the GET_ADDR_ARGS and related macros from the TLS code
Florian Weimer [Mon, 23 Dec 2024 12:55:49 +0000 (13:55 +0100)] 
elf: Remove the GET_ADDR_ARGS and related macros from the TLS code

This was used to manage an IA-64 ABI divergence is no longere needed
after the IA-64 removal.

(It should be possible to encode all the required information in
one machine word, so the pointer indirection is really unnecessary.
Technically, none of this is part of the ABI, so perhaps it's
possible to do this retroactively.  See bug 27404.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
6 months agohurd: Avoid asm statements which return
Samuel Thibault [Thu, 26 Dec 2024 22:11:28 +0000 (23:11 +0100)] 
hurd: Avoid asm statements which return

They are not supposed to change flow control.

This fixes miscompilation with gcc 14.2.0 which then drops code, see
https://lists.gnu.org/archive/html/bug-hurd/2024-11/msg00145.html

6 months agobuild-many-glibcs.py: Add --exclude option
H.J. Lu [Tue, 24 Dec 2024 21:05:31 +0000 (05:05 +0800)] 
build-many-glibcs.py: Add --exclude option

m68k-linux-gnu-coldfire-soft GCC and glibc often won't build due to

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103370

which results in build-many-glibcs.py failure.  Add an option, --exclude,
to exclude some targets.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostdio-common: Tweak comment in Makefile
Sam James [Tue, 24 Dec 2024 11:38:09 +0000 (11:38 +0000)] 
stdio-common: Tweak comment in Makefile

Followup to 5a96da210c15e18c3c5298dc23a9e2e57691b6c6.

6 months agostdio-common: Use clang with bugfix for bug28
Dmitry Chestnykh [Tue, 24 Dec 2024 08:52:35 +0000 (11:52 +0300)] 
stdio-common: Use clang with bugfix for bug28

The issue that was the cause of hang was fixed in upstream.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
6 months agoNEWS: Mention testing glibc build with a different set of compilers
H.J. Lu [Mon, 23 Dec 2024 21:20:43 +0000 (05:20 +0800)] 
NEWS: Mention testing glibc build with a different set of compilers

Also document C and C++ compilers used to test glibc should come from
the same set of compilers.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agosupport: Add support_record_failure_barrier
Florian Weimer [Mon, 23 Dec 2024 12:57:55 +0000 (13:57 +0100)] 
support: Add support_record_failure_barrier

This can be used to stop execution after a TEST_COMPARE_BLOB
failure, for example.

6 months agoio: statx, fstatat: Drop nonnull attribute on the path argument
Miao Wang [Mon, 23 Dec 2024 09:30:43 +0000 (10:30 +0100)] 
io: statx, fstatat: Drop nonnull attribute on the path argument

Since Linux 6.11 the kernel allows path to be NULL if flags &
AT_EMPTY_PATH.  Let's allow users to take the advantage if they don't
care running on old kernels.

Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
6 months agoconfigure: Improve configure output for C++ Compiler
H.J. Lu [Mon, 23 Dec 2024 00:11:58 +0000 (08:11 +0800)] 
configure: Improve configure output for C++ Compiler

Change configure output for C++ Compiler from

...
checking -finput-charset=ascii in testing... -finput-charset=ascii
checking -finput-charset=ascii in testing... -finput-charset=ascii
...

to

...
checking -finput-charset=ascii in testing... -finput-charset=ascii
checking g++ -finput-charset=ascii in testing... -finput-charset=ascii
...

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agogetaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]
H.J. Lu [Tue, 17 Dec 2024 07:18:36 +0000 (15:18 +0800)] 
getaddrinfo.c: Avoid uninitialized pointer access [BZ #32465]

Add valid_decimal_value to check valid decimal value in a string to
avoid uninitialized endp in add_prefixlist and gaiconf_init as reported
by Clang 19:

./getaddrinfo.c:1884:11: error: variable 'endp' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
 1884 |       && (cp == NULL
      |           ^~~~~~~~~~
./getaddrinfo.c:1887:11: note: uninitialized use occurs here
 1887 |       && *endp == '\0'
      |           ^~~~
./getaddrinfo.c:1884:11: note: remove the '||' if its condition is always false
 1884 |       && (cp == NULL
      |           ^~~~~~~~~~
 1885 |           || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
      |           ~~
./getaddrinfo.c:1875:13: note: initialize the variable 'endp' to silence this warning
 1875 |   char *endp;
      |             ^
      |              = NULL

This fixes BZ #32465.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agohtl: move pthread_cond_timedwait, pthread_cond_clockwait, pthread_cond_wait into...
gfleury [Thu, 19 Dec 2024 20:37:27 +0000 (22:37 +0200)] 
htl: move pthread_cond_timedwait, pthread_cond_clockwait, pthread_cond_wait into libc.

Message-ID: <20241219203727.669825-9-gfleury@disroot.org>

6 months agohtl: move __pthread_mutex_checklocked into libc.
gfleury [Thu, 19 Dec 2024 20:37:26 +0000 (22:37 +0200)] 
htl: move __pthread_mutex_checklocked into libc.

move out __getpid from pt-mutex.h
and in pt-mutex-* include <unistd.h> where
__getpid was called

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-8-gfleury@disroot.org>

6 months agohtl: move __pthread_timedblock, __pthread_timedblock_intr, __pthread_block, __pthread...
gfleury [Thu, 19 Dec 2024 20:37:25 +0000 (22:37 +0200)] 
htl: move __pthread_timedblock, __pthread_timedblock_intr, __pthread_block, __pthread_block_intr into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-7-gfleury@disroot.org>

6 months agohtl: move pthread_cond_signal into libc.
gfleury [Thu, 19 Dec 2024 20:37:24 +0000 (22:37 +0200)] 
htl: move pthread_cond_signal into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-6-gfleury@disroot.org>

6 months agohtl: move pthread_cond_broadcast into libc.
gfleury [Thu, 19 Dec 2024 20:37:23 +0000 (22:37 +0200)] 
htl: move pthread_cond_broadcast into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-5-gfleury@disroot.org>

6 months agohtl: move pthread_cond_destroy into libc.
gfleury [Thu, 19 Dec 2024 20:37:22 +0000 (22:37 +0200)] 
htl: move pthread_cond_destroy into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-4-gfleury@disroot.org>

6 months agohtl: move __pthread_wakeup into libc.
gfleury [Thu, 19 Dec 2024 20:37:21 +0000 (22:37 +0200)] 
htl: move __pthread_wakeup into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-3-gfleury@disroot.org>

6 months agohtl: move pthread_cond_init into libc.
gfleury [Thu, 19 Dec 2024 20:37:20 +0000 (22:37 +0200)] 
htl: move pthread_cond_init into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20241219203727.669825-2-gfleury@disroot.org>

6 months agoassert/test-assert-2.c: Include <unistd.h>
Samuel Thibault [Sun, 22 Dec 2024 22:33:27 +0000 (23:33 +0100)] 
assert/test-assert-2.c: Include <unistd.h>

For _exit declaration.

6 months agostdio-common: Suppress Clang warnings on scanf13.c
H.J. Lu [Sun, 22 Dec 2024 21:12:03 +0000 (05:12 +0800)] 
stdio-common: Suppress Clang warnings on scanf13.c

Suppress Clang warnings on stdio-common/scanf13.c:

1. Before this commit:

scanf13.c:43:17: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
   43 |               "A%mS%10mls%4ml[bcd]%4mCB", &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |                    ~~~~^
scanf13.c:43:22: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
   43 |               "A%mS%10mls%4ml[bcd]%4mCB", &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |                         ~~~~^
scanf13.c:43:50: error: data argument not used by format string [-Werror,-Wformat-extra-args]
   43 |               "A%mS%10mls%4ml[bcd]%4mCB", &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~                ^
scanf13.c:145:27: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  145 |   if (sscanf (buf, "%2048mls%mlc", &lsp3, &lsp4) != 2)
      |                     ~~~~~~^
scanf13.c:145:31: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  145 |   if (sscanf (buf, "%2048mls%mlc", &lsp3, &lsp4) != 2)
      |                            ~~~^
scanf13.c:145:43: error: data argument not used by format string [-Werror,-Wformat-extra-args]
  145 |   if (sscanf (buf, "%2048mls%mlc", &lsp3, &lsp4) != 2)
      |                    ~~~~~~~~~~~~~~         ^
scanf13.c:161:31: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                         ~~~~~~^
scanf13.c:161:42: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                                ~~~~~~~~~~^
scanf13.c:161:53: error: invalid conversion specifier 'l' [-Werror,-Wformat-invalid-specifier]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                                           ~~~~~~~~~~^
scanf13.c:162:15: error: data argument not used by format string [-Werror,-Wformat-extra-args]
  161 |   if (sscanf (buf, "%4mC%1500ml[dr/]%548ml[abc/d]%3mlc",
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  162 |               &lsp1, &lsp2, &lsp3, &lsp4) != 4)
      |                      ^
10 errors generated.

2. With DIAG_IGNORE_NEEDS_COMMENT_CLANG changes in stdio-common/scanf13.c:

scanf13.c:28:40: error: 'sscanf' may overflow; destination buffer in argument 4 has size 8, but the corresponding specifier may require size 11 [-Werror,-Wfortify-source]
   28 |               "A%ms%10ms%4m[bcd]%4mcB", &sp1, &sp2, &sp3, &sp4) != 4)
      |                                               ^
scanf13.c:94:34: error: 'sscanf' may overflow; destination buffer in argument 3 has size 8, but the corresponding specifier may require size 2049 [-Werror,-Wfortify-source]
   94 |   if (sscanf (buf, "%2048ms%mc", &sp3, &sp4) != 2)
      |                                  ^
scanf13.c:110:61: error: 'sscanf' may overflow; destination buffer in argument 4 has size 8, but the corresponding specifier may require size 1501 [-Werror,-Wfortify-source]
  110 |   if (sscanf (buf, "%4mc%1500m[dr/]%548m[abc/d]%3mc", &sp1, &sp2, &sp3, &sp4)
      |                                                             ^
scanf13.c:110:67: error: 'sscanf' may overflow; destination buffer in argument 5 has size 8, but the corresponding specifier may require size 549 [-Werror,-Wfortify-source]
  110 |   if (sscanf (buf, "%4mc%1500m[dr/]%548m[abc/d]%3mc", &sp1, &sp2, &sp3, &sp4)
      |                                                                   ^
4 errors generated.

Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostring: Suppress Clang warnings on tester.c
H.J. Lu [Sun, 22 Dec 2024 21:12:02 +0000 (05:12 +0800)] 
string: Suppress Clang warnings on tester.c

Add a configure check for -Wno-fortify-source to suppress Clang warnings
on string/tester.c, like:

tester.c:385:10: error: 'strncat' size argument is too large; destination buffer has size 50, but size argument is 99 [-Werror,-Wfortify-source]
  385 |   check (strncat (one, "lmn", 99) == one, 1);   /* Returned value. */

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoAdd a reference to Clang /usr/include/tgmath.h dependency
H.J. Lu [Sun, 22 Dec 2024 21:12:01 +0000 (05:12 +0800)] 
Add a reference to Clang /usr/include/tgmath.h dependency

The fake Clang /usr/include/tgmath.h dependency bug is:

https://github.com/llvm/llvm-project/issues/120891

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoSuppress Clang -Wimplicit-fallthrough warnings
H.J. Lu [Sun, 22 Dec 2024 21:12:00 +0000 (05:12 +0800)] 
Suppress Clang -Wimplicit-fallthrough warnings

Since Clang doesn't properly handle

/* FALLTHROUGH */

in elf/tst-align2.c nor

/* fall through */

in misc/tst-tsearch.c

tst-align2.c:100:9: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
  100 |         case 'A':
      |         ^
tst-align2.c:100:9: note: insert '__attribute__((fallthrough));' to silence this warning
  100 |         case 'A':
      |         ^
      |         __attribute__((fallthrough));
tst-align2.c:100:9: note: insert 'break;' to avoid fall-through
  100 |         case 'A':
      |         ^
      |         break;

suppress them when compiled with Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostdio: Suppress -Wformat only for gcc in tst-sprintf-errno.c
Adhemerval Zanella [Sun, 22 Dec 2024 21:11:59 +0000 (05:11 +0800)] 
stdio: Suppress -Wformat only for gcc in tst-sprintf-errno.c

Since Clang doesn't support

DIAG_IGNORE_NEEDS_COMMENT (11, "-Wformat=");

and for unknown reasons, it doesn't warn the %#m specifier, suppress
-Wformat only for gcc in tst-sprintf-errno.c.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoinclude/sys/cdefs.h: Add __attribute_optimization_barrier__
Adhemerval Zanella [Sun, 22 Dec 2024 21:11:58 +0000 (05:11 +0800)] 
include/sys/cdefs.h: Add __attribute_optimization_barrier__

Add __attribute_optimization_barrier__ to disable inlining and cloning on a
function.  For Clang, expand it to

__attribute__ ((optnone))

Otherwise, expand it to

__attribute__ ((noinline, clone))

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoassert: Use __writev in assert.c [BZ #32492]
DJ Delorie [Sun, 22 Dec 2024 04:12:41 +0000 (23:12 -0500)] 
assert: Use __writev in assert.c [BZ #32492]

Replace writev with __writev in assert/assert.c.  This fixes [BZ #32492].

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
6 months agoFix build without stack protector [BZ #32494]
H.J. Lu [Sun, 22 Dec 2024 19:58:54 +0000 (03:58 +0800)] 
Fix build without stack protector [BZ #32494]

Without stack protector, inhibit_stack_protector is undefined during build:

In file included from <command-line>:
./../include/libc-symbols.h:665:3: error: expected ';' before '__typeof'
  665 |   __typeof (type_name) *name##_ifunc (__VA_ARGS__)
         \
      |   ^~~~~~~~
./../include/libc-symbols.h:676:3: note: in expansion of macro
'__ifunc_resolver'
  676 |   __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__)
      |   ^~~~~~~~~~~~~~~~
./../include/libc-symbols.h:703:3: note: in expansion of macro '__ifunc_args'
  703 |   __ifunc_args (type_name, name, expr, init, arg)
      |   ^~~~~~~~~~~~
./../include/libc-symbols.h:790:3: note: in expansion of macro '__ifunc'
  790 |   __ifunc (redirected_name, name, expr, void, INIT_ARCH)
      |   ^~~~~~~
../sysdeps/x86_64/multiarch/memchr.c:29:1: note: in expansion of macro
'libc_ifunc_redirected'
   29 | libc_ifunc_redirected (__redirect_memchr, memchr, IFUNC_SELECTOR ());
      | ^~~~~~~~~~~~~~~~~~~~~

1. Fix a typo in include/libc-symbols.h to define inhibit_stack_protector
for build.
2. Don't include <config.h> in include/libc-symbols.h since it has been
included in include/libc-misc.h.
3. Change #include "libc-misc.h" to #include <libc-misc.h> in
string/test-string.h.

This fixes BZ #32494.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoCheck if TEST_CC supports -Wno-restrict before using it
Adhemerval Zanella [Thu, 27 Jul 2023 18:49:52 +0000 (15:49 -0300)] 
Check if TEST_CC supports -Wno-restrict before using it

Check if TEST_CC supports -Wno-restrict before using it to avoid Clang
error:

error: unknown warning option '-Wno-restrict' [-Werror,-Wunknown-warning-option]

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agohppa: Simplify handling of sanity check errors in clone.S.
John David Anglin [Sun, 22 Dec 2024 14:58:02 +0000 (09:58 -0500)] 
hppa: Simplify handling of sanity check errors in clone.S.

This simplifies the handling of sanity check errors in clone.S.
Adjusted a couple of comments to reflect current code.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
6 months agohppa: add cacheflush() syscall wrapper
John David Anglin [Sun, 22 Dec 2024 14:51:54 +0000 (09:51 -0500)] 
hppa: add cacheflush() syscall wrapper

The hppa Linux kernel supports the cacheflush() syscall
since version 6.5. This adds the glibc syscall wrapper.

Signed-off-by: Helge Deller <deller@gmx.de>
---
v2: This patch was too late in release cycle for GLIBC_2.40,
    so update now to GLIBC_2.41 instead.

6 months agohppa: Update libm-test-ulps
John David Anglin [Sun, 22 Dec 2024 14:45:34 +0000 (09:45 -0500)] 
hppa: Update libm-test-ulps

Signed-off-by: John David Anglin <dave.anglin@bell.net>
6 months agohurd: make mprotect translate KERN_PROTECTION_FAILURE to EACCESS
Samuel Thibault [Sun, 22 Dec 2024 10:40:18 +0000 (11:40 +0100)] 
hurd: make mprotect translate KERN_PROTECTION_FAILURE to EACCESS

Suggested-by: Sergey Bugaev <bugaevc@gmail.com>
6 months agoCompile tst-deadline.c with -Wno-ignored-attributes for Clang
H.J. Lu [Thu, 19 Dec 2024 21:52:56 +0000 (05:52 +0800)] 
Compile tst-deadline.c with -Wno-ignored-attributes for Clang

Since tst-deadline.c is an internal test, compile tst-deadline.c with
-Wno-ignored-attributes for Clang to silence -Werror,-Wunknown-attributes
errors.  Also suppress -Wmaybe-uninitialized only for GCC in net-internal.h.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agomalloc: Only enable -Waggressive-loop-optimizations suppression for gcc
Adhemerval Zanella [Fri, 25 Mar 2022 12:00:12 +0000 (09:00 -0300)] 
malloc: Only enable -Waggressive-loop-optimizations suppression for gcc

Reviewed-by: Sam James <sam@gentoo.org>
6 months agoSuppress -Wmaybe-uninitialized only for GCC
H.J. Lu [Thu, 19 Dec 2024 21:02:14 +0000 (05:02 +0800)] 
Suppress -Wmaybe-uninitialized only for GCC

Clang doesn't support -Wmaybe-uninitialized.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoSuppress Clang -Wgnu-folding-constant warnings
H.J. Lu [Thu, 19 Dec 2024 20:51:03 +0000 (04:51 +0800)] 
Suppress Clang -Wgnu-folding-constant warnings

Suppress Clang -Wgnu-folding-constant warnings, like

tst-freopen.c:44:13: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
   44 |   char temp[strlen (test) + 1];
      |             ^~~~~~~~~~~~~~~~~

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostdio: Suppress clang warnings for tst-vprintf-width-i18n.c
Adhemerval Zanella [Fri, 3 Jun 2022 13:43:42 +0000 (10:43 -0300)] 
stdio: Suppress clang warnings for tst-vprintf-width-i18n.c

Clang issues the following warning:

  tst-vfprintf-width-i18n.c:51:34: error: invalid conversion specifier '1'
  [-Werror,-Wformat-invalid-specifier]
    TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16);
                                 ~~^

since it does not how to handle %I.
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostdio: Fix clang warnings on tests
Adhemerval Zanella [Thu, 27 Jul 2023 18:27:08 +0000 (15:27 -0300)] 
stdio: Fix clang warnings on tests

clang does not support 'I' specifier and handles it as a 'length
modifier'.
Reviewed-by: Sam James <sam@gentoo.org>
6 months agomath: Fix clang warnings for math/test-tgmath-ret.c
Adhemerval Zanella [Tue, 15 Mar 2022 18:33:02 +0000 (15:33 -0300)] 
math: Fix clang warnings for math/test-tgmath-ret.c

clang warns that since the global variables are only used to function
calls (without being actually used), they are not needed and will
not be emitted.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoSuppress Clang warning on adding an integer to a string
Adhemerval Zanella [Fri, 25 Mar 2022 14:23:35 +0000 (11:23 -0300)] 
Suppress Clang warning on adding an integer to a string

Suppress Clang warning on adding an integer to a string, like:

tst-iconv-sticky-input-error.c:125:42: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
  125 |                 expected_output = "ABXY" + skip;
      |                                   ~~~~~~~^~~~~~
tst-iconv-sticky-input-error.c:125:42: note: use array indexing to silence this warning
  125 |                 expected_output = "ABXY" + skip;
      |                                          ^
      |                                   &      [     ]

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostdio: Suppress %Z format for clang
Adhemerval Zanella [Thu, 1 Sep 2022 12:29:23 +0000 (09:29 -0300)] 
stdio: Suppress %Z format for clang

clang does not handle %Z on print, and just suppressing
-Wformat-invalid-specifier might trigger another warning for extra
arguments (since %Z is ignored).  So suppress -Wformat-extra-args
as well.

For tst-fphex.c a heavy hammer is used since the printf is more
complex and clang throws a more generic warning.
Reviewed-by: Sam James <sam@gentoo.org>
6 months agostdio: Suppress clang warnings for tst-unlockedio.c
Adhemerval Zanella [Thu, 24 Mar 2022 19:03:16 +0000 (16:03 -0300)] 
stdio: Suppress clang warnings for tst-unlockedio.c

Suppress the following -Wgnu-folding-constant and -Wliteral-conversion
warnings from Clang:

  tst-unlockedio.c:35:12: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant]
   35 |   char buf[strlen (blah) + 1];
      |            ^~~~~~~~~~~~~~~~~

  tst-unlockedio.c:63:36: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from -0 to 0
  [-Werror,-Wliteral-conversion]
        || fwrite_unlocked (blah, 0, -0.0, fp) != 0
           ~~~~~~~~~~~~~~~           ^~~~
  tst-unlockedio.c:61:33: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fwrite_unlocked (--cp, 0.25, 16, fp) != 0
           ~~~~~~~~~~~~~~~        ^~~~
  tst-unlockedio.c:59:37: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fwrite_unlocked (cp++, 16, 0.25, fp) != 0
           ~~~~~~~~~~~~~~~            ^~~~
  tst-unlockedio.c:116:34: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from -0 to 0
  [-Werror,-Wliteral-conversion]
        || fread_unlocked (buf, 0, -0.0, fp) != 0
           ~~~~~~~~~~~~~~          ^~~~
  tst-unlockedio.c:114:32: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fread_unlocked (--wp, 0.25, 16, fp) != 0
           ~~~~~~~~~~~~~~        ^~~~
  tst-unlockedio.c:112:36: error: implicit conversion from 'double' to
  'size_t' (aka 'unsigned long') changes value from 0.25 to 0
  [-Werror,-Wliteral-conversion]
        || fread_unlocked (wp++, 16, 0.25, fp) != 0
           ~~~~~~~~~~~~~~            ^~~~

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agolocaledata: Fix clang warnings on tests
Adhemerval Zanella [Tue, 15 Mar 2022 18:29:47 +0000 (15:29 -0300)] 
localedata: Fix clang warnings on tests

clang does not support 'I' specifier and handles it as a 'length
modifier'.
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoelf: Suppress clang warning on tst-unique4
Adhemerval Zanella [Fri, 25 Mar 2022 14:21:33 +0000 (11:21 -0300)] 
elf: Suppress clang warning on tst-unique4

clang warns that the instantiation of the variable is required,
but no definition is available.  They are implemented on
tst-unique4lib.so.

Checked on x86_64-linux-gnu.
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoelf: Enable tst-dlopen-nodelete-reloc if TEST_CXX supports STB_GNU_UNIQUE
H.J. Lu [Thu, 19 Dec 2024 20:32:49 +0000 (04:32 +0800)] 
elf: Enable tst-dlopen-nodelete-reloc if TEST_CXX supports STB_GNU_UNIQUE

tst-dlopen-nodelete-reloc requires STB_GNU_UNIQUE support so that NODELETE
is propagated by do_lookup_unique.  Enable it only if TEST_CXX supports
STB_GNU_UNIQUE,

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoelf: Check PDE load address with non-empty text section
H.J. Lu [Sun, 22 Dec 2024 00:31:25 +0000 (08:31 +0800)] 
elf: Check PDE load address with non-empty text section

Check PDE load address with non-empty text section:

.globl _start
_start:
.globl __start
.byte 0

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agox86: Define __HAVE_FLOAT128 for Clang and use __builtin_*f128 code path
Fangrui Song [Sun, 10 Oct 2021 21:38:00 +0000 (14:38 -0700)] 
x86: Define __HAVE_FLOAT128 for Clang and use __builtin_*f128 code path

Clang supports __builtin_fabsf128 (despite not supporting _Float128) but
it does not support __builtin_fabsq.  Fallback to back to
`typedef __float128 _Float128;` it clang is used.

Originally developed by Fangrui Song <maskray@google.com>.
Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoAdd clang specific warning suppression macros
Adhemerval Zanella [Tue, 12 Sep 2023 18:45:24 +0000 (15:45 -0300)] 
Add clang specific warning suppression macros

Four new macros are added:

  * DIAG_{PUSH,POP}_NEEDS_COMMENT_CLANG are similar to
    DIAG_{PUSH,POP}_NEEDS_COMMENT, but enable clang specific pragmas to
    handle warnings for options only supported by clang.

  * DIAG_IGNORE_NEEDS_COMMENT_{CLANG,GCC} are similar to
    DIAG_IGNORE_NEEDS_COMMENT, but enable the warning suppression only
    for the referenced compiler.

Reviewed-by: Sam James <sam@gentoo.org>
6 months agox86: Use inhibit_stack_protector on tst-ifunc-isa.h
Adhemerval Zanella [Thu, 25 Aug 2022 12:48:57 +0000 (09:48 -0300)] 
x86: Use inhibit_stack_protector on tst-ifunc-isa.h

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoelf: Compile test modules with -fsemantic-interposition
H.J. Lu [Tue, 17 Dec 2024 23:24:38 +0000 (07:24 +0800)] 
elf: Compile test modules with -fsemantic-interposition

Compiler may default to -fno-semantic-interposition. But some elf test
modules must be compiled with -fsemantic-interposition to function properly.
Add a TEST_CC check for -fsemantic-interposition and use it on elf test
modules.  This fixed

FAIL: elf/tst-dlclose-lazy
FAIL: elf/tst-pie1
FAIL: elf/tst-plt-rewrite1
FAIL: elf/unload4

when Clang 19 is used to test glibc.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agotst-printf-bz18872.sh: stdio: Use __attribute__ ((optnone)) for Clang
Adhemerval Zanella [Thu, 24 Mar 2022 18:54:10 +0000 (15:54 -0300)] 
tst-printf-bz18872.sh: stdio: Use __attribute__ ((optnone)) for Clang

Use

__attribute__ ((optnone))

instead of

__attribute__ ((optimize ("-O0")))

to disable optimization for Clang.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoHandle pragma GCC optimize for clang
Adhemerval Zanella [Thu, 24 Mar 2022 19:17:59 +0000 (16:17 -0300)] 
Handle pragma GCC optimize for clang

Reviewed-by: Sam James <sam@gentoo.org>
6 months agodirent: Remove variable length array structure for tst-getdents64.c
Adhemerval Zanella [Fri, 25 Mar 2022 12:03:03 +0000 (09:03 -0300)] 
dirent: Remove variable length array structure for tst-getdents64.c

Clang emits the following warnings:

  ../sysdeps/unix/sysv/linux/tst-getdents64.c:111:18: error: fields must
  have a constant size: 'variable length array in structure' extension
  will never be supported
              char buffer[buffer_size];
                   ^

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoAdd include/libc-misc.h
H.J. Lu [Thu, 19 Dec 2024 21:31:05 +0000 (05:31 +0800)] 
Add include/libc-misc.h

Add include/libc-misc.h to provide miscellaneous definitions for both
glibc build and test:

1. Move inhibit_stack_protector to libc-misc.h and add Clang support.
2. Add test_inhibit_stack_protector for glibc testing.
3. Move inhibit_loop_to_libcall to libc-misc.h.
4. Add test_cc_inhibit_loop_to_libcall to handle TEST_CC != CC and
replace inhibit_loop_to_libcall with test_cc_inhibit_loop_to_libcall
in glibc tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoAdd test-config-cflags-float-store for -ffloat-store
H.J. Lu [Sun, 15 Dec 2024 13:24:14 +0000 (21:24 +0800)] 
Add test-config-cflags-float-store for -ffloat-store

Clang doesn't support -ffloat-store:

clang: error: optimization flag '-ffloat-store' is not supported [-Werror,-Wignored-optimization-argument]

Define test-config-cflags-float-store for -ffloat-store and use it in
math/Makefile for testing.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agolocaledata: Use hexadecimal character escape on tests
Adhemerval Zanella [Mon, 28 Mar 2022 18:50:07 +0000 (15:50 -0300)] 
localedata: Use hexadecimal character escape on tests

Instead of latin1 ones.

Reviewed-by: Sam James <sam@gentoo.org>
6 months agotst-atomic.c: Mark as UNSUPPORTED when compiled with Clang
H.J. Lu [Mon, 16 Dec 2024 10:56:55 +0000 (18:56 +0800)] 
tst-atomic.c: Mark as UNSUPPORTED when compiled with Clang

Since Clang can't remove the dead statement and issues an error:

tst-atomic.c:463:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*&mem)' (aka 'int')
  463 |   if (catomic_exchange_and_add (&mem, 11) != 2
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add'
  213 |   __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c,    \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |                                 mem, value)
      |                                 ~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body'
  198 |                          : "=r" (__result), "=m" (*mem)                       \
      |                                  ~~~~~~~~
  199 |                          : "0" ((int64_t) cast_to_integer (__addval)),     \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst-atomic.c:487:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*(&mem))' (aka 'int')
  487 |   if (catomic_increment_val (&mem) != 3)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/atomic.h:313:38: note: expanded from macro 'catomic_increment_val'
  313 | # define catomic_increment_val(mem) (catomic_exchange_and_add ((mem), 1) + 1)
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add'
  213 |   __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c,    \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |                                 mem, value)
      |                                 ~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body'
  198 |                          : "=r" (__result), "=m" (*mem)                       \
      |                                  ~~~~~~~~
  199 |                          : "0" ((int64_t) cast_to_integer (__addval)),     \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tst-atomic.c:501:7: error: unsupported inline asm: input with type 'int64_t' (aka 'long') matching output with type 'typeof (*(&mem))' (aka 'int')
  501 |   if (catomic_decrement_val (&mem) != 15)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/atomic.h:340:38: note: expanded from macro 'catomic_decrement_val'
  340 | # define catomic_decrement_val(mem) (catomic_exchange_and_add ((mem), -1) - 1)
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:213:3: note: expanded from macro 'catomic_exchange_and_add'
  213 |   __arch_exchange_and_add_body (__arch_exchange_and_add_cprefix, __arch_c,    \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |                                 mem, value)
      |                                 ~~~~~~~~~~~
../sysdeps/x86/atomic-machine.h:199:12: note: expanded from macro '__arch_exchange_and_add_body'
  198 |                          : "=r" (__result), "=m" (*mem)                       \
      |                                  ~~~~~~~~
  199 |                          : "0" ((int64_t) cast_to_integer (__addval)),     \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

mark tst-atomic.c as UNSUPPORTED when compiled with Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoEnable execstack tests only if compiler supports trampoline
H.J. Lu [Mon, 16 Dec 2024 11:20:54 +0000 (19:20 +0800)] 
Enable execstack tests only if compiler supports trampoline

Since trampoline is required to test execstack, enable execstack tests
only if compiler supports trampoline.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agox86: Include test-flt-eval-method-387 if -mfpmath=387 works
H.J. Lu [Thu, 19 Dec 2024 04:08:00 +0000 (12:08 +0800)] 
x86: Include test-flt-eval-method-387 if -mfpmath=387 works

Since Clang doesn't support -mfpmath=387 on x86-64, on x86, include
test-flt-eval-method-387 only if -mfpmath=387 works.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agox86-64: Disable libmvec ABI test for Clang
H.J. Lu [Sun, 15 Dec 2024 21:11:26 +0000 (05:11 +0800)] 
x86-64: Disable libmvec ABI test for Clang

Unlike GCC, libmvec support in Clang is hard-coded.  Clang doesn't use
macros defined in <bits/libm-simd-decl-stubs.h> to support new libmvec
functions added to glibc and can't vectorize all test loops to test
libmvec ABI:

https://github.com/llvm/llvm-project/issues/120868

disable libmvec ABI test for Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoRemove Clang /usr/include/tgmath.h dependency
H.J. Lu [Sun, 15 Dec 2024 23:30:44 +0000 (07:30 +0800)] 
Remove Clang /usr/include/tgmath.h dependency

Remove the /usr/include/tgmath.h dependency generated by Clang even though
Clang never reads /usr/include/tgmath.h.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
6 months agoDon't redefine INFINITY nor NAN
H.J. Lu [Sun, 15 Dec 2024 01:56:34 +0000 (09:56 +0800)] 
Don't redefine INFINITY nor NAN

Since math/math.h isn't a system header, clang issues errors:

In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:91:11: error: 'INFINITY' macro redefined [-Werror,-Wmacro-redefined]
   91 | #  define INFINITY (__builtin_inff ())
      |           ^
/usr/bin/../lib/clang/19/include/float.h:173:11: note: previous definition is here
  173 | #  define INFINITY (__builtin_inff())
      |           ^
In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:98:11: error: 'NAN' macro redefined [-Werror,-Wmacro-redefined]
   98 | #  define NAN (__builtin_nanf (""))
      |           ^
/usr/bin/../lib/clang/19/include/float.h:174:11: note: previous definition is here
  174 | #  define NAN (__builtin_nanf(""))

Don't define INFINITY nor NAN if they are defined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>