diff mbox series

[2/2] package/linux-tools: perf: explicit option for libbfd support

Message ID 20240825194124.4719-3-geomatsi@gmail.com
State Superseded
Headers show
Series perf: add binutils support in new kernels | expand

Commit Message

Sergey Matyukevich Aug. 25, 2024, 7:41 p.m. UTC
Before Linux v6.4, libbfd support in perf was opted in by default and
could be disabled using NO_LIBBFD=1. Starting from Linux v6.4, libbfd
support in perf is opted out by default and can be enabled with new
variable BUILD_NONDISTRO=1. For details see the kernel commit [1].
In brief, the reason why libbfd support in perf is usually disabled
is license: binutils is GPLv3, so some distributions can not ship
perf linked against libbfd.

This commit adds new NONDISTRO option for perf to explicitly enable
libbfd support in perf when appropriate. Note that if binutils is
enabled in config, but NONDISTRO is not enabled, then legacy option
NO_LIBBFD will be set for perf in pre-v6.4 Linux kernels.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dd317df072071903031ab5f91b4823858445c4a0

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
 package/linux-tools/Config.in             | 6 ++++++
 package/linux-tools/linux-tool-perf.mk.in | 7 +++++++
 2 files changed, 13 insertions(+)

Comments

Thomas Petazzoni Aug. 26, 2024, 1:05 p.m. UTC | #1
Hello Sergey,

On Sun, 25 Aug 2024 22:41:09 +0300
Sergey Matyukevich <geomatsi@gmail.com> wrote:

> Before Linux v6.4, libbfd support in perf was opted in by default and
> could be disabled using NO_LIBBFD=1. Starting from Linux v6.4, libbfd
> support in perf is opted out by default and can be enabled with new

s/with new/with the new/

> variable BUILD_NONDISTRO=1. For details see the kernel commit [1].
> In brief, the reason why libbfd support in perf is usually disabled
> is license: binutils is GPLv3, so some distributions can not ship
> perf linked against libbfd.
> 
> This commit adds new NONDISTRO option for perf to explicitly enable

s/adds new/adds a new/

s/for perf/to perf/

> libbfd support in perf when appropriate. Note that if binutils is
> enabled in config, but NONDISTRO is not enabled, then legacy option

s/in config/in the configuration/

s/then legacy/then the legacy option/

> NO_LIBBFD will be set for perf in pre-v6.4 Linux kernels.
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dd317df072071903031ab5f91b4823858445c4a0
> 
> Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
> ---
>  package/linux-tools/Config.in             | 6 ++++++
>  package/linux-tools/linux-tool-perf.mk.in | 7 +++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in
> index 5a38f6dafe..e87a1d571a 100644
> --- a/package/linux-tools/Config.in
> +++ b/package/linux-tools/Config.in
> @@ -112,6 +112,12 @@ config BR2_PACKAGE_LINUX_TOOLS_PERF_TUI
>  	  enables zooming into DSOs and threads as well as other
>  	  features.
>  
> +config BR2_PACKAGE_LINUX_TOOLS_PERF_NONDISTRO
> +	bool "enable perf NONDISTRO"

I know the upstream variable is named NONDISTRO, but to mean
"NONDISTRO" doesn't make any sense. Shouldn't this be named after the
feature it provides, or after binutils, or something?

> +	help
> +	  Enable building an linking against libbfd and libiberty

s/an/and/

> +	  distribution license incompatible libraries.

incompatible with what? Is it the fact that tools/perf is GPLv2 only
and libbfd/libiberty are GPLv3+ ?

I think this help text needs to be improved to really explained what
happens.

Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in
index 5a38f6dafe..e87a1d571a 100644
--- a/package/linux-tools/Config.in
+++ b/package/linux-tools/Config.in
@@ -112,6 +112,12 @@  config BR2_PACKAGE_LINUX_TOOLS_PERF_TUI
 	  enables zooming into DSOs and threads as well as other
 	  features.
 
+config BR2_PACKAGE_LINUX_TOOLS_PERF_NONDISTRO
+	bool "enable perf NONDISTRO"
+	help
+	  Enable building an linking against libbfd and libiberty
+	  distribution license incompatible libraries.
+
 config BR2_PACKAGE_LINUX_TOOLS_PERF_NEEDS_HOST_PYTHON3
 	bool "perf need python3 to build"
 	select BR2_PACKAGE_HOST_PYTHON3
diff --git a/package/linux-tools/linux-tool-perf.mk.in b/package/linux-tools/linux-tool-perf.mk.in
index 65aba2e9fe..c26a3eb31b 100644
--- a/package/linux-tools/linux-tool-perf.mk.in
+++ b/package/linux-tools/linux-tool-perf.mk.in
@@ -96,7 +96,14 @@  PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
 endif
 
 ifeq ($(BR2_PACKAGE_BINUTILS),y)
+ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_NONDISTRO),y)
 PERF_DEPENDENCIES += binutils
+# Explicitely enable for Linux >= v6.4
+PERF_MAKE_FLAGS += BUILD_NONDISTRO=1
+else
+# Explicitely disable for Linux < v6.4
+PERF_MAKE_FLAGS += NO_DEMANGLE=1 NO_LIBBFD=1
+endif
 else
 PERF_MAKE_FLAGS += NO_DEMANGLE=1
 endif