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

From: Thomas Weißschuh

Date: Wed Feb 25 2026 - 17:24:12 EST


On 2026-02-25 22:17:02+0000, David Laight wrote:
> On Wed, 25 Feb 2026 22:25:12 +0100
> Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
>
> > On 2026-02-23 10:17:19+0000, david.laight.linux@xxxxxxxxx wrote:
> > > From: David Laight <david.laight.linux@xxxxxxxxx>
> > >
> > > Needed to stop compiler 'optimisations' bloating code.
> > > Equivalent to the definition in include/linux/compiler.h
> > >
> > > Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
> > > ---
> > >
> > > New patch for v3.
> > >
> > > tools/include/nolibc/compiler.h | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
> > > index a8c7619dcdde..8e0eef434eec 100644
> > > --- a/tools/include/nolibc/compiler.h
> > > +++ b/tools/include/nolibc/compiler.h
> > > @@ -71,4 +71,9 @@
> > > # define __nolibc_static_assert(_t)
> > > #endif
> > >
> > > +#ifndef _NOLIBC_OPTIMIZER_HIDE_VAR
> >
> > The ifndef guard should not be necessary.
>
> I copied the one from include/linux/compiler.h
> Nothing seems to need that one either.

Yeah, someone should probably clean that up, too.
> Can you take it out?

Sure, I can do that when applying the patch.
But a new revision will be necessary anyways.

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