Use host-libbpf for host-pahole.
cover Use host-libbpf for host-pahole.
Hi.
Following a failed build involving libbpf, Thomas Pettazzoni suggested me to remove git submodule from host-pahole to build it the "buildroot way".
So, in this contribution, I first added host recipe to libbpf. Then, I removed git submobule used by host-pahole to get libbpf to instead use host-libbpf.
I was able to build and run a qemu image:
Welcome to Buildroot
buildroot login: root
# zcat /proc/config.gz | grep BTF CONFIG_DEBUG_INFO_BTF=y CONFIG_PAHOLE_HAS_SPLIT_BTF=y CONFIG_DEBUG_INFO_BTF_MODULES=y
Nonetheless, I am not really happy with this contribution as I had to add a bad tweak removing a header file installed by host-libbpf to avoid a kernel build error:
So, I marked this contribution as RFC to get your opinions about it.
Francis Laniel (2):
package/libbpf: build for host
package/pahole: use commit 73383b3a39af
linux/linux.mk | 11 +++++++++++ package/libbpf/libbpf.mk | 7 +++++++ package/pahole/pahole.hash | 2 +- package/pahole/pahole.mk | 14 +++++++------- 4 files changed, 26 insertions(+), 8 deletions(-)
Best regards and thank you in advance.
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
RFC PATCH 1/2 package/libbpf: build for host
--- package/libbpf/libbpf.mk | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
package/libbpf/libbpf.mk +25 -0
@@ -10,6 +10,7 @@ LIBBPF_LICENSE = GPL-2.0, LGPL-2.1, BSD-2-Clause LIBBPF_LICENSE_FILES = LICENSE LICENSE.BSD-2-Clause LICENSE.LGPL-2.1 LIBBPF_CPE_ID_VENDOR = libbpf_project LIBBPF_DEPENDENCIES = host-bison host-flex host-pkgconf elfutils zlib +HOST_LIBBPF_DEPENDENCIES = host-bison host-flex host-pkgconf host-elfutils host-zlib LIBBPF_INSTALL_STAGING = YES define LIBBPF_BUILD_CMDS
@@ -38,4 +39,28 @@ define LIBBPF_INSTALL_TARGET_CMDS -C $(@D)/src install DESTDIR=$(TARGET_DIR) endef +define HOST_LIBBPF_INSTALL_CMDS + $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) \ + -C $(@D)/src install install_uapi_headers DESTDIR=$(HOST_DIR) + + # We need to install_uapi_headers so we have btf.h to compile + # host-pahole. + # Nonetheless, this target adds bpf.h which generates a conflict when + # building the kernel: + # In file included from libbpf_internal.h:17:0, from strset.c:9: + # relo_core.h:10:6: error: nested redefinition of ‘enum bpf_core_relo_kind’ + # enum bpf_core_relo_kind { + # ^~~~~~~~~~~~~~~~~~ + # relo_core.h:10:6: error: redeclaration of ‘enum bpf_core_relo_kind’ + # In file included from libbpf_legacy.h:13:0, + # from libbpf_internal.h:16, + # from strset.c:9: + # /home/francis/buildroot/output/host/include/linux/bpf.h:6497:6: note: originally defined here + # enum bpf_core_relo_kind { + # So, better to remove remove it now since we do not need it to build + # host-pahole. + rm $(HOST_DIR)/include/linux/bpf.h +endef + $(eval $(generic-package)) +$(eval $(host-generic-package))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Arnout Vandecappelle
AppliedRe: [Buildroot] [RFC PATCH v1 1/2] package/libbpf: build for host
Quoted 31 lines · Francis Laniel
Signed-off-by Francis Laniel <[email protected]>--- package/libbpf/libbpf.mk | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)package/libbpf/libbpf.mk +11
-0@@ -10,6 +10,7 @@ LIBBPF_LICENSE = GPL-2.0, LGPL-2.1, BSD-2-Clause LIBBPF_LICENSE_FILES = LICENSE LICENSE.BSD-2-Clause LICENSE.LGPL-2.1 LIBBPF_CPE_ID_VENDOR = libbpf_project LIBBPF_DEPENDENCIES = host-bison host-flex host-pkgconf elfutils zlib +HOST_LIBBPF_DEPENDENCIES = host-bison host-flex host-pkgconf host-elfutils host-zlib LIBBPF_INSTALL_STAGING = YES define LIBBPF_BUILD_CMDS@@ -38,4 +39,28 @@ define LIBBPF_INSTALL_TARGET_CMDS -C $(@D)/src install DESTDIR=$(TARGET_DIR) endef +define HOST_LIBBPF_INSTALL_CMDS + $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) \ + -C $(@D)/src install install_uapi_headers DESTDIR=$(HOST_DIR) + + # We need to install_uapi_headers so we have btf.h to compile + # host-pahole. + # Nonetheless, this target adds bpf.h which generates a conflict when + # building the kernel: + # In file included from libbpf_internal.h:17:0, from strset.c:9: + # relo_core.h:10:6: error: nested redefinition of ‘enum bpf_core_relo_kind’
package/libbpf/libbpf.mk define LIBBPF_INSTALL_TARGET_CMDS · line 61
Quoted 10 lines
package/libbpf/libbpf.mk +10
-0+ # enum bpf_core_relo_kind { + # ^~~~~~~~~~~~~~~~~~ + # relo_core.h:10:6: error: redeclaration of ‘enum bpf_core_relo_kind’ + # In file included from libbpf_legacy.h:13:0, + # from libbpf_internal.h:16, + # from strset.c:9: + # /home/francis/buildroot/output/host/include/linux/bpf.h:6497:6: note: originally defined here + # enum bpf_core_relo_kind { + # So, better to remove remove it now since we do not need it to build + # host-pahole.
This entire comment shows up in the build log because make echoes commands and
these are commands. So I moved it outside of the define.
Applied both to master, thanks. In the second commit, I also reworded the
commit message a bit.
Regards,
Arnout
package/libbpf/libbpf.mk define LIBBPF_INSTALL_TARGET_CMDS · line 66
Quoted 5 lines
package/libbpf/libbpf.mk +4
-0+ rm $(HOST_DIR)/include/linux/bpf.h +endef + $(eval $(generic-package)) +$(eval $(host-generic-package))
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
RFC PATCH 2/2 package/pahole: use commit 73383b3a39af
In reply to Francis LanielThis modification uses buildroot host-libbpf instead of pahole libbpf git submodule.
Also, it nows uses commit:73383b3a39af ("libbpf: Update libbpf to the latest git HEAD")
To avoid compile errors due to use of depecrated APIs (like btf__get_nr_types).
A build pre hook was also added to Linux to avoid conflicts regarding bpf.h which added to HOST_DIR by host-libbpf.
--- package/pahole/pahole.hash | 2 +- package/pahole/pahole.mk | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
package/pahole/pahole.hash +1 -1
@@ -1,3 +1,3 @@ # Locally computed -sha256 cde85af68b368f50a913be387f94f6b43612a04af6c92387b4dcabb712a668fe pahole-v1.23-br1.tar.gz +sha256 3531396c0568793ef8ca1a2fbb44ef2e1e81bdd55496a4487b83ba4d95df9d99 pahole-73383b3a39afe86b22e098773e47b8546c48a649.tar.gz sha256 ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6 COPYING
package/pahole/pahole.mk +7 -7
@@ -4,14 +4,14 @@ # ################################################################################ -PAHOLE_VERSION = v1.23 -PAHOLE_SITE = https://git.kernel.org/pub/scm/devel/pahole/pahole.git -PAHOLE_SITE_METHOD = git -# pahole contains git submodule and relies on them to be built. -PAHOLE_GIT_SUBMODULES = YES -HOST_PAHOLE_DEPENDENCIES = host-elfutils +PAHOLE_VERSION = 73383b3a39afe86b22e098773e47b8546c48a649 +PAHOLE_SITE = https://git.kernel.org/pub/scm/devel/pahole/pahole.git/snapshot +HOST_PAHOLE_DEPENDENCIES = \ + host-elfutils \ + host-libbpf # Defining __LIB is needed to build pahole. -HOST_PAHOLE_CONF_OPTS = -D__LIB=lib +# Set LIBBPF_EMBEDDED to OFF to use host-libbpf. +HOST_PAHOLE_CONF_OPTS = -D__LIB=lib -DLIBBPF_EMBEDDED=OFF PAHOLE_LICENSE = GPL-2.0 PAHOLE_LICENSE_FILES = COPYING
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot