Bug 2183758 - v6.2.8 spec file needs +BuildRequires:libbpf-devel>=0.8.0 ? libbpf build not found ?
Summary: v6.2.8 spec file needs +BuildRequires:libbpf-devel>=0.8.0 ? libbpf build not ...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 36
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-01 20:01 UTC by Jason Vas Dias
Modified: 2023-04-03 13:50 UTC (History)
18 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-04-03 13:50:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to FC36 kernel 6.2.8-100.fc36 spec file from SRPM to build perf + tools (3.46 KB, patch)
2023-04-02 00:39 UTC, Jason Vas Dias
no flags Details | Diff
Patch to tools makefiles to specify '-fPIC' and to use kernel libbpf for perf (3.16 KB, patch)
2023-04-02 00:42 UTC, Jason Vas Dias
no flags Details | Diff
Patch to fs/pipe.c to send SIGIO with POLL_HUP on peer close (2.69 KB, patch)
2023-04-02 00:45 UTC, Jason Vas Dias
no flags Details | Diff

Description Jason Vas Dias 2023-04-01 20:01:02 UTC
1. Please describe the problem:
Attempt to build kernel + perf from :
$ ls -l kernel-6.2.8-100.fc36.src.rpm 
-rw-r--r--. 1 root root 140380707 Mar 23 05:09 kernel-6.2.8-100.fc36.src.rpm

Result:

/usr/bin/make FIXDEP=1 -f Makefile.perf 
Makefile.config:593: *** Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources.  Stop.


2. What is the Version-Release number of the kernel:
6.2.8-100

3. Did it work previously in Fedora? If so, what kernel version did the issue
   *first* appear?  Old kernels are available for download at
   https://koji.fedoraproject.org/koji/packageinfo?packageID=8 :
Yes - 6.1.18 built fine

4. Can you reproduce this issue? If so, please provide the steps to reproduce
   the issue below:
See above

5. Does this problem occur with the latest Rawhide kernel? To install the
   Rawhide kernel, run ``sudo dnf install fedora-repos-rawhide`` followed by
   ``sudo dnf update --enablerepo=rawhide kernel``:
?

6. Are you running any modules that not shipped with directly Fedora's kernel?:
no

7. Please attach the kernel logs. You can get the complete kernel log
   for a boot with ``journalctl --no-hostname -k > dmesg.txt``. If the
   issue occurred on a previous boot, use the journalctl ``-b`` flag.
N/A

Comment 1 Jason Vas Dias 2023-04-01 20:39:17 UTC
Oops, sorry, 'libpf' in title should be 'libbpf'. 

Why perf should be complaining about not finding the libbpf just built 
as part of the kernel build (it did build successfully) :

