Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 938957 - kernel-build.eclass: USE=strip semantics vs USE=debug (excluding vmlinux unconditionally)
Summary: kernel-build.eclass: USE=strip semantics vs USE=debug (excluding vmlinux unco...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Distribution Kernel Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-03 06:59 UTC by Sam James
Modified: 2024-09-05 07:41 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 06:59:07 UTC
In kernel-build.eclass, we currently do...
```
        # Use the kernel build system to strip, this ensures the modules
        # are stripped *before* they are signed or compressed.
        local strip_args
        if use strip; then
                strip_args="--strip-unneeded"
        fi
        # Modules were already stripped by the kernel build system
        dostrip -x /lib/modules
[...]

        # Install vmlinux with debuginfo when requested
        if use debug; then
                if [[ "${image_path}" != "vmlinux" ]]; then
                        mv "build/vmlinux" "${ED}${kernel_dir}/vmlinux" || die
                fi
                dostrip -x "${kernel_dir}/vmlinux"
        fi
```

This interacts in an interesting way with enabling BTF debug information, because we end up not just having BTF, but also *keeping the DWARF* because we're not stripping vmlinux.

Maybe USE=strip should, if USE=-debug, call `strip` on vmlinux but make sure to pass --keep-section=".BTF" (or whatever it is).
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:00:03 UTC Comment hidden (obsolete)
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:02:37 UTC Comment hidden (obsolete)
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:06:11 UTC
(I split my other comments into bug 938958.)
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:10:23 UTC
Martin: cc'd you as you may have some input here. The context is "we're likely to enable BTF by default, trying to figure out what it's useful/not useful for USE=debug to do in light of this."
Comment 5 Martin Kletzander 2024-09-04 15:27:43 UTC
Thanks for Cc'ing me.  This is ultimately an issue with the USE flags I think.  For the whole system there are multiple FEATURES one might work with including "installsources", "compressdebug", "splitdebug", "nostrip" which have pretty clear meaning and with various combinations one is able to achieve pretty much what one desires (or at least with my limited imagination).  The kernel USE flags are much more limited and it is non-intuitive how they should behave in combination.  At least I can imagine so much when multiple people would be tasked with describing the behaviour.

I'm not that well versed in portage internals, so I don't see *why* even is there a USE flag like "debug" or "strip" when these can be derived from the features.  I can, however, imagine there is a reason for that, so I went with it when fixing the debug info installation (full vmlinux) as that was needed to make systemtap happy.  Well, at least partially, the support is still subpar compared to other distributions.  If I understand correctly the other related bug is more about this, so I'll post my findings there as well.  However I can imagine being much more flexible if kernel-build.eclass based its behaviour on the FEATURES since for each installed file it ought to be pretty straightforward to see what needs to be done with it:

- nostrip -- don't strip stuff in /boot and /lib/modules
- splitdebug -- if there's debuginfo use objdump to put it in /usr/lib/debug/, ideally install symlinks in /usr/lib/debug/.build-id/ as well, but make sure the build-ids don't change (I was not sure how to do that which became one of the reasons to use `mv` for vmlinux installation)
- installsources -- install sources to /usr/src/debug
- compressdebug -- compress debugging information in /usr/lib/debug/

and so on.  I must admit I am unaware of how feasible that is, so pardon my naivety.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-04 15:52:06 UTC
(In reply to Martin Kletzander from comment #5)
> Well, at least partially, the support is still subpar compared to other distributions. 

Will respond to the rest later (thank you Martin!), but if there's stuff you feel isn't covered by these two bugs, please feel free to file more. I want to get us to a point where systemtap is happy, even if it involves some bigger picture planning on our side.
Comment 7 Martin Kletzander 2024-09-05 07:41:48 UTC
If I understand correctly the other bug (for which I still included the comment in this one because I was in a hurry) is about making the experience better, so it should fall into the other one.  Well, also this one.  I'm not entirely sure what is the difference between these two.  If we have the same behaviour for kernel.eclass as we do for FEATURES in all other ebuilds, then both of these might be closed?  Or maybe one is about the BTF for which there might be another USE flag, but I have no idea whether that would be necessary or not.