linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs}
@ 2024-06-27 15:06 Guilherme Amadio
  2024-06-27 15:06 ` [PATCH 2/2] perf build: warn if libtracefs is not found Guilherme Amadio
  2024-06-28 13:06 ` [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
  0 siblings, 2 replies; 5+ messages in thread
From: Guilherme Amadio @ 2024-06-27 15:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Ian Rogers, Linux Kernel Mailing List,
	linux-perf-users, Guilherme Amadio

This avoids reported warnings when the packages are not installed.

Fixes: 0f0e1f44569061e3dc590cd0b8cb74d8fd53706b
Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
---
 tools/perf/Makefile.config | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 81f73f68d256..987b48f242d3 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -182,14 +182,6 @@ endif
 FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
 FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
 
-# for linking with debug library, run like:
-# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
-FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
-FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
-
-FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
-FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
-
 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
 # include ARCH specific config
 -include $(src-perf)/arch/$(SRCARCH)/Makefile
@@ -211,6 +203,17 @@ endif
 ifneq ($(NO_LIBTRACEEVENT),1)
   ifeq ($(call get-executable,$(PKG_CONFIG)),)
   dummy := $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
+  else
+    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent),0)
+      # for linking with debug library, run like:
+      # make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
+      FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
+      FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
+    endif
+    ifeq ($(shell $(PKG_CONFIG) --exists libtracefs),0)
+      FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
+      FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
+    endif
   endif
 endif
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] perf build: warn if libtracefs is not found
  2024-06-27 15:06 [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
@ 2024-06-27 15:06 ` Guilherme Amadio
  2024-06-27 17:26   ` Ian Rogers
  2024-06-28 13:06 ` [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
  1 sibling, 1 reply; 5+ messages in thread
From: Guilherme Amadio @ 2024-06-27 15:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Ian Rogers, Linux Kernel Mailing List,
	linux-perf-users, Guilherme Amadio

Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
---
 tools/perf/Makefile.config | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 987b48f242d3..e99afc7eb4b5 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -1204,6 +1204,8 @@ ifneq ($(NO_LIBTRACEEVENT),1)
     LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))
     LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))
     CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)
+  else
+    $(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)
   endif
 endif
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] perf build: warn if libtracefs is not found
  2024-06-27 15:06 ` [PATCH 2/2] perf build: warn if libtracefs is not found Guilherme Amadio
@ 2024-06-27 17:26   ` Ian Rogers
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Rogers @ 2024-06-27 17:26 UTC (permalink / raw)
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Linux Kernel Mailing List,
	linux-perf-users, Guilherme Amadio

On Thu, Jun 27, 2024 at 8:07 AM Guilherme Amadio <amadio@gentoo.org> wrote:
>
> Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
> ---
>  tools/perf/Makefile.config | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 987b48f242d3..e99afc7eb4b5 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -1204,6 +1204,8 @@ ifneq ($(NO_LIBTRACEEVENT),1)
>      LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION)))
>      LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3))
>      CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP)
> +  else
> +    $(warning libtracefs is missing. Please install libtracefs-dev/libtracefs-devel)

This all makes sense and looks good to me. I believe perf isn't
directly depending on libtracefs and gets the dependency from
libtraceevent. Older libtraceevents didn't have libtracefs so just
warning in this case makes sense to me. I just wanted to speak my
thoughts out loud in case I was missing something.

Thanks,
Ian

>    endif
>  endif
>
> --
> 2.45.2
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs}
  2024-06-27 15:06 [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
  2024-06-27 15:06 ` [PATCH 2/2] perf build: warn if libtracefs is not found Guilherme Amadio
@ 2024-06-28 13:06 ` Guilherme Amadio
  2024-06-28 18:54   ` Namhyung Kim
  1 sibling, 1 reply; 5+ messages in thread
From: Guilherme Amadio @ 2024-06-28 13:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Ian Rogers, Linux Kernel Mailing List,
	linux-perf-users

Hi Arnaldo,

On Thu, Jun 27, 2024 at 05:06:05PM +0200, Guilherme Amadio wrote:
> This avoids reported warnings when the packages are not installed.
> 
> Fixes: 0f0e1f44569061e3dc590cd0b8cb74d8fd53706b
> Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
> ---
>  tools/perf/Makefile.config | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 81f73f68d256..987b48f242d3 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -182,14 +182,6 @@ endif
>  FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
>  FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
>  
> -# for linking with debug library, run like:
> -# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
> -FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
> -FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
> -
> -FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
> -FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
> -
>  FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
>  # include ARCH specific config
>  -include $(src-perf)/arch/$(SRCARCH)/Makefile
> @@ -211,6 +203,17 @@ endif
>  ifneq ($(NO_LIBTRACEEVENT),1)
>    ifeq ($(call get-executable,$(PKG_CONFIG)),)
>    dummy := $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
> +  else
> +    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent),0)

