[PATCH v2 14/28] string: Use asm alias instead of symbol redirections for stpcpy and mempcpy

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Oct 30 14:17:35 GMT 2025



On 28/10/25 17:05, H.J. Lu wrote:
> On Wed, Oct 29, 2025 at 4:01 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 28/10/25 16:17, H.J. Lu wrote:
>>> On Wed, Oct 29, 2025 at 1:12 AM Adhemerval Zanella
>>> <adhemerval.zanella@linaro.org> wrote:
>>>>
>>>> Commit 939da411433 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.
>>>> ---
>>>>  include/string.h | 4 ++--
>>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/include/string.h b/include/string.h
>>>> index c26ca0927c..2ea212a401 100644
>>>> --- a/include/string.h
>>>> +++ b/include/string.h
>>>> @@ -188,8 +188,8 @@ extern __typeof (strsep) strsep attribute_hidden;
>>>>    && !defined NO_MEMPCPY_STPCPY_REDIRECT
>>>>  /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
>>>>     __mempcpy and __stpcpy if not inlined.  */
>>>> -extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
>>>> -extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
>>>> +__asm__ ("mempcpy = __mempcpy");
>>>> +__asm__ ("stpcpy = __stpcpy");
> 
> Please add a configure test to use asm alias only if symbol redirection
> is unsupported.

The configure check is an option; another is just set it for __clang__.
I do not have a strong opinion.


More information about the Libc-alpha mailing list