diff mbox series

kbuild: rpm-pkg: include vmlinux debug symbols

Message ID 20240910014327.1726214-1-ushankar@purestorage.com (mailing list archive)
State New
Headers show
Series kbuild: rpm-pkg: include vmlinux debug symbols | expand

Commit Message

Uday Shankar Sept. 10, 2024, 1:43 a.m. UTC
None of the RPMs created by make rpm-pkg appear to contain vmlinux debug
symbols (though debug symbols for modules are left in the .ko files in
the kernel-%{KERNELRELEASE} package). This causes issues when trying to
run tools like systemtap against kernels produced via make rpm-pkg. Add
the vmlinux debug symbols to the kernel-%{KERNELRELEASE} package (at
/lib/modules/${KERNELRELEASE}/vmlinux.debug).

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
---
 scripts/package/kernel.spec | 9 +++++++++
 1 file changed, 9 insertions(+)


base-commit: e3bf4ec9d54ed96fb3eb7dd53edcc9452897604d

Comments

Uday Shankar Sept. 16, 2024, 9:34 p.m. UTC | #1
ping
Nathan Chancellor Sept. 17, 2024, 1:28 p.m. UTC | #2
Hi Uday,

First of all, you might not get many comments on this patch for several
days because it is conference week (Open Source Summit, Linux Security
Summit, and Linux Plumbers Conference). Sorry for the delay in review as
a result.

On Mon, Sep 09, 2024 at 07:43:27PM -0600, Uday Shankar wrote:
> None of the RPMs created by make rpm-pkg appear to contain vmlinux debug
> symbols (though debug symbols for modules are left in the .ko files in
> the kernel-%{KERNELRELEASE} package). This causes issues when trying to
> run tools like systemtap against kernels produced via make rpm-pkg. Add
> the vmlinux debug symbols to the kernel-%{KERNELRELEASE} package (at
> /lib/modules/${KERNELRELEASE}/vmlinux.debug).
> 
> Signed-off-by: Uday Shankar <ushankar@purestorage.com>
> ---
>  scripts/package/kernel.spec | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index ac3e5ac01d8a..f5d6ce95b4f0 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -60,6 +60,15 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
>  # DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
>  %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} DEPMOD=true modules_install
>  %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +(
> +	# eu-strip tries to truncate its output file, which does not end
> +	# well with -o /dev/null. so output to a junk temp file instead
> +	tmp=$(mktemp)
> +	trap "rm -f $tmp" 0
> +	eu-strip --remove-comment \
> +		-f %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinux.debug \
> +		-o $tmp vmlinux
> +)

Why not match what the Arch Linux and Debian packages do and just add
the whole vmlinux to the package under either /usr/lib/debug or
/usr/src/debug? This also appears to match the official Fedora package
and it does not mandate the use of eu-strip.

Masahiro might have further comments though.

Cheers,
Nathan

>  cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
>  cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
>  if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
> 
> base-commit: e3bf4ec9d54ed96fb3eb7dd53edcc9452897604d
> -- 
> 2.34.1
>
Masahiro Yamada Sept. 17, 2024, 1:35 p.m. UTC | #3
On Tue, Sep 10, 2024 at 10:44 AM Uday Shankar <ushankar@purestorage.com> wrote:
>
> None of the RPMs created by make rpm-pkg appear to contain vmlinux debug
> symbols (though debug symbols for modules are left in the .ko files in
> the kernel-%{KERNELRELEASE} package). This causes issues when trying to
> run tools like systemtap against kernels produced via make rpm-pkg. Add
> the vmlinux debug symbols to the kernel-%{KERNELRELEASE} package (at
> /lib/modules/${KERNELRELEASE}/vmlinux.debug).
>
> Signed-off-by: Uday Shankar <ushankar@purestorage.com>
> ---
>  scripts/package/kernel.spec | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index ac3e5ac01d8a..f5d6ce95b4f0 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -60,6 +60,15 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
>  # DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
>  %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} DEPMOD=true modules_install
>  %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
> +(
> +       # eu-strip tries to truncate its output file, which does not end
> +       # well with -o /dev/null. so output to a junk temp file instead
> +       tmp=$(mktemp)
> +       trap "rm -f $tmp" 0
> +       eu-strip --remove-comment \
> +               -f %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinux.debug \
> +               -o $tmp vmlinux
> +)


I agree with Nathan.
Please check what Fedora does.

Adding the debug info to the normal kernel package would be frowned upon
because it grows the package size, whereas many people do not need it.

As far as I understood, in Fedora, *-debuginfo package has it under
/usr/lib/debug/.


[vagrant@fedora39 ~]$ rpm -ql kernel-debuginfo | grep vmlinux
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/scripts/gdb/__pycache__/vmlinux-gdb.cpython-312.opt-1.pyc
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/scripts/gdb/__pycache__/vmlinux-gdb.cpython-312.pyc
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/scripts/gdb/vmlinux-gdb.py
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/vmlinux
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/vmlinux-gdb.py
[vagrant@fedora39 ~]$ file
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/vmlinux
/usr/lib/debug/lib/modules/6.10.9-100.fc39.x86_64/vmlinux: ELF 64-bit
LSB executable, x86-64, version 1 (SYSV), statically linked,
BuildID[sha1]=109fc8dfd9c144def507008951ee8a26eef39086, with
debug_info, not stripped








>  cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
>  cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
>  if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
>
> base-commit: e3bf4ec9d54ed96fb3eb7dd53edcc9452897604d
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index ac3e5ac01d8a..f5d6ce95b4f0 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -60,6 +60,15 @@  cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
 # DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
 %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} DEPMOD=true modules_install
 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
+(
+	# eu-strip tries to truncate its output file, which does not end
+	# well with -o /dev/null. so output to a junk temp file instead
+	tmp=$(mktemp)
+	trap "rm -f $tmp" 0
+	eu-strip --remove-comment \
+		-f %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinux.debug \
+		-o $tmp vmlinux
+)
 cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
 cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
 if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then