All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Schier <nsc@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: sashiko-reviews@lists.linux.dev,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Christian Heusel" <christian@heusel.eu>,
	linux-kbuild@vger.kernel.org,
	"Adrián García Casado" <adriangarciacasado42@gmail.com>
Subject: Re: [PATCH] kbuild: package: Install System.map to build tree only
Date: Mon, 23 Nov 2026 16:58:04 +0100	[thread overview]
Message-ID: <awRijCPFYK4J5L6C@levanger> (raw)
In-Reply-To: <20261122213504.GA1454693@ax162>

On Sun, Nov 22, 2026 at 02:35:04PM -0700, Nathan Chancellor wrote:
> On Tue, Nov 17, 2026 at 03:53:56PM +0000, sashiko-bot@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found 1 potential
> > issue to consider:
> > - [Medium] kbuild: package: System.map dropped from tar-pkg and dir-pkg
> >   in buildtar
> > --
> > 
> > commit 4e40237f8938f58bf4db63fc401e165ccfea766e
> > Author: Nicolas Schier <nsc@kernel.org>
> > 
> > kbuild: package: Install System.map to build tree only
> > 
> > This commit removes the target-specific installation of System.map to
> > /boot and instead installs System.map into the packaged kernel build tree
> > via scripts/package/install-extmod-build.
> > 
> > > diff --git a/scripts/package/buildtar b/scripts/package/buildtar
> > > index cc87a473c01f4..057ca4fc7d71f 100755
> > > --- a/scripts/package/buildtar
> > > +++ b/scripts/package/buildtar
> > > @@ -45,7 +45,6 @@ make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_
> > >  #
> > >  # Install basic kernel files
> > >  #
> > > -cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
> > >  cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
> > >  cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
> > 
> > [Severity: Medium]
> > Does removing this copy drop System.map from the tar-pkg and dir-pkg
> > targets altogether?  Unlike PKGBUILD, builddeb, and kernel.spec, buildtar
> > does not package a kernel build tree or call
> > scripts/package/install-extmod-build, so System.map is no longer included
> > anywhere in the resulting tarball or directory.
> 
> Seems legitimate.
> 
> This got me thinking a little more about this change and I am not sure
> this is actually a good direction to go in. Tying the existence of
> System.map to the external module build feels wrong to me since it may
> be useful for other tools and /boot/System.map-${KERNELRELEASE} is a
> common place for it to be. I think we should probably leave it where it
> is in the current set of packaging scripts but symlink it to the
> external module build location in the places that need it.

As Distros are moving everything to /usr/ -- but I haven't seen
/usr/boot/ anywhere -- I'd prefer to move it away from /boot.  The
kmod build tree looks like the native location to me (as per
scripts/depmod.sh) and from what I can find, most debugging tools use
vmlinux or /proc/kallsyms rather than System.map; but I have never ever
tried to debug a Linux without the full source + build tree at hand.

Does System.map still help with regular debugging with CONFIG_KASLR
enabled?

If it wasn't for 'depmod -e' I'd like to put System.map to the
linux-image-${KVER}-dbg_*.deb, as Debian does.


> Something
> like this maybe (completely untested):
> 
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index ba1defc61652..4261963a901e 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -147,6 +147,13 @@ install_kernel_headers () {
>  		"${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"
>  	fi
>  
> +	if [ "${ARCH}" = um ] ; then
> +		system_map="/usr/lib/uml/modules/${KERNELRELEASE}/System.map"
> +	else
> +		system_map="/boot/System.map-${KERNELRELEASE}"
> +	fi
> +	ln -s "${system_map}" "${pdir}/usr/src/linux-headers-${version}/System.map"
> +

What about doing it the other way round?  We could provide the symlink
in the old /boot/ location for now and move System.map to the module
build tree?



>  	mkdir -p $pdir/lib/modules/$version/
>  	ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
>  }
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 8f0933cbbe45..3add2b2c7dd2 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -122,6 +122,7 @@ fi
>  ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
>  %if %{with_devel}
>  %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
> +ln -fns /lib/modules/%{KERNELRELEASE}/System.map %{buildroot}/usr/src/kernels/%{KERNELRELEASE}/System.map

Looking at line 122 (start of hunk), /lib/modules/%{KERNELRELEASE} seems to be a symlink to
/lib/modules/%{KERNELRELEASE}/build/, thus that line will would create a
funny symlink. ;)


-- 
Nicolas

  reply	other threads:[~2026-11-23 16:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 15:52 [PATCH] kbuild: package: Install System.map to build tree only Nicolas Schier
2026-11-17 15:53 ` sashiko-bot
2026-11-22 21:35   ` Nathan Chancellor
2026-11-23 15:58     ` Nicolas Schier [this message]
2026-11-24  3:03       ` Nathan Chancellor
2026-11-25 16:09         ` Nicolas Schier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awRijCPFYK4J5L6C@levanger \
    --to=nsc@kernel.org \
    --cc=adriangarciacasado42@gmail.com \
    --cc=christian@heusel.eu \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=nathan@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.