Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 770430 - >=sys-kernel/gentoo-kernel-5.10 and >=sys-kernel/vanilla-kernel-5.10 fail to build without libelf installed in SYSROOT
Summary: >=sys-kernel/gentoo-kernel-5.10 and >=sys-kernel/vanilla-kernel-5.10 fail to ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2021-02-14 03:02 UTC by David Michael
Modified: 2021-06-22 18:52 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 David Michael 2021-02-14 03:02:49 UTC
Building sys-kernel/gentoo-kernel in a separate ROOT fails due to missing libelf (at least when it's targeting amd64 and x86).

Auto-detecting system features:
...                        libelf: [ OFF ]
...                          zlib: [ on  ]
...                           bpf: [ on  ]

No libelf found
make[5]: *** [Makefile:287: elfdep] Error 1
make[4]: *** [/var/tmp/portage/sys-kernel/gentoo-kernel-5.10.15/work/linux-5.10/kernel/bpf/preload/Makefile:11: kernel/bpf/preload/libbpf.a] Error 2
make[3]: *** [/var/tmp/portage/sys-kernel/gentoo-kernel-5.10.15/work/linux-5.10/scripts/Makefile.build:496: kernel/bpf/preload] Error 2
make[2]: *** [/var/tmp/portage/sys-kernel/gentoo-kernel-5.10.15/work/linux-5.10/scripts/Makefile.build:496: kernel/bpf] Error 2
make[2]: *** Waiting for unfinished jobs....

There are a couple libraries in tools/build/feature/Makefile that need to be cross-compiled, i.e. declared in DEPEND.  It works after installing dev-libs/elfutils or dev-libs/libelf, so adding DEPEND="virtual/libelf" should fix it.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-02-14 08:41:00 UTC
This doesn't seem correct.  FWICS all the references to libelf are done via HOSTCC.
Comment 2 Mike Gilbert gentoo-dev 2021-02-14 14:38:37 UTC
I can confirm that kernel/bpf/preload/bpf_preload_umd is built using CC, not HOSTCC.

With CROSS_COMPILE="x86_64-pc-linux-gnu-" and HOSTCC defaulted to "gcc", the exact command line is below.

> x86_64-pc-linux-gnu-gcc -m64   -o kernel/bpf/preload/bpf_preload_umd kernel/bpf/preload/iterators/iterators.o kernel/bpf/preload/libbpf.a -lelf -lz
Comment 3 Mike Gilbert gentoo-dev 2021-02-14 14:50:14 UTC
This particular failure only affects kernels with CONFIG_BPF_PRELOAD_UMD enabled, so an unconditional entry in DEPEND might be a bit drastic.
Comment 4 David Michael 2021-02-14 15:03:36 UTC
Yes, but CONFIG_BPF_PRELOAD_UMD is defined in the config for at least amd64 and x86 with default USE flags (no savedconfig), so this build failure happens by default.
Comment 5 Mike Gilbert gentoo-dev 2021-02-14 15:05:26 UTC
It looks like Fedora sets CONFIG_BPF_PRELOAD_UMD=m, so it may make more sense to add this dependency to the ebuilds that utilize a Fedora kernel config.

It might also make sense to enable the dependency only if savedconfig is disabled: if it is enabled, the user may have disabled this kernel option and we should leave it up to them to install any dependencies.
Comment 6 Mike Gilbert gentoo-dev 2021-02-14 15:20:32 UTC
Given that bpf_preload_umd gets linked to cross-compiled shared libraries (libelf and libz), I wonder how this works at runtime. Maybe libelf and zlib need to be in both DEPEND and RDEPEND?
Comment 7 Mike Gilbert gentoo-dev 2021-02-14 15:22:45 UTC
Another simple solution would be to override Fedora's decision and disable CONFIG_BPF_PRELOAD_UMD by default. That avoids the mess entirely.
Comment 8 David Michael 2021-02-14 15:35:41 UTC
It probably doesn't need RDEPEND since it doesn't look like bpf_preload_umd is installed in the binpkg.  I'm fine with disabling the option.  I don't use the functionality.
Comment 9 Mike Gilbert gentoo-dev 2021-02-18 18:48:42 UTC
I created a PR to update base.config.
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-02-28 11:42:36 UTC
I'm probably going to add libelf to RDEPEND because of the host tools being installed.  While I've no clue how this works (or whether it doesn't) with cross, I guess adding libelf to DEPEND is less of a problem then.
Comment 11 David Michael 2021-02-28 14:37:45 UTC
I don't see objtool getting installed by kernel-build.eclass for gentoo-kernel.  Is that only installed for the -bin packages?

$ qlist gentoo-kernel | grep objtool
/usr/src/linux-5.10.16/tools/objtool/Makefile
/usr/src/linux-5.10.16/include/linux/objtool.h

Running objdump on all packaged files only shows programs linked against libcrypto and libyaml being installed, but they're under scripts and built for CBUILD, so RDEPEND won't help cross in those cases.
Comment 12 David Michael 2021-06-22 18:52:58 UTC
It looks like configs disable CONFIG_BPF_PRELOAD_UMD now, so this can be closed.