public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/nolibc: avoid call to wcslen() in _start_c() inserted by clang
@ 2026-04-18 10:31 Thomas Weißschuh
  2026-04-19 15:32 ` Willy Tarreau
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2026-04-18 10:31 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: linux-kernel, Thomas Weißschuh

Clang may convert the loop to find _auxv into a call to wcslen() which
is missing on nolibc. -fsanitize needs to be disabled for this to
happen.

Use the same pattern as in the nolibc strlen() implementation to avoid
the function call generation.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/include/nolibc/crt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h
index d8ce91fd2e3b..f38590a05adf 100644
--- a/tools/include/nolibc/crt.h
+++ b/tools/include/nolibc/crt.h
@@ -89,7 +89,7 @@ void _start_c(long *sp)
 
 	/* find _auxv */
 	for (auxv = (void *)envp; *auxv++;)
-		;
+		__asm__("");
 	_auxv = auxv;
 
 #ifndef NOLIBC_IGNORE_ERRNO

---
base-commit: b5ac9d2dc1330d0b16a141962ac202739b091efd
change-id: 20260418-nolibc-wcslen-5afac8eb318b

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/nolibc: avoid call to wcslen() in _start_c() inserted by clang
  2026-04-18 10:31 [PATCH] tools/nolibc: avoid call to wcslen() in _start_c() inserted by clang Thomas Weißschuh
@ 2026-04-19 15:32 ` Willy Tarreau
  0 siblings, 0 replies; 2+ messages in thread
From: Willy Tarreau @ 2026-04-19 15:32 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: linux-kernel

On Sat, Apr 18, 2026 at 12:31:54PM +0200, Thomas Weißschuh wrote:
> Clang may convert the loop to find _auxv into a call to wcslen() which
> is missing on nolibc. -fsanitize needs to be disabled for this to
> happen.
> 
> Use the same pattern as in the nolibc strlen() implementation to avoid
> the function call generation.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Compilers are always full of surprises!

Acked-by: Willy Tarreau <w@1wt.eu>
Willy

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-19 15:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-18 10:31 [PATCH] tools/nolibc: avoid call to wcslen() in _start_c() inserted by clang Thomas Weißschuh
2026-04-19 15:32 ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox