libbpf: Remove bpf.h in linux.mk
cover libbpf: Remove bpf.h in linux.mk
Hi everyone.
I hope you are fine and the same for your relatives.
The goal of this contribution is to fix this a recurrent building problem which happens in buildroot CI (sorry for only taking care of this now...) [1]. Actually, to build host-pahole, we install host-libbpf uapi headers to the host but we remove bpf.h to avoid a conflict with this file while building the kernel [2].
Then host-pahole will use the system uapi headers to be built.
The problem with this approach is that it works while the system uapi headers permits building host-pahole which is not the case within buildroot CI.
So, a solution to this problem would be to keep bpf.h when installing uapi headers and to remove it right before building the kernel to avoid the conflict. As a consequence, we are able to build host-pahole with a good bpf.h and we can then build the kernel.
I sadly know this approach is far from being perfect but this is the only way I see to fix this build problem... So, if someone has a better idea I am up to implement it!
Francis Laniel (1):
package/libbpf: remove bpf.h in linux.mk
linux/linux.mk | 23 +++++++++++++++++++++++ package/libbpf/libbpf.mk | 21 ++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-)
Best regards and thank you in advance.
---
[1] http://autobuild.buildroot.net/results/7b3f560a773791e00b8bb32f64c0d39749b809b1/build-end.log
[2] https://github.com/buildroot/buildroot/blob/f3f441aea23dbf84fec85a9cef1aaf276c4484f0/package/libbpf/libbpf.mk#L61
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
RFC PATCH 1/1 package/libbpf: remove bpf.h in linux.mk
Removing bpf.h in host-libbpf leads to problems when building host-pahole [1]. So, we keep this file to build host-pahole and remove it before building the kernel to avoid conflicts with kernel bpf.h.
[1] http://autobuild.buildroot.net/results/7b3f560a773791e00b8bb32f64c0d39749b809b1/build-end.log
--- linux/linux.mk | 23 +++++++++++++++++++++++ package/libbpf/libbpf.mk | 21 ++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-)
linux/linux.mk +23 -0
@@ -122,6 +122,29 @@ endif ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE),y) LINUX_DEPENDENCIES += host-pahole + +# To build host-pahole, we need to install host-libbpf. +# Particularly, we need to use libbpf Makefile target install_uapi_headers to +# install a particular header file. +# But, this 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 it now as we already built host-pahole. +define LINUX_REMOVE_LIBBPF_HEADER + if [ -f $(HOST_DIR)/include/linux/bpf.h ]; then \ + rm $(HOST_DIR)/include/linux/bpf.h; \ + fi +endef + +LINUX_PRE_BUILD_HOOKS += LINUX_REMOVE_LIBBPF_HEADER else define LINUX_FIXUP_CONFIG_PAHOLE_CHECK if grep -q "^CONFIG_DEBUG_INFO_BTF=y" $(KCONFIG_DOT_CONFIG); then \
package/libbpf/libbpf.mk +4 -17
@@ -39,26 +39,13 @@ define LIBBPF_INSTALL_TARGET_CMDS -C $(@D)/src install DESTDIR=$(TARGET_DIR) endef -# 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, the only user of host-libbpf. +# 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. +# So, if this file is present, it will be removed by linux.mk. define HOST_LIBBPF_INSTALL_CMDS $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) \ -C $(@D)/src install install_uapi_headers DESTDIR=$(HOST_DIR) - rm $(HOST_DIR)/include/linux/bpf.h endef $(eval $(generic-package))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot