linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
@ 2024-05-27  0:56 Mateusz Kowalczyk
  2024-05-28 16:09 ` James Clark
  2024-06-04 13:26 ` [PATCH] " Leo Yan
  0 siblings, 2 replies; 7+ messages in thread
From: Mateusz Kowalczyk @ 2024-05-27  0:56 UTC (permalink / raw)
  To: linux-perf-users

Hi,

To build recent perf, I'm having to apply the below patch.

```diff
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 7f1e016a9253..b70fef12a977 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -1181,7 +1181,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
     CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
     LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
     EXTLIBS += ${TRACEEVENTLIBS}
-    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
+    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
     LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
     LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
     LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
```

I don't understand why `PKG_CONFIG_PATH` is overwritten this way. `grep`ing for PKG_CONFIG_PATH reveals that this isn't done anywhere else in the kernel tree. All other uses of `$(PKG_CONFIG)` in the file simply invoke the tool.

Of course, I do actually have `libtraceevent.pc` available, it's just that `LIBTRACEVENT_DIR` is empty which stops it from finding it.

```
[shana@aya:~/programming/linux/tools/perf]$ pkg-config --modversion libtraceevent
1.8.2
```

If I do not apply the patch, I'm getting the below errors during build.

I'm not sure how others are getting it to build, maybe I'm doing something wrong? Please let me know. If the diff is fine, it'd be great if anyone could apply it.

Thanks!

```
Perhaps you should add the directory containing `libtraceevent.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libtraceevent' found
expr: syntax error: unexpected argument ‘255’

Auto-detecting system features:
...                                   dwarf: [ on  ]
...                      dwarf_getlocations: [ on  ]
...                                   glibc: [ on  ]
...                                  libbfd: [ on  ]
...                          libbfd-buildid: [ on  ]
...                                  libcap: [ on  ]
...                                  libelf: [ on  ]
...                                 libnuma: [ on  ]
...                  numa_num_possible_cpus: [ on  ]
...                                 libperl: [ on  ]
...                               libpython: [ on  ]
...                               libcrypto: [ on  ]
...                               libunwind: [ on  ]
...                      libdw-dwarf-unwind: [ on  ]
...                             libcapstone: [ OFF ]
...                                    zlib: [ on  ]
...                                    lzma: [ on  ]
...                               get_cpuid: [ on  ]
...                                     bpf: [ on  ]
...                                  libaio: [ on  ]
...                                 libzstd: [ on  ]

  INSTALL libsubcmd_headers
  PERF_VERSION = 6.10.rc1.g1613e604df0c
  GEN     perf-archive
  GEN     perf-iostat
  INSTALL libsymbol_headers
  INSTALL libapi_headers
  INSTALL libperf_headers
  INSTALL libbpf_headers
  TEST    pmu-events/metric_test.log
  CC      builtin-bench.o
  CC      builtin-annotate.o
  CC      builtin-config.o
  CC      builtin-diff.o
  CC      builtin-evlist.o
  CC      builtin-ftrace.o
  CC      builtin-help.o
  CC      builtin-buildid-list.o
  CC      builtin-buildid-cache.o
  CC      builtin-kallsyms.o
  CC      builtin-list.o
  GEN     pmu-events/pmu-events.c
In file included from util/session.h:5,
                 from builtin-buildid-list.c:17:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
In file included from util/session.h:5,
                 from builtin-evlist.c:15:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
In file included from util/session.h:5,
                 from builtin-buildid-cache.c:24:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
  CC      builtin-record.o
In file included from util/session.h:5,
                 from builtin-diff.c:15:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
  CC      builtin-report.o
  CC      builtin-stat.o
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-list.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-evlist.o] Error 1
In file included from util/session.h:5,
                 from builtin-annotate.c:32:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-cache.o] Error 1
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-annotate.o] Error 1
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-diff.o] Error 1
In file included from util/session.h:5,
                 from builtin-record.c:27:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
In file included from util/session.h:5,
                 from builtin-stat.c:60:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
In file included from util/session.h:5,
                 from builtin-report.c:35:
