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>,
	Samuel Martin <s.martin49@gmail.com>
Subject: [Buildroot] [PATCH v2 2/2] linux: add BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE
Date: Wed, 22 Dec 2021 18:49:05 +0100	[thread overview]
Message-ID: <20211222174905.71902-3-flaniel@linux.microsoft.com> (raw)
In-Reply-To: <20211222174905.71902-1-flaniel@linux.microsoft.com>

CONFIG_DEBUG_BTF_INFO relies on pahole, so kernel DWARF are converted to BTF.
If CONFIG_DEBUG_BTF_INFO is set and BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE not,
an error message is shown and .config is not written.

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
---
 linux/Config.in               | 12 ++++++++++++
 linux/linux.mk                | 12 ++++++++++++
 package/pahole/Config.in.host |  2 ++
 3 files changed, 26 insertions(+)

diff --git a/linux/Config.in b/linux/Config.in
index 6c30100921..ef86cbc021 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -470,6 +470,18 @@ config BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF
 	  CONFIG_UNWINDER_ORC=y, please install libelf-dev,
 	  libelf-devel or elfutils-libelf-devel".
 
+config BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE
+	bool "Needs host pahole"
+	help
+	  Some Linux kernel configuration options (such as
+	  CONFIG_DEBUG_INFO_BTF) require building a host
+	  program called pahole. Enabling this option will ensure
+	  host-pahole gets built before the Linux kernel.
+
+	  Enable this option if you get a Linux kernel build failure
+	  such as "BTF: .tmp_vmlinux.btf: pahole (pahole) is not
+	  available".
+
 # Linux extensions
 source "linux/Config.ext.in"
 
diff --git a/linux/linux.mk b/linux/linux.mk
index 61fdc0c76c..acb2464e8d 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -114,6 +114,17 @@ ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF),y)
 LINUX_DEPENDENCIES += host-elfutils host-pkgconf
 endif
 
+ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE),y)
+LINUX_DEPENDENCIES += host-pahole
+else
+define LINUX_FIXUP_CONFIG_PAHOLE_CHECK
+        if grep -q "^CONFIG_DEBUG_INFO_BTF=y" $(KCONFIG_DOT_CONFIG); then \
+                echo "To use CONFIG_DEBUG_INFO_BTF, enable host-pahole (BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE)" 1>&2; \
+		exit 1; \
+        fi
+endef
+endif
+
 # If host-uboot-tools is selected by the user, assume it is needed to
 # create a custom image
 ifeq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS),y)
@@ -324,6 +335,7 @@ define LINUX_KCONFIG_FIXUP_CMDS
 		$(call KCONFIG_DISABLE_OPT,$(opt))
 	)
 	$(LINUX_FIXUP_CONFIG_ENDIANNESS)
+	$(LINUX_FIXUP_CONFIG_PAHOLE_CHECK)
 	$(if $(BR2_arm)$(BR2_armeb),
 		$(call KCONFIG_ENABLE_OPT,CONFIG_AEABI))
 	$(if $(BR2_powerpc)$(BR2_powerpc64)$(BR2_powerpc64le),
diff --git a/package/pahole/Config.in.host b/package/pahole/Config.in.host
index e427629632..521874961b 100644
--- a/package/pahole/Config.in.host
+++ b/package/pahole/Config.in.host
@@ -3,4 +3,6 @@ config BR2_PACKAGE_HOST_PAHOLE
 	help
 	  Pahole and other DWARF utils.
 
+	  Select this if you want to build a kernel with CONFIG_DEBUG_INFO_BTF set.
+
 	  https://git.kernel.org/pub/scm/devel/pahole/pahole.git
-- 
2.30.2

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

  parent reply	other threads:[~2021-12-22 17:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 17:49 [Buildroot] [PATCH v2 0/2] Enable BTF headers for Linux kernel Francis Laniel
2021-12-22 17:49 ` [Buildroot] [PATCH v2 1/2] package/pahole: new host package Francis Laniel
2022-01-13 21:40   ` Thomas Petazzoni
2021-12-22 17:49 ` Francis Laniel [this message]
2022-01-13 21:41   ` [Buildroot] [PATCH v2 2/2] linux: add BR2_LINUX_KERNEL_NEEDS_HOST_PAHOLE Thomas Petazzoni
2022-01-17 13:51     ` Francis Laniel

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=20211222174905.71902-3-flaniel@linux.microsoft.com \
    --to=flaniel@linux.microsoft.com \
    --cc=buildroot@buildroot.org \
    --cc=s.martin49@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