Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 890963 - sys-devel/binutils-2.40 breaks kernel BTF generation with dev-util/pahole-1.24
Summary: sys-devel/binutils-2.40 breaks kernel BTF generation with dev-util/pahole-1.24
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Matthias Schwarzott
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-15 18:03 UTC by Johannes Penßel
Modified: 2023-01-27 21:21 UTC (History)
3 users (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 Johannes Penßel 2023-01-15 18:03:27 UTC
When building the Linux (6.1.6) kernel using binutils-2.40 with CONFIG_DEBUG_INFO_BTF=y, the process fails with the following message:

  DESCEND objtool
  DESCEND bpf/resolve_btfids
  CALL    scripts/checksyscalls.sh
  CHK     kernel/kheaders_data.tar.xz
  UPD     include/generated/utsversion.h
  CC      init/version-timestamp.o
  LD      .tmp_vmlinux.btf
  BTF     .btf.vmlinux.bin.o
Unsupported DW_TAG_unspecified_type(0x3b)
Encountered error while encoding BTF.
  LD      .tmp_vmlinux.kallsyms1
  NM      .tmp_vmlinux.kallsyms1.syms
  KSYMS   .tmp_vmlinux.kallsyms1.S
  AS      .tmp_vmlinux.kallsyms1.S
  LD      .tmp_vmlinux.kallsyms2
^Cmake[1]: *** [scripts/Makefile.vmlinux:34: vmlinux] Interrupt

With pahole built from the git master branch, the problem does not occur.

$ emerge --info

Portage 3.0.43 (python 3.10.9-final-0, default/linux/amd64/17.1/no-multilib/systemd/merged-usr, gcc-12, glibc-2.36-r6, 6.1.6-gentoo x86_64)
=================================================================
System uname: Linux-6.1.6-gentoo-x86_64-12th_Gen_Intel-R-_Core-TM-_i5-1240P-with-glibc2.36
KiB Mem:    16216916 total,   5426212 free
KiB Swap:    8388604 total,   8387068 free
Timestamp of repository gentoo: Sun, 15 Jan 2023 15:32:09 +0000
Head commit of repository gentoo: 04740c4819ebe6b53a3b2b649b268f13e71f77ac

Timestamp of repository guru: Sat, 14 Jan 2023 19:17:01 +0000
Head commit of repository guru: 9f35f20e4c6161a301901fcef62746abd02b2478

sh bash 5.2_p15-r1
ld GNU ld (Gentoo 2.40 p1) 2.40
app-misc/pax-utils:        1.3.6-r1::gentoo
app-shells/bash:           5.2_p15-r1::gentoo
dev-lang/perl:             5.36.0-r1::gentoo
dev-lang/python:           3.10.9::gentoo, 3.11.1::gentoo
dev-lang/rust:             1.66.1::gentoo
dev-util/cmake:            3.25.1::gentoo
dev-util/meson:            1.0.0::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/sandbox:          2.30-r1::gentoo
sys-apps/systemd:          252.4-r1::gentoo
sys-devel/autoconf:        2.13-r7::gentoo, 2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.39-r4::gentoo, 2.40::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r1::gentoo
sys-devel/gcc:             12.2.1_p20221231::gentoo
sys-devel/gcc-config:      2.10::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo
sys-devel/llvm:            15.0.7::gentoo
sys-devel/make:            4.4::gentoo
sys-kernel/linux-headers:  6.1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r6::local
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000
    volatile: True
    sync-git-verify-commit-signature: yes

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo
    volatile: True

local
    location: /usr/local/portage/overlay
    masters: gentoo
    priority: 10
    volatile: True

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -D_FORTIFY_SOURCE=2 -fstack-clash-protection -fstack-protector-strong -flto=auto -fcf-protection=full -mshstk -g -Wall"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d"
CXXFLAGS="-O2 -pipe -march=native -D_FORTIFY_SOURCE=2 -fstack-clash-protection -fstack-protector-strong -flto=auto -fcf-protection=full -mshstk -g -Wall"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -march=native -D_FORTIFY_SOURCE=2 -fstack-clash-protection -fstack-protector-strong -flto=auto -fcf-protection=full -mshstk -g -Wall"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live cgroup compressdebug config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=native -D_FORTIFY_SOURCE=2 -fstack-clash-protection -fstack-protector-strong -flto=auto -fcf-protection=full -mshstk -g -Wall"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-O2 -pipe -march=native -D_FORTIFY_SOURCE=2 -fstack-clash-protection -fstack-protector-strong -flto=auto -fcf-protection=full -mshstk -g -Wall -Wl,--as-needed -Wl,--enable-new-dtags -Wl,--build-id=sha1 -Wl,-z,relro,-z,now -Wl,-O1"
LEX="flex"
MAKEOPTS="-j16"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RUSTFLAGS="-C target-cpu=native -C dwarf-version=5"
SHELL="/bin/zsh"
USE="acl afp alsa amd64 amr apng apparmor archive argon2 audit bcrypt blake2 bluetooth boost bs2b btrfs bzip2 cairo caps cet chromium clang cli cloudproviders colord connection-sharing crypt cryptsetup cups curl cxx dbus default-compiler-rt default-lld device-mapper djvu dracut drm eds egl eglfs exif fat fdk ffmpeg flatpak fontconfig fonts fortran freetype fribidi gbm gdbm geolocation gif gles2 gles2-only glib gmp gnome gnome-desktop gnome-keyring gnome-online-accounts gnome-shell gnuefi gsettings gstreamer gtk gtk3 gtk4 harfbuzz hpn hsts iconv icu idn idn2 introspection io-uring ios ipv6 iwd jit jpeg jpeg2k jpegxl kbd ktls ladspa lcms libaom libdrm libglvnd libidn2 libmount libproxy libtirpc libv4l libxml2 llvm lmdb lto lv2 lzma minizip modemmanager mp3 mpc mpfr mtp natspec nautilus ncurses networkmanager nfs nftables nls nptl numa oauth ogg openal openh264 openmp opus pam pango pcre pcre2 pdf perl pgo pipewire png policykit postproc postscript psl pulseaudio qml qsv qt6 readline rubberband samba screencast seccomp speex ssl stemmer svg sysprof systemd systemtap tdb test-rust theora threads tiff tpm tracker truetype udev udisks unicode unwind upower v4l vaapi vala valgrind verify-sig vfat vorbis vpx vulkan wayland weather webp wifi x264 x265 xattr xml xxhash zeroconf zlib zram zstd" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby31" USERLAND="GNU" VIDEO_CARDS="intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Comment 1 Johannes Penßel 2023-01-15 18:05:46 UTC
CORRECTION: the pahole from git is affected as well.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-15 18:18:48 UTC
https://lore.kernel.org/all/YzwkazNc6wNCpQTN@kernel.org/t/ possibly (not read the thread yet).
Comment 3 Holger Hoffstätte 2023-01-15 19:02:56 UTC
Confirmed with 6.1.6, WTF are these guys doing..
Comment 4 Holger Hoffstätte 2023-01-15 19:17:32 UTC
So if I build pahole/next from git, replace the pahole binary and build again I get:

..
  LD      .tmp_vmlinux.btf
  BTF     .btf.vmlinux.bin.o
  LD      .tmp_vmlinux.kallsyms1
  NM      .tmp_vmlinux.kallsyms1.syms
  KSYMS   .tmp_vmlinux.kallsyms1.S
  AS      .tmp_vmlinux.kallsyms1.S
  LD      .tmp_vmlinux.kallsyms2
  NM      .tmp_vmlinux.kallsyms2.syms
  KSYMS   .tmp_vmlinux.kallsyms2.S
  AS      .tmp_vmlinux.kallsyms2.S
  LD      vmlinux
  BTFIDS  vmlinux
  NM      System.map
  SORTTAB vmlinux
..

There's a whole boatload of patches since 1.24:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/log/?h=next

I tried to selectively apply only the necessary bits but it turns out to be another great episode of whack-a-mole, with 10 patches in and always one more bit missing.

Maybe select & apply everything since 1.24 into a patchball? That's the best I can think of right now.
Comment 5 Holger Hoffstätte 2023-01-15 19:40:17 UTC
Just to make sure I did a full kernel/modules build with the pahole/next binary, booted the result and bpftrace still works fine.
So that should be safe, for Gentoo definitions of "safe". :D
Comment 6 Holger Hoffstätte 2023-01-15 20:27:28 UTC
Also not sure about comment#1, pahole/master also works fine since it has the relevant commits. That would make the patchset smaller (by ~half).
Comment 7 Holger Hoffstätte 2023-01-15 21:29:16 UTC
$ git clone git://git.kernel.org/pub/scm/devel/pahole/pahole.git
$ cd pahole
$ mkdir -p /etc/portage/patches/dev-util/pahole
$ git format-patch --stdout v1.24 > binutils-2.40-fix.patch
$ mv binutils-2.40-fix.patch /etc/portage/patches/dev-util/pahole
$ emerge -v1 \=pahole-1.24
$ build kernel
$ \o/

The patchset is 88k and 23k gzipped, so probably too large for in-tree.
Comment 8 Johannes Penßel 2023-01-15 21:45:33 UTC
(In reply to Holger Hoffstätte from comment #6)
> Also not sure about comment#1, pahole/master also works fine since it has
> the relevant commits. That would make the patchset smaller (by ~half).

It probably failed again because I did not perform a kernel rebuild with the new pahole, but simply tried to complete the unsuccessful one.
Comment 9 Argh!... Rats!... 2023-01-19 00:40:01 UTC
Can confirm Problem at Kernel Build but somehow i doubt that it is pahole.
I suspect binutils-libs maybe....

Fact is that file:
- .tmp_vmlinux.btf 

is either not present in source or not created by pahole(???) or whatever creates it.

Not sure if this might be related:
- https://lore.kernel.org/all/YzwkazNc6wNCpQTN@kernel.org/t/

I tested build of Kernel 6.1.6 and 6.1.7 which both show same Problem.
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-19 01:13:00 UTC
(In reply to Argh!... Rats!... from comment #9)
> Can confirm Problem at Kernel Build but somehow i doubt that it is pahole.
> I suspect binutils-libs maybe....
> 

Please see the discussion above and the linked mailing list threads, as well as the patches.

It's to do with new binutils (not binutils-libs) but that doesn't mean the fault lies with it.
Comment 11 Argh!... Rats!... 2023-01-19 02:02:39 UTC
(In reply to Sam James from comment #10)
> (In reply to Argh!... Rats!... from comment #9)
> > Can confirm Problem at Kernel Build but somehow i doubt that it is pahole.
> > I suspect binutils-libs maybe....
> > 
> 
> Please see the discussion above and the linked mailing list threads, as well
> as the patches.
> 
> It's to do with new binutils (not binutils-libs) but that doesn't mean the
> fault lies with it.

does downgrade to binutils-2.39-r4 help?
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-19 02:21:16 UTC
(In reply to Argh!... Rats!... from comment #11)
> does downgrade to binutils-2.39-r4 help?

It should. But I'm going to backport the pahole patches in a minute as well.
Comment 13 Larry the Git Cow gentoo-dev 2023-01-19 02:49:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8447b2c20881b1d6b1fe417f16c82e39e24c1ac5

commit 8447b2c20881b1d6b1fe417f16c82e39e24c1ac5
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-01-19 02:48:35 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-19 02:48:35 +0000

    dev-util/pahole: backport patches for binutils-2.40 compat
    
    Kernel fails to compile otherwise.
    
    Closes: https://bugs.gentoo.org/890963
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-util/pahole/Manifest                     |  1 +
 dev-util/pahole/pahole-1.24_p20221024.ebuild | 65 ++++++++++++++++++++++++++++
 dev-util/pahole/pahole-9999.ebuild           | 41 +++++++++++++-----
 3 files changed, 97 insertions(+), 10 deletions(-)