util/trace-event.h:152:62: error: operator '&&' has no right operand
  152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
      |                                                              ^~
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-record.o] Error 1
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-report.o] Error 1
make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-stat.o] Error 1
make[2]: *** [Makefile.perf:727: perf-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
  CC      pmu-events/pmu-events.o
  LD      pmu-events/pmu-events-in.o
make[1]: *** [Makefile.perf:264: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
perf version 6.10.rc1.g5f00d82dec63

```

--
Mateusz K.

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

* Re: Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
  2024-05-27  0:56 Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH? Mateusz Kowalczyk
@ 2024-05-28 16:09 ` James Clark
  2024-05-29  0:05   ` Mateusz Kowalczyk
  2024-06-04 13:26 ` [PATCH] " Leo Yan
  1 sibling, 1 reply; 7+ messages in thread
From: James Clark @ 2024-05-28 16:09 UTC (permalink / raw)
  To: Mateusz Kowalczyk, linux-perf-users



On 27/05/2024 01:56, Mateusz Kowalczyk wrote:
> Hi,
> 
> To build recent perf, I'm having to apply the below patch.
> 
> ```diff
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 7f1e016a9253..b70fef12a977 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -1181,7 +1181,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
>      CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
>      LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
>      EXTLIBS += ${TRACEEVENTLIBS}
> -    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
> +    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
>      LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>      LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>      LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
> ```
> 
> I don't understand why `PKG_CONFIG_PATH` is overwritten this way. `grep`ing for PKG_CONFIG_PATH reveals that this isn't done anywhere else in the kernel tree. All other uses of `$(PKG_CONFIG)` in the file simply invoke the tool.
> 

Hi Mateusz,

If PKG_CONFIG_PATH being overwritten is an issue, I'm assuming that you
have it set in your shell already? Is there a reason you aren't using
the default? Or is it that your version of pkg-config doesn't like that
var being set to an empty value?

> Of course, I do actually have `libtraceevent.pc` available, it's just that `LIBTRACEVENT_DIR` is empty which stops it from finding it.
> 
> ```
> [shana@aya:~/programming/linux/tools/perf]$ pkg-config --modversion libtraceevent
> 1.8.2
> ```
> 
> If I do not apply the patch, I'm getting the below errors during build.
> 
> I'm not sure how others are getting it to build, maybe I'm doing something wrong? Please let me know. If the diff is fine, it'd be great if anyone could apply it.
> 

I think your diff needs a small change. I'm assuming it was done this
way to allow the custom libtraceevent path to be specified with
LIBTRACEEVENT_DIR. If you remove that then it can't be done anymore.

Isn't the right change to set PKG_CONFIG_PATH if LIBTRACEEVENT_DIR is
set, but otherwise leave it unset?

But yes the build is working fine for me.

James


> Thanks!
> 
> ```
> Perhaps you should add the directory containing `libtraceevent.pc'
> to the PKG_CONFIG_PATH environment variable
> No package 'libtraceevent' found
> expr: syntax error: unexpected argument ‘255’
> 
> Auto-detecting system features:
> ...                                   dwarf: [ on  ]
> ...                      dwarf_getlocations: [ on  ]
> ...                                   glibc: [ on  ]
> ...                                  libbfd: [ on  ]
> ...                          libbfd-buildid: [ on  ]
> ...                                  libcap: [ on  ]
> ...                                  libelf: [ on  ]
> ...                                 libnuma: [ on  ]
> ...                  numa_num_possible_cpus: [ on  ]
> ...                                 libperl: [ on  ]
> ...                               libpython: [ on  ]
> ...                               libcrypto: [ on  ]
> ...                               libunwind: [ on  ]
> ...                      libdw-dwarf-unwind: [ on  ]
> ...                             libcapstone: [ OFF ]
> ...                                    zlib: [ on  ]
> ...                                    lzma: [ on  ]
> ...                               get_cpuid: [ on  ]
> ...                                     bpf: [ on  ]
> ...                                  libaio: [ on  ]
> ...                                 libzstd: [ on  ]
> 
>   INSTALL libsubcmd_headers
>   PERF_VERSION = 6.10.rc1.g1613e604df0c
>   GEN     perf-archive
>   GEN     perf-iostat
>   INSTALL libsymbol_headers
>   INSTALL libapi_headers
>   INSTALL libperf_headers
>   INSTALL libbpf_headers
>   TEST    pmu-events/metric_test.log
>   CC      builtin-bench.o
>   CC      builtin-annotate.o
>   CC      builtin-config.o
>   CC      builtin-diff.o
>   CC      builtin-evlist.o
>   CC      builtin-ftrace.o
>   CC      builtin-help.o
>   CC      builtin-buildid-list.o
>   CC      builtin-buildid-cache.o
>   CC      builtin-kallsyms.o
>   CC      builtin-list.o
>   GEN     pmu-events/pmu-events.c
> In file included from util/session.h:5,
>                  from builtin-buildid-list.c:17:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
> In file included from util/session.h:5,
>                  from builtin-evlist.c:15:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
> In file included from util/session.h:5,
>                  from builtin-buildid-cache.c:24:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
>   CC      builtin-record.o
> In file included from util/session.h:5,
>                  from builtin-diff.c:15:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
>   CC      builtin-report.o
>   CC      builtin-stat.o
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-list.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-evlist.o] Error 1
> In file included from util/session.h:5,
>                  from builtin-annotate.c:32:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-cache.o] Error 1
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-annotate.o] Error 1
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-diff.o] Error 1
> In file included from util/session.h:5,
>                  from builtin-record.c:27:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
> In file included from util/session.h:5,
>                  from builtin-stat.c:60:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
> In file included from util/session.h:5,
>                  from builtin-report.c:35:
> util/trace-event.h:152:62: error: operator '&&' has no right operand
>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>       |                                                              ^~
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-record.o] Error 1
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-report.o] Error 1
> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-stat.o] Error 1
> make[2]: *** [Makefile.perf:727: perf-in.o] Error 2
> make[2]: *** Waiting for unfinished jobs....
>   CC      pmu-events/pmu-events.o
>   LD      pmu-events/pmu-events-in.o
> make[1]: *** [Makefile.perf:264: sub-make] Error 2
> make: *** [Makefile:70: all] Error 2
> perf version 6.10.rc1.g5f00d82dec63
> 
> ```
> 
> --
> Mateusz K.
> 
> 

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

* Re: Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
  2024-05-28 16:09 ` James Clark
