Re: [PATCH v3] kbuild: Makefile.lib: fix offsets generation with debug info

From: Nicolas Schier

Date: Thu Nov 05 2026 - 01:41:40 EST


On Wed, Nov 04, 2026 at 09:48:00PM -0700, Nathan Chancellor wrote:
> > When debug information is enabled (e.g. -ggdb3), the assembler
> > output file (e.g. kernel/sched/rq-offsets.s) contains additional
> > directives such as .ascii with offset info and debug metadata.
> >
> > For example:
> >
> > .ascii "->RQ_nr_pinned $3048 offsetof(struct rq, nr_pinned)" #
> > ...
> > .ascii "->func); __data = (it_func_ptr)->data; ((void(*)(void *, pro"
> >
> > The current sed-offsets macro uses [^ ]* to match constant names,
> > which is too permissive and can match unexpected characters when
> > debug directives are present. Additionally, the fallback command
> > 's:->::; p;' strips '->' from any unmatched line and prints it,
> > which causes debug metadata to leak into the generated header
> > file (include/generated/rq-offsets.h), breaking the build.
> >
> > Replace [^ ]* with [[:alnum:]_]* to match only valid C identifiers,
> > and remove the fallback 's:->::' command so that only successfully
> > transformed lines are emitted into the generated header.
> >
> > v2:
> > - Add BLANK() macro for better readability of generated headers
> > (suggested by Nathan Chancellor).
> > v3:
> > - Check for ->BLANK() at the beginning of a line
> > (suggested by Nathan Chancellor).
>
> For the future, please include this changelog underneath the '---' below
> your signoff so that it is not included when we apply the patch.
> Nicolas, would you mind snipping that during application?

Sure, thanks for the reminder!

--
Nicolas