From: "Mateusz Kowalczyk" <fuuzetsu@fuuzetsu.co.uk>
To: "James Clark" <james.clark@arm.com>,
linux-perf-users <linux-perf-users@vger.kernel.org>
Subject: Re: Why does libtracevent pkg-config detection wipe PKG_CONFIG_PATH?
Date: Wed, 29 May 2024 09:05:45 +0900 [thread overview]
Message-ID: <198bd01f-ffa5-4f9e-9c03-a1193eec25e4@app.fastmail.com> (raw)
In-Reply-To: <0e2d8cc4-420b-4387-9b26-2f00cbbc1a83@arm.com>
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
next prev parent reply other threads:[~2024-05-29 0:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=198bd01f-ffa5-4f9e-9c03-a1193eec25e4@app.fastmail.com \
--to=fuuzetsu@fuuzetsu.co.uk \
--cc=james.clark@arm.com \
--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;
as well as URLs for NNTP newsgroup(s).