public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Guilherme Amadio <amadio@gentoo.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/2] perf build: conditionally add feature check flags for libtrace{event,fs}
Date: Fri, 28 Jun 2024 11:54:46 -0700	[thread overview]
Message-ID: <Zn8G9gyvo98AT8ni@google.com> (raw)
In-Reply-To: <Zn61WOXCq0MRQovH@gentoo.org>

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
> > 

      reply	other threads:[~2024-06-28 18:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 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=Zn8G9gyvo98AT8ni@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=amadio@gentoo.org \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    /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