@ 2024-05-29  0:05   ` Mateusz Kowalczyk
  2024-05-29  8:34     ` James Clark
  0 siblings, 1 reply; 7+ messages in thread
From: Mateusz Kowalczyk @ 2024-05-29  0:05 UTC (permalink / raw)
  To: James Clark, linux-perf-users

On Wed, 29 May 2024, at 1:09 AM, James Clark wrote:
> On 27/05/2024 01:56, Mateusz Kowalczyk wrote:
>> Hi,
>> 
>> To build recent perf, I'm having to apply the below patch.
>> 
>> ```diff
>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>> index 7f1e016a9253..b70fef12a977 100644
>> --- a/tools/perf/Makefile.config
>> +++ b/tools/perf/Makefile.config
>> @@ -1181,7 +1181,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
>>      CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
>>      LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
>>      EXTLIBS += ${TRACEEVENTLIBS}
>> -    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
>> +    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
>>      LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>      LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>      LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>> ```
>> 
>> I don't understand why `PKG_CONFIG_PATH` is overwritten this way. `grep`ing for PKG_CONFIG_PATH reveals that this isn't done anywhere else in the kernel tree. All other uses of `$(PKG_CONFIG)` in the file simply invoke the tool.
>> 
>
> Hi Mateusz,
>
> If PKG_CONFIG_PATH being overwritten is an issue, I'm assuming that you
> have it set in your shell already? Is there a reason you aren't using
> the default? Or is it that your version of pkg-config doesn't like that
> var being set to an empty value?

I have PKG_CONFIG_PATH set in my shell already. I don't have LIBTRACEEVENT_DIR set.

I'm not sure if pkg-config version is relevant, presumably if PKG_CONFIG_PATH is empty then no matter the version, it'll fail to resolve anything? Maybe not. Either way, on my setup, PKG_CONFIG_PATH is set explicitly and libtraceevent.pc is on it.

```
[shana@aya:~/programming/linux/tools/perf]$ echo $PKG_CONFIG_PATH 
/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/lib/pkgconfig:/nix/store/azfzvr6qa3680a8prh3xrpjfr26zmm59-libxslt-1.1.39-dev/lib/pkgconfig:/nix/store/z91sa53zd8iscw7bsjphdk8s5b84hwpg-audit-3.1.2-dev/lib/pkgconfig:/nix/store/zk3sjrzfyjw14yy8jq9yn9nk41clf84q-elfutils-0.191-dev/lib/pkgconfig:/nix/store/hf0v7fphfvxrz8dvgv2fxh12vslwh9hs-newt-0.52.24/lib/pkgconfig:/nix/store/gms9ygkqyhw74nrhxqcm0xf2gpnqbpss-slang-2.3.3-dev/lib/pkgconfig:/nix/store/2nj2qa56cnq6shqskd9ixipc01s302wb-ncurses-6.4-dev/lib/pkgconfig:/nix/store/i4w2yc2np0lw8plxri2s2n244ywm1wfy-libtraceevent-1.8.2-dev/lib/pkgconfig:/nix/store/m35h4lw1sslg0vdqw0bjkcx5nqlv4pl2-libunwind-1.8.1-dev/lib/pkgconfig:/nix/store/j93y8jkrqjy18njpnszvsk792hn1vd89-xz-5.4.6-dev/lib/pkgconfig:/nix/store/wz1lmhhmvjxj2ipp2z5mvkydchhljggm-zlib-1.3.1-dev/lib/pkgconfig:/nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev/lib/pkgconfig:/nix/store/6a5ryz1dbq8n79qkgcvikgm3c4fmkp05-numactl-2.0.18-dev/lib/pkgconfig:/nix/store/wwg6376ymkhpjxy6c3w9gkbhv6l2gmqy-libxcrypt-4.4.36/lib/pkgconfig:/nix/store/ijj4lm5k5vg7fzf3w3cbpgfc98d1b01a-babeltrace-1.5.8/lib/pkgconfig:/nix/store/z2jqrpg85lkh7v9bpz24nsmac1lhs5bs-zstd-1.5.6-dev/lib/pkgconfig:/nix/store/j3hdndafs2ixbh1bhv95g6pj4bankd1i-libcap-2.69-dev/lib/pkgconfig:/nix/store/srmzd01br39m4w52v9zb66v4ghlxsxfg-attr-2.5.2-dev/lib/pkgconfig

[shana@aya:~/programming/linux/tools/perf]$ pkg-config --version
0.29.2
```

