[PATCH 30/59] x86: Fix strstr ifunc on clang
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Wed Oct 22 16:35:42 GMT 2025
On 17/10/25 19:33, H.J. Lu wrote:
> On Sat, Oct 18, 2025 at 3:44 AM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> 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).
>> ---
>> sysdeps/x86_64/multiarch/strstr.c | 20 ++++++++++++--------
>> 1 file changed, 12 insertions(+), 8 deletions(-)
>>
>> diff --git a/sysdeps/x86_64/multiarch/strstr.c b/sysdeps/x86_64/multiarch/strstr.c
>> index e18e6418ae..339e7b8501 100644
>> --- a/sysdeps/x86_64/multiarch/strstr.c
>> +++ b/sysdeps/x86_64/multiarch/strstr.c
>> @@ -34,16 +34,20 @@
>> #include "string/strstr.c"
>>
>> extern __typeof (__redirect_strstr) __strstr_sse2_unaligned attribute_hidden;
>> -extern __typeof (__redirect_strstr) __strstr_generic attribute_hidden;
>
> Does this line removal change GCC codegen?
The symbol is not declared local, but since it is not called internally it does
create any PLT calls. But moving it before the 'string/strstr.c' pacify clang
warnings, I will update the patch.
More information about the Libc-alpha
mailing list