* [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info
@ 2026-09-28 10:53 Dmitry Kandybka
2026-10-05 15:07 ` Nathan Chancellor
2026-10-15 21:01 ` [PATCH v2] " Dmitry Kandybka
0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Kandybka @ 2026-09-28 10:53 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier; +Cc: linux-kbuild, linux-kernel, stable
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.
Fixes: 7dd47b95b0f5 ("kbuild: consolidate redundant sed script ASM offset generation")
Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
---
scripts/Makefile.lib | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a4fdd8bd975..32251eb6ca33 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -493,9 +493,8 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
# the .ascii directive whereas GCC keeps the <space> as-is.
define sed-offsets
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
- /^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}'
+ /^->/{s:->#\(.*\):/* \1 */:p; \
+ s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p;}'
endef
# Use filechk to avoid rebuilds when a header changes, but the resulting file
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info
2026-09-28 10:53 [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info Dmitry Kandybka
@ 2026-10-05 15:07 ` Nathan Chancellor
2026-10-15 21:01 ` [PATCH v2] " Dmitry Kandybka
1 sibling, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2026-10-05 15:07 UTC (permalink / raw)
To: Dmitry Kandybka
Cc: Nathan Chancellor, Nicolas Schier, linux-kbuild, linux-kernel, stable
Hi Dmitry,
> 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.
>
> Fixes: 7dd47b95b0f5 ("kbuild: consolidate redundant sed script ASM offset generation")
> Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
> ---
> scripts/Makefile.lib | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 0a4fdd8bd975..32251eb6ca33 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -493,9 +493,8 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
> # the .ascii directive whereas GCC keeps the <space> as-is.
> define sed-offsets
> 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
> - /^->/{s:->#\(.*\):/* \1 */:; \
> - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
> - s:->::; p;}'
> + /^->/{s:->#\(.*\):/* \1 */:p; \
> + s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p;}'
Sashiko notes [1] that this results in BLANK() being dropped, which does
not result in any functional change as far as I can tell but it does
kind of make these generated headers a little harder to read in some
cases. Obviously the default fallback is what causes the problem here,
so maybe we can change BLANK() to include something that we can look for
like the name of the macro? This diff on top of your patchset appears to
keep the generated files the same while resolving your issue.
[1]: https://sashiko.dev/#/patchset/20260928105330.25427-1-d.kandybka@gmail.com
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index e7be517aaaf6..945006392cde 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -5,7 +5,7 @@
#define DEFINE(sym, val) \
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
-#define BLANK() asm volatile("\n.ascii \"->\"" : : )
+#define BLANK() asm volatile("\n.ascii \"->BLANK()\"" : : )
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 32251eb6ca33..96c2ec50f06e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -494,7 +494,8 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
define sed-offsets
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
/^->/{s:->#\(.*\):/* \1 */:p; \
- s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p;}'
+ s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p; \
+ s:->BLANK()::p;}'
endef
# Use filechk to avoid rebuilds when a header changes, but the resulting file
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2] kbuild: Makefile.lib: fix offsets generation with debug info
2026-09-28 10:53 [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info Dmitry Kandybka
2026-10-05 15:07 ` Nathan Chancellor
@ 2026-10-15 21:01 ` Dmitry Kandybka
2026-10-26 7:47 ` [PATCH v3] " Dmitry Kandybka
1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Kandybka @ 2026-10-15 21:01 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: Nicolas Schier, linux-kbuild, linux-kernel, stable
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).
Fixes: 7dd47b95b0f5 ("kbuild: consolidate redundant sed script ASM offset generation")
Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
---
include/linux/kbuild.h | 2 +-
scripts/Makefile.lib | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index e7be517aaaf6..118568971fdf 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -5,7 +5,7 @@
#define DEFINE(sym, val) \
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
-#define BLANK() asm volatile("\n.ascii \"->\"" : : )
+#define BLANK() do { asm volatile ("\n.ascii \"->BLANK()\"" : : ); } while (0)
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a4fdd8bd975..96c2ec50f06e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -493,9 +493,9 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
# the .ascii directive whereas GCC keeps the <space> as-is.
define sed-offsets
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
- /^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}'
+ /^->/{s:->#\(.*\):/* \1 */:p; \
+ s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p; \
+ s:->BLANK()::p;}'
endef
# Use filechk to avoid rebuilds when a header changes, but the resulting file
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v3] kbuild: Makefile.lib: fix offsets generation with debug info
2026-10-15 21:01 ` [PATCH v2] " Dmitry Kandybka
@ 2026-10-26 7:47 ` Dmitry Kandybka
2026-11-05 4:48 ` Nathan Chancellor
2026-11-05 7:31 ` Nicolas Schier
0 siblings, 2 replies; 7+ messages in thread
From: Dmitry Kandybka @ 2026-10-26 7:47 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: linux-kbuild, linux-kernel, stable
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).
Fixes: 7dd47b95b0f5 ("kbuild: consolidate redundant sed script ASM offset generation")
Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
---
include/linux/kbuild.h | 2 +-
scripts/Makefile.lib | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index e7be517aaaf6..118568971fdf 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -5,7 +5,7 @@
#define DEFINE(sym, val) \
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
-#define BLANK() asm volatile("\n.ascii \"->\"" : : )
+#define BLANK() do { asm volatile ("\n.ascii \"->BLANK()\"" : : ); } while (0)
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a4fdd8bd975..90422215046f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -493,9 +493,9 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
# the .ascii directive whereas GCC keeps the <space> as-is.
define sed-offsets
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
- /^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}'
+ /^->/{s:->#\(.*\):/* \1 */:p; \
+ s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p; \
+ s:^->BLANK()::p;}'
endef
# Use filechk to avoid rebuilds when a header changes, but the resulting file
--
2.54.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3] kbuild: Makefile.lib: fix offsets generation with debug info
2026-10-26 7:47 ` [PATCH v3] " Dmitry Kandybka
@ 2026-11-05 4:48 ` Nathan Chancellor
2026-11-05 6:36 ` Nicolas Schier
2026-11-05 7:31 ` Nicolas Schier
1 sibling, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2026-11-05 4:48 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier; +Cc: linux-kbuild, linux-kernel, stable
> 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@gmail.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3] kbuild: Makefile.lib: fix offsets generation with debug info
2026-11-05 4:48 ` Nathan Chancellor
@ 2026-11-05 6:36 ` Nicolas Schier
0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Schier @ 2026-11-05 6:36 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: linux-kbuild, linux-kernel, stable
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] kbuild: Makefile.lib: fix offsets generation with debug info
2026-10-26 7:47 ` [PATCH v3] " Dmitry Kandybka
2026-11-05 4:48 ` Nathan Chancellor
@ 2026-11-05 7:31 ` Nicolas Schier
1 sibling, 0 replies; 7+ messages in thread
From: Nicolas Schier @ 2026-11-05 7:31 UTC (permalink / raw)
To: Nathan Chancellor, Dmitry Kandybka
Cc: Nicolas Schier, linux-kbuild, linux-kernel, stable
On Mon, 26 Oct 2026 10:47:33 +0300, Dmitry Kandybka 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"
>
> [...]
Applied to kbuild/linux.git (kbuild-next-unstable), with patch history snipped.
Thanks!
[1/1] kbuild: Makefile.lib: fix offsets generation with debug info
https://git.kernel.org/kbuild/c/131d86d0
Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers).
Patches applied to the kbuild-next-unstable branch are accepted pending
wider testing in linux-next and any post-commit review; they will
generally be moved to the kbuild-next branch in about a week if no
issues are found.
Best regards,
--
Nicolas
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-05 7:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 10:53 [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info Dmitry Kandybka
2026-10-05 15:07 ` Nathan Chancellor
2026-10-15 21:01 ` [PATCH v2] " Dmitry Kandybka
2026-10-26 7:47 ` [PATCH v3] " Dmitry Kandybka
2026-11-05 4:48 ` Nathan Chancellor
2026-11-05 6:36 ` Nicolas Schier
2026-11-05 7:31 ` Nicolas Schier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®