>> Of course, I do actually have `libtraceevent.pc` available, it's just that `LIBTRACEVENT_DIR` is empty which stops it from finding it.
>> 
>> ```
>> [shana@aya:~/programming/linux/tools/perf]$ pkg-config --modversion libtraceevent
>> 1.8.2
>> ```
>> 
>> If I do not apply the patch, I'm getting the below errors during build.
>> 
>> I'm not sure how others are getting it to build, maybe I'm doing something wrong? Please let me know. If the diff is fine, it'd be great if anyone could apply it.
>> 
>
> I think your diff needs a small change. I'm assuming it was done this
> way to allow the custom libtraceevent path to be specified with
> LIBTRACEEVENT_DIR. If you remove that then it can't be done anymore.
>
> Isn't the right change to set PKG_CONFIG_PATH if LIBTRACEEVENT_DIR is
> set, but otherwise leave it unset?

I think that sounds right. I'm not sure what that looks like in `Make` but if no-one is up to making the change, I can attempt it at least...

> But yes the build is working fine for me.

How does it work? Presumably you either must have LIBTRACEEVENT_DIR set or your pkg-config is able to find libraries even with empty PKG_CONFIG_PATH. The latter would explain some things. On my setup at least, there are no "global" default search locations and PKG_CONFIG_PATH basically determines all the library locations. Maybe that's the difference. I guess it's easy to verify, if you run `PKG_CONFIG_PATH= pkg-config --modversion libtraceevent` then I must assume that it returns something on your setup.

> James
>
>
>> Thanks!
>> 
>> ```
>> Perhaps you should add the directory containing `libtraceevent.pc'
>> to the PKG_CONFIG_PATH environment variable
>> No package 'libtraceevent' found
>> expr: syntax error: unexpected argument ‘255’
>> 
>> Auto-detecting system features:
>> ...                                   dwarf: [ on  ]
>> ...                      dwarf_getlocations: [ on  ]
>> ...                                   glibc: [ on  ]
>> ...                                  libbfd: [ on  ]
>> ...                          libbfd-buildid: [ on  ]
>> ...                                  libcap: [ on  ]
>> ...                                  libelf: [ on  ]
>> ...                                 libnuma: [ on  ]
>> ...                  numa_num_possible_cpus: [ on  ]
>> ...                                 libperl: [ on  ]
>> ...                               libpython: [ on  ]
>> ...                               libcrypto: [ on  ]
>> ...                               libunwind: [ on  ]
>> ...                      libdw-dwarf-unwind: [ on  ]
>> ...                             libcapstone: [ OFF ]
>> ...                                    zlib: [ on  ]
>> ...                                    lzma: [ on  ]
>> ...                               get_cpuid: [ on  ]
>> ...                                     bpf: [ on  ]
>> ...                                  libaio: [ on  ]
>> ...                                 libzstd: [ on  ]
>> 
>>   INSTALL libsubcmd_headers
>>   PERF_VERSION = 6.10.rc1.g1613e604df0c
>>   GEN     perf-archive
>>   GEN     perf-iostat
>>   INSTALL libsymbol_headers
>>   INSTALL libapi_headers
>>   INSTALL libperf_headers
>>   INSTALL libbpf_headers
>>   TEST    pmu-events/metric_test.log
>>   CC      builtin-bench.o
>>   CC      builtin-annotate.o
>>   CC      builtin-config.o
>>   CC      builtin-diff.o
>>   CC      builtin-evlist.o
>>   CC      builtin-ftrace.o
>>   CC      builtin-help.o
>>   CC      builtin-buildid-list.o
>>   CC      builtin-buildid-cache.o
>>   CC      builtin-kallsyms.o
>>   CC      builtin-list.o
>>   GEN     pmu-events/pmu-events.c
>> In file included from util/session.h:5,
>>                  from builtin-buildid-list.c:17:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>> In file included from util/session.h:5,
>>                  from builtin-evlist.c:15:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>> In file included from util/session.h:5,
>>                  from builtin-buildid-cache.c:24:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>>   CC      builtin-record.o
>> In file included from util/session.h:5,
>>                  from builtin-diff.c:15:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>>   CC      builtin-report.o
>>   CC      builtin-stat.o
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-list.o] Error 1
>> make[3]: *** Waiting for unfinished jobs....
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-evlist.o] Error 1
>> In file included from util/session.h:5,
>>                  from builtin-annotate.c:32:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-cache.o] Error 1
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-annotate.o] Error 1
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-diff.o] Error 1
>> In file included from util/session.h:5,
>>                  from builtin-record.c:27:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>> In file included from util/session.h:5,
>>                  from builtin-stat.c:60:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>> In file included from util/session.h:5,
>>                  from builtin-report.c:35:
>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>       |                                                              ^~
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-record.o] Error 1
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-report.o] Error 1
>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-stat.o] Error 1
>> make[2]: *** [Makefile.perf:727: perf-in.o] Error 2
>> make[2]: *** Waiting for unfinished jobs....
>>   CC      pmu-events/pmu-events.o
>>   LD      pmu-events/pmu-events-in.o
>> make[1]: *** [Makefile.perf:264: sub-make] Error 2
>> make: *** [Makefile:70: all] Error 2
>> perf version 6.10.rc1.g5f00d82dec63
>> 
>> ```
>> 
>> --
>> Mateusz K.

Thanks!

--
Mateusz K

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

* Re: Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
  2024-05-29  0:05   ` Mateusz Kowalczyk