There is a problem here which I noticed while working on the fix for
the problem reported by Thorsten (in tools/verification/rv). We need

-    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent),0)
+    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent 2>&1 1>/dev/null; echo $$?),0)

to produce a 0 in the output, otherwise it doesn't work. I will send a v2 fixing this.

For the feature checks that depend on using FEATURE_CHECK_* like the ones below,
it looks like the best would be to find a good common place to do it instead of
redeclaring these required flags on various subdirectories. I thought about
doing that in tools/build/Makefile.feature, but since these flags depend on
using $(PKG_CONFIG), and that is also set in various places, I thought I'd ask
first before going ahead. The idea I have is to gather somewhere the packages
that are used via their .pc files, and set the appropriate FEATURE_CHECK_* flags
such that all subdirectories could get them automatically. That may require setting 
PKG_CONFIG in a common place as well, and then dropping it from places such as
tools/perf/Makefile.perf. Maybe something like this is Makefile.feature:

PKG_CONFIG = $(CROSS_COMPILE)pkg-config

ifneq ($(call get-executable,$(PKG_CONFIG)),)
    # libtraceevent
    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent 2>&1 1>/dev/null; echo $$?),0)
      FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null)
      FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent 2>/dev/null)
    endif

    # libtracefs
    ifeq ($(shell $(PKG_CONFIG) --exists libtracefs 2>&1 1>/dev/null; echo $$?),0)
      FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
      FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
    endif

    # ... other packages
endif

and this shows that we could also define a function for this, and call it for
each package, which would simplify things a bit more. These are the Makefiles
that need to be adjusted:

tools/perf/Makefile.config
tools/tracing/latency/Makefile.config
tools/tracing/rtla/Makefile.config
tools/verification/rv/Makefile.config

Best regards,
-Guilherme

> +      # for linking with debug library, run like:
> +      # make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
> +      FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
> +      FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
> +    endif
> +    ifeq ($(shell $(PKG_CONFIG) --exists libtracefs),0)
> +      FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
> +      FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
> +    endif
>    endif
>  endif
>  
> -- 
> 2.45.2
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs}
  2024-06-28 13:06 ` [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
@ 2024-06-28 18:54   ` Namhyung Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2024-06-28 18:54 UTC (permalink / raw)
  To: Guilherme Amadio
  Cc: Arnaldo Carvalho de Melo, Ian Rogers, Linux Kernel Mailing List,
	linux-perf-users

Hello,