[jvd@jvdspc]:~/rpmbuild/BUILD/kernel-6.2.8/linux-6.2.8-300.fc36.x86_64/tools [3295] 21:36:28 [#:1968!:21514]{0}	
$ find . -name 'libbpf.a'
./bpf/resolve_btfids/libbpf/libbpf.a


And I do have libbpf-devel installed ! 

$ rpm -q libbpf-devel
libbpf-devel-0.7.0-3.fc36.x86_64


Now, why isn't the perf build picking these facts up, is the question.

Comment 2 Jason Vas Dias 2023-04-01 21:02:15 UTC
I do have to make some patches to the spec file to get perf to be compiled under FC36:

Here is what I had to do to get the kernel I am running now to build, with my fs/pipe.c patch
(irrelevant to this bug) - I do like to build ALL kernel packages, so this patch
enabled building all previous kernels with:

$ rpmbuild -ba  SPECS/kernel.spec  --with no_fedora_disable_subpkgs --without do_sign --with release \
  --without debug --with tools --with headers --with cross-headers --with doc --with perf --with verbose \
2>&1 | tee -a LOGS/kernel-6.2.8.fc36.log
:
$ diff -U1 kernel-6.1.18-100.fc36.spec ~/rpmbuild/SPECS/kernel-6.1.18-300.fc36.x86_64.spec 
--- kernel-6.1.18-100.fc36.spec	2023-04-01 21:43:05.406088350 +0100
+++ /home/jvd/rpmbuild/SPECS/kernel-6.1.18-300.fc36.x86_64.spec	2023-03-18 14:43:51.944910586 +0000
@@ -18,2 +18,6 @@
 
+%bcond_without do_sign
+
+%bcond_with no_fedora_disable_subpkgs
+
 %if %{with clang_lto} && %{without toolchain_clang}
@@ -78,3 +82,3 @@
 %ifarch %{secure_boot_arch}
-%global signkernel 1
+%global signkernel 0%{with do_sign}
 %else
@@ -84,3 +88,3 @@
 # Sign modules on all arches
-%global signmodules 1
+%global signmodules 0%{with do_sign}
 
@@ -128,3 +132,3 @@
 %define patchversion 6.1
-%define pkgrelease 100
+%define pkgrelease 300
 %define kversion 6
@@ -134,3 +138,3 @@
 # This allows pkg_release to have configurable %%{?dist} tag
-%define specrelease 100%{?buildid}%{?dist}
+%define specrelease %{pkgrelease}%{?buildid}%{?dist}
 # This defines the kabi tarball version
@@ -232,2 +236,3 @@
 
+%if 0%{?with no_fedora_disable_subpkgs}
 %if 0%{?fedora}
@@ -247,2 +252,3 @@
 %endif
+%endif
 
@@ -865,2 +871,7 @@
 Patch1: patch-%{patchversion}-redhat.patch
+
+Patch2: fs_pipe_c_pipe_fd_sigio_poll_hup.patch
+
+Source2222: kernel-6.0.8-tools-PIE.patch
+
 %endif
@@ -1430,2 +1441,3 @@
 %setup -q -n kernel-%{tarfile_release} -c
+
 mv linux-%{tarfile_release} linux-%{KVERREL}
@@ -1438,2 +1450,5 @@
 ApplyOptionalPatch patch-%{patchversion}-redhat.patch
+
+ApplyOptionalPatch fs_pipe_c_pipe_fd_sigio_poll_hup.patch
+
 %endif
@@ -1597,3 +1612,3 @@
 
-%define make %{__make} %{?cross_opts} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}"
+%define make %{__make} %{?cross_opts} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" V=%{with verbose}
 
@@ -2293,3 +2308,19 @@
 %global perf_make \
-  %{__make} %{?make_opts} EXTRA_CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags} -Wl,-E" %{?cross_opts} -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 LIBBPF_DYNAMIC=1 LIBTRACEEVENT_DYNAMIC=1 %{?perf_build_extra_opts} prefix=%{_prefix} PYTHON=%{__python3}
+	%{__make} %{?make_opts} EXTRA_CFLAGS="${RPM_OPT_FLAGS} -fPIC" LDFLAGS="%{__global_ldflags} -fpic -Wl,-E ${LDLIBS:- -lz -lm -lpthread -lrt -ldl -lc}" %{?cross_opts} -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 LIBBPF_DYNAMIC=1 LIBTRACEEVENT_DYNAMIC=1 %{?perf_build_extra_opts} prefix=%{_prefix} PYTHON=%{__python3} V=%{with verbose}
+
+%if %{?with_perf}||%{?with_tools}
+%if 0%{?fedora}
+#
+# The default RPMOPTFLAGS ends up selecting -fpie mode by default, so we had to add -fPIC to $LDFLAGS, so
+# some makefiles must also specify -fPIC compile flags:
+#
+if [ ! -f .kernel_608_PIE_patch_applied ]; then
+   touch .kernel_608_PIE_patch_applied
+   cd tools && patch -p0 -b --suffix=.6.0.8.pie < %{SOURCE2222} && cd .. && echo "Applied -fPIC Tools Build Patch" >&2;
+else
+   :
+fi
+%endif
+%endif
+
 %if %{with_perf}