@ 2024-05-29  8:34     ` James Clark
  0 siblings, 0 replies; 7+ messages in thread
From: James Clark @ 2024-05-29  8:34 UTC (permalink / raw)
  To: Mateusz Kowalczyk, linux-perf-users



On 29/05/2024 01:05, Mateusz Kowalczyk wrote:
> On Wed, 29 May 2024, at 1:09 AM, James Clark wrote:
>> On 27/05/2024 01:56, Mateusz Kowalczyk wrote:
>>> Hi,
>>>
>>> To build recent perf, I'm having to apply the below patch.
>>>
>>> ```diff
>>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>>> index 7f1e016a9253..b70fef12a977 100644
>>> --- a/tools/perf/Makefile.config
>>> +++ b/tools/perf/Makefile.config
>>> @@ -1181,7 +1181,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
>>>      CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
>>>      LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
>>>      EXTLIBS += ${TRACEEVENTLIBS}
>>> -    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
>>> +    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
>>>      LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>>      LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>>      LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>> ```
>>>
>>> I don't understand why `PKG_CONFIG_PATH` is overwritten this way. `grep`ing for PKG_CONFIG_PATH reveals that this isn't done anywhere else in the kernel tree. All other uses of `$(PKG_CONFIG)` in the file simply invoke the tool.
>>>
>>
>> Hi Mateusz,
>>
>> If PKG_CONFIG_PATH being overwritten is an issue, I'm assuming that you
>> have it set in your shell already? Is there a reason you aren't using
>> the default? Or is it that your version of pkg-config doesn't like that
>> var being set to an empty value?
> 
> I have PKG_CONFIG_PATH set in my shell already. I don't have LIBTRACEEVENT_DIR set.
> 
> I'm not sure if pkg-config version is relevant, presumably if PKG_CONFIG_PATH is empty then no matter the version, it'll fail to resolve anything? Maybe not. Either way, on my setup, PKG_CONFIG_PATH is set explicitly and libtraceevent.pc is on it.
> 
> ```
> [shana@aya:~/programming/linux/tools/perf]$ echo $PKG_CONFIG_PATH 
> /nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/lib/pkgconfig:/nix/store/azfzvr6qa3680a8prh3xrpjfr26zmm59-libxslt-1.1.39-dev/lib/pkgconfig:/nix/store/z91sa53zd8iscw7bsjphdk8s5b84hwpg-audit-3.1.2-dev/lib/pkgconfig:/nix/store/zk3sjrzfyjw14yy8jq9yn9nk41clf84q-elfutils-0.191-dev/lib/pkgconfig:/nix/store/hf0v7fphfvxrz8dvgv2fxh12vslwh9hs-newt-0.52.24/lib/pkgconfig:/nix/store/gms9ygkqyhw74nrhxqcm0xf2gpnqbpss-slang-2.3.3-dev/lib/pkgconfig:/nix/store/2nj2qa56cnq6shqskd9ixipc01s302wb-ncurses-6.4-dev/lib/pkgconfig:/nix/store/i4w2yc2np0lw8plxri2s2n244ywm1wfy-libtraceevent-1.8.2-dev/lib/pkgconfig:/nix/store/m35h4lw1sslg0vdqw0bjkcx5nqlv4pl2-libunwind-1.8.1-dev/lib/pkgconfig:/nix/store/j93y8jkrqjy18njpnszvsk792hn1vd89-xz-5.4.6-dev/lib/pkgconfig:/nix/store/wz1lmhhmvjxj2ipp2z5mvkydchhljggm-zlib-1.3.1-dev/lib/pkgconfig:/nix/store/0bp9inq3wd4car25n60idlfics6fajjv-openssl-3.0.13-dev/lib/pkgconfig:/nix/store/6a5ryz1dbq8n79qkgcvikgm3c4fmkp05-numactl-2.0.18-dev/lib/pkgconfig:/nix/store/wwg6376ymkhpjxy6c3w9gkbhv6l2gmqy-libxcrypt-4.4.36/lib/pkgconfig:/nix/store/ijj4lm5k5vg7fzf3w3cbpgfc98d1b01a-babeltrace-1.5.8/lib/pkgconfig:/nix/store/z2jqrpg85lkh7v9bpz24nsmac1lhs5bs-zstd-1.5.6-dev/lib/pkgconfig:/nix/store/j3hdndafs2ixbh1bhv95g6pj4bankd1i-libcap-2.69-dev/lib/pkgconfig:/nix/store/srmzd01br39m4w52v9zb66v4ghlxsxfg-attr-2.5.2-dev/lib/pkgconfig
> 
> [shana@aya:~/programming/linux/tools/perf]$ pkg-config --version
> 0.29.2
> ```
> 
>>> Of course, I do actually have `libtraceevent.pc` available, it's just that `LIBTRACEVENT_DIR` is empty which stops it from finding it.
>>>
>>> ```
>>> [shana@aya:~/programming/linux/tools/perf]$ pkg-config --modversion libtraceevent
>>> 1.8.2
>>> ```
>>>
>>> If I do not apply the patch, I'm getting the below errors during build.
>>>
>>> I'm not sure how others are getting it to build, maybe I'm doing something wrong? Please let me know. If the diff is fine, it'd be great if anyone could apply it.
>>>
>>
>> I think your diff needs a small change. I'm assuming it was done this
>> way to allow the custom libtraceevent path to be specified with
>> LIBTRACEEVENT_DIR. If you remove that then it can't be done anymore.
>>
>> Isn't the right change to set PKG_CONFIG_PATH if LIBTRACEEVENT_DIR is
>> set, but otherwise leave it unset?
> 
> I think that sounds right. I'm not sure what that looks like in `Make` but if no-one is up to making the change, I can attempt it at least...
> 

Give it a go. It's probably something like this:

  trace_cfg_path := $(if
    $(LIBTRACEEVENT_DIR),$(LIBTRACEEVENT_DIR),$(PKG_CONFIG_PATH))
  $(shell PKG_CONFIG_PATH=$(trace_cfg_path) $(PKG_CONFIG) ...

Don't forget to check the patch guide:
https://docs.kernel.org/process/submitting-patches.html

>> But yes the build is working fine for me.
> 
> How does it work? Presumably you either must have LIBTRACEEVENT_DIR set or your pkg-config is able to find libraries even with empty PKG_CONFIG_PATH. The latter would explain some things. On my setup at least, there are no "global" default search locations and PKG_CONFIG_PATH basically determines all the library locations. Maybe that's the difference. I guess it's easy to verify, if you run `PKG_CONFIG_PATH= pkg-config --modversion libtraceevent` then I must assume that it returns something on your setup.
> 

Yes I'm using the default paths so I don't need to set anything, and I
assume most people are. It all makes sense that you are seeing the issue
if you are setting it.

>> James
>>
>>
>>> Thanks!
>>>
>>> ```
>>> Perhaps you should add the directory containing `libtraceevent.pc'
>>> to the PKG_CONFIG_PATH environment variable
>>> No package 'libtraceevent' found
>>> expr: syntax error: unexpected argument ‘255’
>>>
>>> Auto-detecting system features:
>>> ...                                   dwarf: [ on  ]
>>> ...                      dwarf_getlocations: [ on  ]
>>> ...                                   glibc: [ on  ]
>>> ...                                  libbfd: [ on  ]
>>> ...                          libbfd-buildid: [ on  ]
>>> ...                                  libcap: [ on  ]
>>> ...                                  libelf: [ on  ]
>>> ...                                 libnuma: [ on  ]
>>> ...                  numa_num_possible_cpus: [ on  ]
>>> ...                                 libperl: [ on  ]
>>> ...                               libpython: [ on  ]
>>> ...                               libcrypto: [ on  ]
>>> ...                               libunwind: [ on  ]
>>> ...                      libdw-dwarf-unwind: [ on  ]
>>> ...                             libcapstone: [ OFF ]
>>> ...                                    zlib: [ on  ]
>>> ...                                    lzma: [ on  ]
>>> ...                               get_cpuid: [ on  ]
>>> ...                                     bpf: [ on  ]
>>> ...                                  libaio: [ on  ]
>>> ...                                 libzstd: [ on  ]
>>>
>>>   INSTALL libsubcmd_headers
>>>   PERF_VERSION = 6.10.rc1.g1613e604df0c
>>>   GEN     perf-archive
>>>   GEN     perf-iostat
>>>   INSTALL libsymbol_headers
>>>   INSTALL libapi_headers
>>>   INSTALL libperf_headers
>>>   INSTALL libbpf_headers
>>>   TEST    pmu-events/metric_test.log
>>>   CC      builtin-bench.o
>>>   CC      builtin-annotate.o
>>>   CC      builtin-config.o
>>>   CC      builtin-diff.o
>>>   CC      builtin-evlist.o
>>>   CC      builtin-ftrace.o
>>>   CC      builtin-help.o
>>>   CC      builtin-buildid-list.o
>>>   CC      builtin-buildid-cache.o
>>>   CC      builtin-kallsyms.o
>>>   CC      builtin-list.o
>>>   GEN     pmu-events/pmu-events.c
>>> In file included from util/session.h:5,
>>>                  from builtin-buildid-list.c:17:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>> In file included from util/session.h:5,
>>>                  from builtin-evlist.c:15:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>> In file included from util/session.h:5,
>>>                  from builtin-buildid-cache.c:24:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>>   CC      builtin-record.o
>>> In file included from util/session.h:5,
>>>                  from builtin-diff.c:15:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>>   CC      builtin-report.o
>>>   CC      builtin-stat.o
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-list.o] Error 1
>>> make[3]: *** Waiting for unfinished jobs....
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-evlist.o] Error 1
>>> In file included from util/session.h:5,
>>>                  from builtin-annotate.c:32:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-buildid-cache.o] Error 1
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-annotate.o] Error 1
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-diff.o] Error 1
>>> In file included from util/session.h:5,
>>>                  from builtin-record.c:27:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>> In file included from util/session.h:5,
>>>                  from builtin-stat.c:60:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>> In file included from util/session.h:5,
>>>                  from builtin-report.c:35:
>>> util/trace-event.h:152:62: error: operator '&&' has no right operand
>>>   152 | #if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
>>>       |                                                              ^~
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-record.o] Error 1
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-report.o] Error 1
>>> make[3]: *** [/home/shana/programming/linux/tools/build/Makefile.build:105: builtin-stat.o] Error 1
>>> make[2]: *** [Makefile.perf:727: perf-in.o] Error 2
>>> make[2]: *** Waiting for unfinished jobs....
>>>   CC      pmu-events/pmu-events.o
>>>   LD      pmu-events/pmu-events-in.o
>>> make[1]: *** [Makefile.perf:264: sub-make] Error 2
>>> make: *** [Makefile:70: all] Error 2
>>> perf version 6.10.rc1.g5f00d82dec63
>>>
>>> ```
>>>
>>> --
>>> Mateusz K.
> 
> Thanks!
> 
> --
> Mateusz K

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

