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

From: Nathan Chancellor

Date: Wed Nov 04 2026 - 23:50:11 EST


> 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?

> Fixes: 7dd47b95b0f5 ("kbuild: consolidate redundant sed script ASM offset generation")
> Signed-off-by: Dmitry Kandybka <d.kandybka@xxxxxxxxx>

Reviewed-by: Nathan Chancellor <nathan@xxxxxxxxxx>

--
Cheers,
Nathan