@@ -2493,2 +2524,3 @@
 cd linux-%{KVERREL}
+export LNX_SRC="$(pwd)";
 
@@ -3180,2 +3212,5 @@
 %changelog
+* Sat Mar 18 2023 Jason Vas Dias <jason.vas.dias> [6.1.14-300]
+- Apply fix for upstream kernel bug 216458 / RH BZ 2125104
+
 * Sat Mar 11 2023 Justin M. Forbes <jforbes> [6.1.18-0]

And I have to patch tools makefiles in order to inject '-fPIC' into in build args,
otherwise the '-fpie' default of newer GCC prevents linking:

This is %{SOURCE2222} :


$ cat ~/rpmbuild/SOURCES/kernel-6.0.8-tools-PIE.patch
diff -up ./gpio/Makefile~ ./gpio/Makefile
--- ./gpio/Makefile~	2022-11-10 17:17:40.000000000 +0000
+++ ./gpio/Makefile	2022-11-18 20:26:47.547144600 +0000
@@ -16,7 +16,7 @@ endif
 # (this improves performance and avoids hard-to-debug behaviour);
 MAKEFLAGS += -r
 
-override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
+override CFLAGS += -O2 -Wall -fPIC -g -D_GNU_SOURCE -I$(OUTPUT)include
 
 ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon gpio-watch
 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
diff -up ./iio/Makefile~ ./iio/Makefile
--- ./iio/Makefile~	2022-11-10 17:17:40.000000000 +0000
+++ ./iio/Makefile	2022-11-18 20:25:52.834414709 +0000
@@ -12,7 +12,7 @@ endif
 # (this improves performance and avoids hard-to-debug behaviour);
 MAKEFLAGS += -r
 
-override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
+override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include -fPIC
 
 ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
diff -up ./perf/Makefile.perf~ ./perf/Makefile.perf
--- ./perf/Makefile.perf~	2022-11-10 17:17:40.000000000 +0000
+++ ./perf/Makefile.perf	2022-11-18 19:57:57.356098020 +0000
@@ -413,7 +413,7 @@ ifdef ASCIIDOC8
 endif
 
 EXTLIBS := $(call filter-out,$(EXCLUDE_EXTLIBS),$(EXTLIBS))
-LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
+LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group ../bpf/resolve_btfids/libbpf/libbpf.a -Wl,-z,muldefs
 
 ifeq ($(USE_CLANG), 1)
   CLANGLIBS_LIST = AST Basic CodeGen Driver Frontend Lex Tooling Edit Sema Analysis Parse Serialization
diff -up ./power/x86/intel-speed-select/Makefile~ ./power/x86/intel-speed-select/Makefile
--- ./power/x86/intel-speed-select/Makefile~	2022-11-10 17:17:40.000000000 +0000
+++ ./power/x86/intel-speed-select/Makefile	2022-11-18 20:21:25.705733422 +0000
@@ -13,7 +13,7 @@ endif
 # Do not use make's built-in rules
 # (this improves performance and avoids hard-to-debug behaviour);
 MAKEFLAGS += -r
-override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include -I/usr/include/libnl3
+override CFLAGS += -O2 -Wall -fPIC -g -D_GNU_SOURCE -I$(OUTPUT)include -I/usr/include/libnl3
 override LDFLAGS += -lnl-genl-3 -lnl-3
 
 ALL_TARGETS := intel-speed-select