On Fri, Jun 28, 2024 at 03:06:32PM +0200, Guilherme Amadio wrote:
> Hi Arnaldo,
> 
> On Thu, Jun 27, 2024 at 05:06:05PM +0200, Guilherme Amadio wrote:
> > This avoids reported warnings when the packages are not installed.
> > 
> > Fixes: 0f0e1f44569061e3dc590cd0b8cb74d8fd53706b
> > Signed-off-by: Guilherme Amadio <amadio@gentoo.org>
> > ---
> >  tools/perf/Makefile.config | 19 +++++++++++--------
> >  1 file changed, 11 insertions(+), 8 deletions(-)
> > 
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 81f73f68d256..987b48f242d3 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -182,14 +182,6 @@ endif
> >  FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
> >  FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
> >  
> > -# for linking with debug library, run like:
> > -# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
> > -FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
> > -FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
> > -
> > -FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
> > -FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
> > -
> >  FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
> >  # include ARCH specific config
> >  -include $(src-perf)/arch/$(SRCARCH)/Makefile
> > @@ -211,6 +203,17 @@ endif
> >  ifneq ($(NO_LIBTRACEEVENT),1)
> >    ifeq ($(call get-executable,$(PKG_CONFIG)),)
> >    dummy := $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)
> > +  else
> > +    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent),0)
> 
> There is a problem here which I noticed while working on the fix for
> the problem reported by Thorsten (in tools/verification/rv). We need
> 
> -    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent),0)
> +    ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent 2>&1 1>/dev/null; echo $$?),0)
> 
> to produce a 0 in the output, otherwise it doesn't work. I will send a v2 fixing this.

Yeah, I've noticed this too.

> 
> For the feature checks that depend on using FEATURE_CHECK_* like the ones below,
> it looks like the best would be to find a good common place to do it instead of
> redeclaring these required flags on various subdirectories. I thought about
> doing that in tools/build/Makefile.feature, but since these flags depend on
> using $(PKG_CONFIG), and that is also set in various places, I thought I'd ask
> first before going ahead. The idea I have is to gather somewhere the packages
> that are used via their .pc files, and set the appropriate FEATURE_CHECK_* flags
> such that all subdirectories could get them automatically. That may require setting 
> PKG_CONFIG in a common place as well, and then dropping it from places such as
> tools/perf/Makefile.perf. Maybe something like this is Makefile.feature:
> 
> PKG_CONFIG = $(CROSS_COMPILE)pkg-config
> 
> ifneq ($(call get-executable,$(PKG_CONFIG)),)
>     # libtraceevent
>     ifeq ($(shell $(PKG_CONFIG) --exists libtraceevent 2>&1 1>/dev/null; echo $$?),0)
>       FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null)
>       FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent 2>/dev/null)
>     endif
> 
>     # libtracefs
>     ifeq ($(shell $(PKG_CONFIG) --exists libtracefs 2>&1 1>/dev/null; echo $$?),0)
>       FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
>       FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
>     endif
> 
>     # ... other packages
> endif
> 
> and this shows that we could also define a function for this, and call it for
> each package, which would simplify things a bit more. These are the Makefiles
> that need to be adjusted:
> 
> tools/perf/Makefile.config
> tools/tracing/latency/Makefile.config
> tools/tracing/rtla/Makefile.config
> tools/verification/rv/Makefile.config

Sounds like a good idea.  It'd be great if we could remove the
duplication and share the common code for this.

Thanks,
Namhyung

> 
> > +      # for linking with debug library, run like:
> > +      # make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig
> > +      FEATURE_CHECK_CFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --cflags libtraceevent)
> > +      FEATURE_CHECK_LDFLAGS-libtraceevent := $(shell $(PKG_CONFIG) --libs libtraceevent)
> > +    endif
> > +    ifeq ($(shell $(PKG_CONFIG) --exists libtracefs),0)
> > +      FEATURE_CHECK_CFLAGS-libtracefs := $(shell $(PKG_CONFIG) --cflags libtracefs)
> > +      FEATURE_CHECK_LDFLAGS-libtracefs := $(shell $(PKG_CONFIG) --libs libtracefs)
> > +    endif
> >    endif
> >  endif
> >  
> > -- 
> > 2.45.2
> > 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-28 18:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 15:06 [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
2024-06-27 15:06 ` [PATCH 2/2] perf build: warn if libtracefs is not found Guilherme Amadio
2024-06-27 17:26   ` Ian Rogers
2024-06-28 13:06 ` [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs} Guilherme Amadio
2024-06-28 18:54   ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).