* Re: [PATCH] Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
  2024-05-27  0:56 Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH? Mateusz Kowalczyk
  2024-05-28 16:09 ` James Clark
@ 2024-06-04 13:26 ` Leo Yan
  2024-06-04 23:53   ` Mateusz Kowalczyk
  1 sibling, 1 reply; 7+ messages in thread
From: Leo Yan @ 2024-06-04 13:26 UTC (permalink / raw)
  To: Mateusz Kowalczyk, linux-perf-users

Hi Mateusz,

On 5/27/24 01:56, Mateusz Kowalczyk wrote:
> Hi,
> 
> To build recent perf, I'm having to apply the below patch.
> 
> ```diff
> ---
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 7f1e016a9253..b70fef12a977 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -1181,7 +1181,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
>       CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
>       LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
>       EXTLIBS += ${TRACEEVENTLIBS}
> -    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
> +    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
>       LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>       LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>       LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
> ```
> 
> I don't understand why `PKG_CONFIG_PATH` is overwritten this way. `grep`ing for PKG_CONFIG_PATH reveals that this isn't done anywhere else in the kernel tree. All other uses of `$(PKG_CONFIG)` in the file simply invoke the tool.
> 
> Of course, I do actually have `libtraceevent.pc` available, it's just that `LIBTRACEVENT_DIR` is empty which stops it from finding it.

When I was fixing the cross compilation issue for perf, I also 
encountered the similar issue with you. I have sent a patch series to 
resolve the compilation issue.

It will be appreciated if you could check if the patch [1] can fix your 
reported issue or not.

Also thanks for James' reminding.

Thanks,
Leo

[1] 
https://lore.kernel.org/linux-perf-users/20240604093223.1934236-3-leo.yan@arm.com/T/#u

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

* Re: [PATCH] Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
  2024-06-04 13:26 ` [PATCH] " Leo Yan
