* [PATCH] kbuild: rpm-pkg: Fix generating debuginfo manually.
@ 2026-02-12 13:58 Lukas Herbolt
2026-02-12 16:26 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Lukas Herbolt @ 2026-02-12 13:58 UTC (permalink / raw)
To: nathan, nsc; +Cc: linux-kbuild, Lukas Herbolt
The ${OBJCOPY} and ${READELF} are not expanded into path to readelf
and objcopy binary so just use the binary name with the %{_bindir}
makro.
Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
scripts/package/kernel.spec | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 0f1c8de1bd95..d032f6aff91b 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -109,11 +109,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf
while read -r mod; do
mod="${mod%.o}.ko"
dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
- buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
+ buildid=$(%{_bindir}/eu-readelf -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug"
mkdir -p "${dbg%/*}" "${link%/*}"
- "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
+ %{_bindir}/objcopy --only-keep-debug "${mod}" "${dbg}"
ln -sf --relative "${dbg}" "${link}"
echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] kbuild: rpm-pkg: Fix generating debuginfo manually.
2026-02-12 13:58 [PATCH] kbuild: rpm-pkg: Fix generating debuginfo manually Lukas Herbolt
@ 2026-02-12 16:26 ` Nathan Chancellor
2026-02-12 19:28 ` Lukas Herbolt
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2026-02-12 16:26 UTC (permalink / raw)
To: Lukas Herbolt; +Cc: nsc, linux-kbuild
Hi Lukas,
Thanks for the patch!
On Thu, Feb 12, 2026 at 02:58:56PM +0100, Lukas Herbolt wrote:
> The ${OBJCOPY} and ${READELF} are not expanded into path to readelf
> and objcopy binary so just use the binary name with the %{_bindir}
> makro.
>
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
> ---
> scripts/package/kernel.spec | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 0f1c8de1bd95..d032f6aff91b 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -109,11 +109,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf
> while read -r mod; do
> mod="${mod%.o}.ko"
> dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
> - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
> + buildid=$(%{_bindir}/eu-readelf -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
When using the binrpm-pkg target within Kbuild, I do see these expanded
to their Kbuild value:
++ .../toolchains/gcc/15.2.0/bin/x86_64-linux-readelf -n net/ipv6/netfilter/nf_reject_ipv6.ko
++ sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p'
but I guess use of the spec file is not limited to being within Kbuild?
How are you using it? I guess using the srcrpm-pkg and building it
manually?
I would prefer to keep use of these variables so that the user's choice
of toolchain is properly respected. The proper way to fix this is likely
using a fallback only when the variable is not defined. Does this work
for your usecase?
diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 0f1c8de1bd95..c23ff98f63ed 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -109,11 +109,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf
while read -r mod; do
mod="${mod%.o}.ko"
dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
- buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
+ buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug"
mkdir -p "${dbg%/*}" "${link%/*}"
- "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
+ "${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}"
ln -sf --relative "${dbg}" "${link}"
echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] kbuild: rpm-pkg: Fix generating debuginfo manually.
2026-02-12 16:26 ` Nathan Chancellor
@ 2026-02-12 19:28 ` Lukas Herbolt
0 siblings, 0 replies; 3+ messages in thread
From: Lukas Herbolt @ 2026-02-12 19:28 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: nsc, linux-kbuild
On 2026-02-12 17:26, Nathan Chancellor wrote:
> Hi Lukas,
>
> Thanks for the patch!
>
> On Thu, Feb 12, 2026 at 02:58:56PM +0100, Lukas Herbolt wrote:
>> The ${OBJCOPY} and ${READELF} are not expanded into path to readelf
>> and objcopy binary so just use the binary name with the %{_bindir}
>> makro.
>>
>> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
>> ---
>> scripts/package/kernel.spec | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
>> index 0f1c8de1bd95..d032f6aff91b 100644
>> --- a/scripts/package/kernel.spec
>> +++ b/scripts/package/kernel.spec
>> @@ -109,11 +109,11 @@ echo
>> /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux >
>> %{buildroot}/debuginf
>> while read -r mod; do
>> mod="${mod%.o}.ko"
>>
>> dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
>> - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID:
>> \(..\)\(.*\)@\1/\2@p')
>> + buildid=$(%{_bindir}/eu-readelf -n "${mod}" | sed -n 's@^.*Build ID:
>> \(..\)\(.*\)@\1/\2@p')
>
> When using the binrpm-pkg target within Kbuild, I do see these expanded
> to their Kbuild value:
>
> ++ .../toolchains/gcc/15.2.0/bin/x86_64-linux-readelf -n
> net/ipv6/netfilter/nf_reject_ipv6.ko
> ++ sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p'
>
> but I guess use of the spec file is not limited to being within Kbuild?
> How are you using it? I guess using the srcrpm-pkg and building it
> manually?
Yes exactly; make srcrpm-pkg and then mock --rebuild <src.rpm> (which
actually
runs rpmbuild in chroot).
Looking into it I guess the variables should be expanded after the make
srcrpm-pkg, but if I check the spec file:
I can see:
buildid=$("${READELF}" ....
So the mkspec is not expanding the variable.
>
> I would prefer to keep use of these variables so that the user's choice
> of toolchain is properly respected. The proper way to fix this is
> likely
> using a fallback only when the variable is not defined. Does this work
> for your usecase?
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 0f1c8de1bd95..c23ff98f63ed 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -109,11 +109,11 @@ echo
> /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux >
> %{buildroot}/debuginf
> while read -r mod; do
> mod="${mod%.o}.ko"
>
> dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
> - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID:
> \(..\)\(.*\)@\1/\2@p')
> + buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID:
> \(..\)\(.*\)@\1/\2@p')
> link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug"
>
> mkdir -p "${dbg%/*}" "${link%/*}"
> - "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
> + "${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}"
> ln -sf --relative "${dbg}" "${link}"
>
> echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
Yeah that works for me.
--
-lhe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-12 19:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12 13:58 [PATCH] kbuild: rpm-pkg: Fix generating debuginfo manually Lukas Herbolt
2026-02-12 16:26 ` Nathan Chancellor
2026-02-12 19:28 ` Lukas Herbolt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox