[PATCH 1/7] Fix internal tests when building with clang
H.J. Lu
hjl.tools@gmail.com
Wed Jan 1 00:35:51 GMT 2025
On Wed, Jan 1, 2025 at 2:26 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> When building internal tests, clang fails with:
>
> ../include/string.h:183:44: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
> 183 | extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
> | ^
> ../string/bits/string_fortified.h:42:8: note: previous definition is here
> 42 | __NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
> | ^
>
> Because memcpy might be already defined if glibc is build with
> fortify support.
>
> The straighforward solution is just to avoid this indirection for
> internal tests, since it is not required.
>
> Checked on aarch64-linux-gnu.
> ---
> include/string.h | 4 +++-
> scripts/gen-as-const.py | 3 ++-
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/include/string.h b/include/string.h
> index 3b4c6007d7..003636b75b 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -175,7 +175,9 @@ extern __typeof (strnlen) strnlen attribute_hidden;
> extern __typeof (strsep) strsep attribute_hidden;
> #endif
>
> -#if (!IS_IN (libc) || !defined SHARED) \
> +/* Also exclude tests and related modules. */
> +#if ((!IS_IN (libc) || !defined SHARED) \
> + && !(IS_IN (testsuite_internal) || IS_IN (extramodules))) \
> && !defined NO_MEMPCPY_STPCPY_REDIRECT
> /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
> __mempcpy and __stpcpy if not inlined. */
These were added when __stpcpy and __mempcpy were macros
defined in string/bits/string2.h that call __builtin_stpcpy and
__builtin_mempcpy. But string/bits/string2.h was removed by
commit 18b10de7ced9e9c3843299fb600e40b11af3e0af
Author: Wilco Dijkstra <wdijkstr@arm.com>
Date: Mon Jun 12 15:19:38 2017 +0100
2017-06-12 Wilco Dijkstra <wdijkstr@arm.com>
There is no longer a need for string2.h, so remove it and all mention of it.
Move the redirect for __stpcpy to include/string.h since it is
still required
until all internal uses have been renamed.
This fixes several linknamespace/localplt failures when building with -Os.
[BZ #15105]
[BZ #19463]
* include/string.h: Add internal redirect for __stpcpy.
* string/Makefile: Remove bits/string2.h.
* string/string.h: Update comment.
* string/string-inlines.c: Remove bits/string2.h include
and comment.
* string/bits/string2.h: Remove file.
Can you try this patch instead?
> diff --git a/scripts/gen-as-const.py b/scripts/gen-as-const.py
> index 2f6b09d05b..17d08dd5a2 100644
> --- a/scripts/gen-as-const.py
> +++ b/scripts/gen-as-const.py
> @@ -38,7 +38,8 @@ def gen_test(sym_data):
> for arg in sym_data:
> if isinstance(arg, str):
> if arg == 'START':
> - out_lines.append('#include <stdint.h>\n'
> + out_lines.append('#define NO_MEMPCPY_STPCPY_REDIRECT\n'
> + '#include <stdint.h>\n'
> '#include <stdio.h>\n'
> '#include <bits/wordsize.h>\n'
> '#if __WORDSIZE == 64\n'
> --
> 2.43.0
>
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Redirect-mempcpy-and-stpcpy-only-in-libc.a.patch
Type: text/x-patch
Size: 2102 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250101/5bcd3150/attachment-0001.bin>
More information about the Libc-alpha
mailing list