[PATCH 1/7] Fix internal tests when building with clang
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Dec 31 18:26:07 GMT 2024
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. */
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
More information about the Libc-alpha
mailing list