@ 2024-06-04 23:53   ` Mateusz Kowalczyk
  2024-06-05 13:00     ` Leo Yan
  0 siblings, 1 reply; 7+ messages in thread
From: Mateusz Kowalczyk @ 2024-06-04 23:53 UTC (permalink / raw)
  To: Leo Yan, linux-perf-users

On Tue, 4 Jun 2024, at 10:26 PM, Leo Yan wrote:
> Hi Mateusz,
>
> On 5/27/24 01:56, Mateusz Kowalczyk wrote:
>> Hi,
>> 
>> To build recent perf, I'm having to apply the below patch.
>> 
>> ```diff
>> ---
>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>> index 7f1e016a9253..b70fef12a977 100644
>> --- a/tools/perf/Makefile.config
>> +++ b/tools/perf/Makefile.config
>> @@ -1181,7 +1181,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
>>       CFLAGS += -DHAVE_LIBTRACEEVENT $(LIBTRACEEVENT_CFLAGS)
>>       LDFLAGS += $(LIBTRACEEVENT_LDFLAGS)
>>       EXTLIBS += ${TRACEEVENTLIBS}
>> -    LIBTRACEEVENT_VERSION := $(shell PKG_CONFIG_PATH=$(LIBTRACEEVENT_DIR) $(PKG_CONFIG) --modversion libtraceevent)
>> +    LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent)
>>       LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>       LIBTRACEEVENT_VERSION_2 := $(word 2, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>>       LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION)))
>> ```
>> 
>> I don't understand why `PKG_CONFIG_PATH` is overwritten this way. `grep`ing for PKG_CONFIG_PATH reveals that this isn't done anywhere else in the kernel tree. All other uses of `$(PKG_CONFIG)` in the file simply invoke the tool.
>> 
>> Of course, I do actually have `libtraceevent.pc` available, it's just that `LIBTRACEVENT_DIR` is empty which stops it from finding it.
>
> When I was fixing the cross compilation issue for perf, I also 
> encountered the similar issue with you. I have sent a patch series to 
> resolve the compilation issue.
>
> It will be appreciated if you could check if the patch [1] can fix your 
> reported issue or not.

Hi Leo,

I applied the linked patch on top of latest kernel tree checkout and I can confirm that it fixes the issue for me, thank you!

> Also thanks for James' reminding.
>
> Thanks,
> Leo
>
> [1] 
> https://lore.kernel.org/linux-perf-users/20240604093223.1934236-3-leo.yan@arm.com/T/#u



--
Mateusz K.

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

* Re: [PATCH] Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
  2024-06-04 23:53   ` Mateusz Kowalczyk
@ 2024-06-05 13:00     ` Leo Yan
  0 siblings, 0 replies; 7+ messages in thread
From: Leo Yan @ 2024-06-05 13:00 UTC (permalink / raw)
  To: Mateusz Kowalczyk, Leo Yan, linux-perf-users

On 6/5/24 00:53, Mateusz Kowalczyk wrote:

[...]

>> It will be appreciated if you could check if the patch [1] can fix your
>> reported issue or not.
>
> Hi Leo,
>
> I applied the linked patch on top of latest kernel tree checkout and I can confirm that it fixes the issue for me, thank you!

Thanks a lot for the testing, Mateusz!

Leo
>> [1] https://lore.kernel.org/linux-perf-users/20240604093223.1934236-3-leo.yan@arm.com/T/#u
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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

end of thread, other threads:[~2024-06-05 13:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27  0:56 Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH? Mateusz Kowalczyk
2024-05-28 16:09 ` James Clark
2024-05-29  0:05   ` Mateusz Kowalczyk
2024-05-29  8:34     ` James Clark
2024-06-04 13:26 ` [PATCH] " Leo Yan
2024-06-04 23:53   ` Mateusz Kowalczyk
2024-06-05 13:00     ` Leo Yan

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