Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Francis Laniel <flaniel@linux.microsoft.com>
To: buildroot@buildroot.org
Cc: Francis Laniel <flaniel@linux.microsoft.com>,
	Romain Naour <romain.naour@gmail.com>
Subject: [Buildroot] [RFC PATCH v1 1/1] package/libbpf: remove bpf.h in linux.mk
Date: Fri, 10 Jun 2022 17:54:41 +0100	[thread overview]
Message-ID: <20220610165441.84812-2-flaniel@linux.microsoft.com> (raw)
In-Reply-To: <20220610165441.84812-1-flaniel@linux.microsoft.com>

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.

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>

[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(-)

diff --git a/linux/linux.mk b/linux/linux.mk
index 322ccabbd9..85a38fd3ee 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -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 \
diff --git a/package/libbpf/libbpf.mk b/package/libbpf/libbpf.mk
index 987d1145f1..6fd69f2536 100644
--- a/package/libbpf/libbpf.mk
+++ b/package/libbpf/libbpf.mk
@@ -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))
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2022-06-10 16:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10 16:54 [Buildroot] [RFC PATCH v1 0/1] libbpf: Remove bpf.h in linux.mk Francis Laniel
2022-06-10 16:54 ` Francis Laniel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220610165441.84812-2-flaniel@linux.microsoft.com \
    --to=flaniel@linux.microsoft.com \
    --cc=buildroot@buildroot.org \
    --cc=romain.naour@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox