[PATCH v5 next 01/17] tools/nolibc: Add _NOLIBC_OPTIMIZER_HIDE_VAR() to compiler.h

From: david . laight . linux

Date: Sun Mar 08 2026 - 07:38:07 EST


From: David Laight <david.laight.linux@xxxxxxxxx>

Needed to stop compiler 'optimisations' bloating code.
Equivalent to the definition in include/linux/compiler.h

Acked-by: Willy Tarreau <w@xxxxxx>
Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
---

Unchanged for v5.

Changes for v4:
- Remove #if guard

tools/include/nolibc/compiler.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index a8c7619dcdde..f03f84cfadce 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -71,4 +71,7 @@
# define __nolibc_static_assert(_t)
#endif

+/* Make the optimizer believe the variable can be manipulated arbitrarily. */
+#define _NOLIBC_OPTIMIZER_HIDE_VAR(var) __asm__ ("" : "+r" (var))
+
#endif /* _NOLIBC_COMPILER_H */
--
2.39.5