diff -up ./thermal/tmon/Makefile~ ./thermal/tmon/Makefile
--- ./thermal/tmon/Makefile~	2022-11-10 17:17:40.000000000 +0000
+++ ./thermal/tmon/Makefile	2022-11-18 20:24:35.076798567 +0000
@@ -12,7 +12,7 @@ override CFLAGS+= $(call cc-option,-fsta
 CC?= $(CROSS_COMPILE)gcc
 PKG_CONFIG?= $(CROSS_COMPILE)pkg-config
 
-override CFLAGS+=-D VERSION=\"$(VERSION)\"
+override CFLAGS+=-D VERSION=\"$(VERSION)\" -fPIC
 TARGET=tmon
 
 INSTALL_PROGRAM=install -m 755 -p
diff -up ./vm/Makefile~ ./vm/Makefile
--- ./vm/Makefile~	2022-11-10 17:17:40.000000000 +0000
+++ ./vm/Makefile	2022-11-18 20:27:21.497977004 +0000
@@ -8,7 +8,7 @@ TARGETS=page-types slabinfo page_owner_s
 LIB_DIR = ../lib/api
 LIBS = $(LIB_DIR)/libapi.a
 
-CFLAGS = -Wall -Wextra -I../lib/
+CFLAGS = -Wall -Wextra -I../lib/ -fPIC
 LDFLAGS = $(LIBS)
 
 all: $(TARGETS)



I do have to add:

LIBS = -Wl,--whole-archive $(PERFLIBS) $(EXTRA_PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group ../bpf/resolve_btfids/libbpf/libbpf.a -Wl,-z,muldefs

to the link line of 'perf' so that it actually builds - I've always had to do this under Fedora (not Rocky RHEL 8).

So, what is new best way of building perf ? I guess I'll have to develop a new patch to find out.

Why has it only now started complaining about not finding libbpf ? None of my make-file changes affect the use of the just built libbpf.

perf's Makefiles really need updating both to fix the missing -fPIC's, and to reliably ALWAYS use the just built kernel libbpf IFF a valid
libbpf.a exists in ../bpf/resolve_btfids/libbpf/ .

Comment 3 Jason Vas Dias 2023-04-01 21:05:14 UTC
Results of last kernel build:

$ ls -ltr *6.1.18*.rpm
-rw-r--r--. 1 jvd devel  3248057 Mar 18 19:12 kernel-selftests-internal-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel  2568185 Mar 18 19:12 bpftool-debuginfo-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel  1653621 Mar 18 19:12 kernel-headers-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel  2628721 Mar 18 19:13 perf-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   793725 Mar 18 19:13 python3-perf-debuginfo-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   917213 Mar 18 19:13 bpftool-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   543493 Mar 18 19:13 kernel-tools-debuginfo-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   266185 Mar 18 19:13 python3-perf-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   160389 Mar 18 19:13 rtla-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   134337 Mar 18 19:13 kernel-tools-libs-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   126045 Mar 18 19:13 kernel-tools-libs-devel-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   123473 Mar 18 19:13 kernel-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel  3413393 Mar 18 19:13 kernel-modules-extra-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   123609 Mar 18 19:13 kernel-devel-matched-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   362133 Mar 18 19:13 kernel-tools-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel   838765 Mar 18 19:13 kernel-modules-internal-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel 18814429 Mar 18 19:13 kernel-ipaclones-internal-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel  6987325 Mar 18 19:13 perf-debuginfo-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel  7652025 Mar 18 19:13 kernel-cross-headers-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel 16642213 Mar 18 19:13 kernel-devel-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel 49438221 Mar 18 19:13 kernel-core-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel 59281473 Mar 18 19:13 kernel-modules-6.1.18-300.fc36.x86_64.rpm
-rw-r--r--. 1 jvd devel 85472869 Mar 18 19:13 kernel-debuginfo-common-x86_64-6.1.18-300.fc36.x86_64.rpm

Just trying to achieve the same for v6.2.8 ...

Comment 4 Jason Vas Dias 2023-04-01 21:51:22 UTC
The patch I needed to resolve this particular problem was:

$ diff -U0 tools/perf/Makefile.config~ tools/perf/Makefile.config
--- tools/perf/Makefile.config~	2023-03-22 12:38:11.000000000 +0000
+++ tools/perf/Makefile.config	2023-04-01 22:42:00.631076440 +0100
@@ -593 +593,3 @@
-            dummy := $(error Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources);
+             ifneq ($(strip $(shell if [ ! -f tools/bpf/resolve_btfids/libbpf/libbpf.a ]; then echo -n OK; fi)),OK)
+	       dummy := $(error Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources);
+             endif


But now bpf_loader won't build:

	util/bpf-loader.c:36:5: warning: no previous prototype for 'bpf_program__set_insns' [-Wmissing-prototypes]
   36 | int bpf_program__set_insns(struct bpf_program *prog __maybe_unused,
      |     ^~~~~~~~~~~~~~~~~~~~~~
util/bpf-loader.c:46:47: warning: 'struct libbpf_prog_handler_opts' declared inside parameter list will not be visible outside of this definition or declaration
   46 |                                  const struct libbpf_prog_handler_opts *opts __maybe_unused)
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~
util/bpf-loader.c:43:5: warning: no previous prototype for 'libbpf_register_prog_handler' [-Wmissing-prototypes]
   43 | int libbpf_register_prog_handler(const char *sec __maybe_unused,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/bpf/libbpf.h:20,
                 from util/bpf-loader.c:10:
util/bpf-loader.c: In function 'libbpf_init':
util/bpf-loader.c:179:21: error: variable 'handler_opts' has initializer but incomplete type
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~
util/bpf-loader.c:179:9: error: invalid application of 'sizeof' to incomplete type 'struct libbpf_prog_handler_opts'
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |         ^~~~~~~~~~~
util/bpf-loader.c:179:9: error: 'struct libbpf_prog_handler_opts' has no member named 'sz'
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |         ^~~~~~~~~~~
util/bpf-loader.c:179:9: error: invalid application of 'sizeof' to incomplete type 'struct libbpf_prog_handler_opts'
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |         ^~~~~~~~~~~
util/bpf-loader.c:179:9: warning: excess elements in struct initializer
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |         ^~~~~~~~~~~
util/bpf-loader.c:179:9: note: (near initialization for '(anonymous)')
util/bpf-loader.c:180:18: error: 'struct libbpf_prog_handler_opts' has no member named 'prog_prepare_load_fn'
  180 |                 .prog_prepare_load_fn = libbpf_prog_prepare_load_fn,
      |                  ^~~~~~~~~~~~~~~~~~~~
util/bpf-loader.c:180:41: warning: excess elements in struct initializer
  180 |                 .prog_prepare_load_fn = libbpf_prog_prepare_load_fn,
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
util/bpf-loader.c:180:41: note: (near initialization for '(anonymous)')
util/bpf-loader.c:179:9: error: invalid use of undefined type 'struct libbpf_prog_handler_opts'
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |         ^~~~~~~~~~~
util/bpf-loader.c:179:47: error: storage size of 'handler_opts' isn't known
  179 |         LIBBPF_OPTS(libbpf_prog_handler_opts, handler_opts,
      |


So what version of the libbpf library provides the missing symbols ?

Must we compile perf against previous libbpf ?


I will wait until this bug is fixed & perf can build against kernel BPF headers before
building another kernel.

I know you build the Fedora kernel on RHEL systems only, I guess this is yet another
artefact of that unwise decision.

Comment 5 Jason Vas Dias 2023-04-01 23:43:56 UTC
Aha! : trying with :
# repoquery --enablerepo=rawhide-source --archlist=src libbpf
Fedora Rawhide - Source                                                                                                                                                                                                                                               9.4 kB/s | 4.4 kB     00:00    
Fedora Rawhide - Source                                                                                                                                                                                                                                               712 kB/s | 8.1 MB     00:11    
Last metadata expiration check: 0:00:05 ago on Sun 02 Apr 2023 00:40:53 IST.
libbpf-2:0.5.0-2.fc36.src
libbpf-2:0.7.0-3.fc36.src
libbpf-2:1.1.0-2.fc38.src
^^^^^^^^^^^^^^^^^^^^^^^^^
built & installed ...

Comment 6 Jason Vas Dias 2023-04-02 00:17:44 UTC
Yes, that works!

I built and installed (with rpm2cpio) the libbpf-2:1.1.0-2 from Rawhide
under /usr/local/{lib64,include}
(because I can't install the RPMs on my FC36 system),
and then perf and all packages now build OK.

So, yes, the $Title of this bug report is correct.

Please add :
 'BuildRequires: libbpf-devel>=0.8.0'
to the FC-36 spec file, (which is not currently an FC36 package,
( so why has the latest FC36 kernel moved to 6.2.x if that
  requires a package not yet in FC36 to build?
), and provide a 'libbpf-compat' set of libraries
to re-package the old libbpf-0.7.0 for FC36 so
existing code does not break.
Or maybe produce a new 'libbpf2' package for FC36.

Please, I am waiting until FC38 is released, then I will upgrade -
FC36 has a support lifetime at least until then, no ?

Comment 7 Jason Vas Dias 2023-04-02 00:20:52 UTC
(should have added: I needed to set:
 $ declare -x  | egrep  'FLAGS|PATH'
declare -x CFLAGS="-I/usr/local/include -O2 -g -fPIC"
declare -x CPPFLAGS="-I/usr/local/include"
declare -x CXXFLAGS="-O2 -g -fPIC"
declare -x LDFLAGS="-L/usr/local/lib64 -R/usr/local/lib64 -O2 -g -fpic -lz -lm -lpthread -lrt -lc"
declare -x PATH="/usr/bin:/usr/sbin"
declare -x PKGCONFIG_PATH="/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig"
declare -x PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig"
) in the build environment.

Comment 8 Jason Vas Dias 2023-04-02 00:39:59 UTC
Created attachment 1955164 [details]
Patch to FC36 kernel 6.2.8-100.fc36 spec file from SRPM to build perf + tools

Comment 9 Jason Vas Dias 2023-04-02 00:42:39 UTC
Created attachment 1955165 [details]
Patch to tools makefiles to specify '-fPIC' and to use kernel libbpf for perf

Comment 10 Jason Vas Dias 2023-04-02 00:45:43 UTC
Created attachment 1955166 [details]
Patch to fs/pipe.c to send SIGIO with POLL_HUP on peer close

Comment 11 Jason Vas Dias 2023-04-02 14:28:36 UTC
Great, the combined patches above produced a full build:

Wrote: /home/jvd/rpmbuild/SRPMS/kernel-6.2.8-300.fc36.src.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-selftests-internal-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/perf-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-headers-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/python3-perf-debuginfo-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/bpftool-debuginfo-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-modules-extra-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-modules-internal-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-tools-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-tools-debuginfo-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/python3-perf-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-tools-libs-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/rtla-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-tools-libs-devel-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-devel-matched-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/bpftool-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-ipaclones-internal-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-core-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/perf-debuginfo-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-cross-headers-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-devel-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-modules-core-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-modules-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-debuginfo-common-x86_64-6.2.8-300.fc36.x86_64.rpm
Wrote: /home/jvd/rpmbuild/RPMS/x86_64/kernel-debuginfo-6.2.8-300.fc36.x86_64.rpm

Comment 12 Jason Vas Dias 2023-04-02 14:30:10 UTC
I can copy these onto my Google Drive and share them if anyone is interested in testing.

Comment 13 Jason Vas Dias 2023-04-02 14:30:58 UTC
Please allow building all packages and fix perf build under FC36 !

Comment 14 Justin M. Forbes 2023-04-03 13:50:08 UTC
The kernel.spec does include bits for building kernel-tools, for the sake of RHEL. Those bits should be disabled for fedora builds, where kernel-tools are built as part of the kernel-tools package, and where those pieces are maintained.  Putting a buildrequires for a libbpf version which does not exist in Fedora 36 is not the correct solution here, it is turning off dynamic linking as was done in the kernel-tools package.


Note You need to log in before you can comment on or make changes to this bug.