perf build: Add missing cflags when building with custom libtraceevent
PATCH 1/1 perf build: Add missing cflags when building with custom libtraceevent
From: Yicong Yang <[email protected]>
When building with custom libtraceevent, below errors occur:
$ make -C tools/perf NO_LIBPYTHON=1 PKG_CONFIG_PATH=<custom libtraceevent>
In file included from util/session.h:5,
from builtin-buildid-list.c:17:
util/trace-event.h:153:10: fatal error: traceevent/event-parse.h: No such file or directory
153 | #include <traceevent/event-parse.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
<snip similar errors of missing headers>This is because the include path is missed in the cflags. Add it.
---
Another problem occurs when building on my old Ubuntu 18.04.1 (4.15 kernel) is that linux/mount.h (which is introduced in the later kernel version) is missing. It's included in tools/include/uapi/linux/fs.h which header is introduced recently. Does it make sense to have a copy of mount.h in tools/include?
tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
@@ -1194,7 +1194,7 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT + CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent) LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent) EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent) LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0
Signature · 1 line
2.24.0
Namhyung Kim
maintainerHello,
Quoted 29 lines · Yicong Yang
From: Yicong Yang <[email protected]>
When building with custom libtraceevent, below errors occur:
$ make -C tools/perf NO_LIBPYTHON=1 PKG_CONFIG_PATH=<custom libtraceevent> In file included from util/session.h:5, from builtin-buildid-list.c:17: util/trace-event.h:153:10: fatal error: traceevent/event-parse.h: No such file or directory 153 | #include <traceevent/event-parse.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ <snip similar errors of missing headers>This is because the include path is missed in the cflags. Add it.
Fixes 0f0e1f445690 ("perf build: Use pkg-config for feature check for libtrace{event,fs}")Signed-off-by Yicong Yang <[email protected]>---
Another problem occurs when building on my old Ubuntu 18.04.1 (4.15 kernel) is thatlinux/mount.h(which is introduced in the later kernel version) is missing. It's included intools/include/uapi/linux/fs.hwhich header is introduced recently. Does it make sense to have a copy ofmount.hintools/include?tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/Makefile.config +0
-0
tools/perf/Makefile.config endif · line 1197
Quoted 5 lines
tools/perf/Makefile.config +1
-1@@ -1194,7 +1194,7 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT + CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent)
Does this solve the problem? On my machine, it returns this:
$ pkg-config --cflags libtraceevent -I/usr/include/traceevent
$ ls /usr/include/traceevent/ event-parse.h event-utils.h kbuffer.h trace-seq.h
So the include path should be "/usr/include" or we should include <event-parse.h> directly. We may update the every include statements but just curious how it solved your problem.
Thanks,
Namhyung
Quoted 6 lines
tools/perf/Makefile.config +0
-0LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent) EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent) LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0Signature · 1 line
2.24.0
Quoted 43 lines · Namhyung Kim
Hello,
Quoted 29 lines · Yicong Yang
From: Yicong Yang <[email protected]>
When building with custom libtraceevent, below errors occur:
$ make -C tools/perf NO_LIBPYTHON=1 PKG_CONFIG_PATH=<custom libtraceevent> In file included from util/session.h:5, from builtin-buildid-list.c:17: util/trace-event.h:153:10: fatal error: traceevent/event-parse.h: No such file or directory 153 | #include <traceevent/event-parse.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ <snip similar errors of missing headers>This is because the include path is missed in the cflags. Add it.
Fixes 0f0e1f445690 ("perf build: Use pkg-config for feature check for libtrace{event,fs}")Signed-off-by Yicong Yang <[email protected]>---
Another problem occurs when building on my old Ubuntu 18.04.1 (4.15 kernel) is thatlinux/mount.h(which is introduced in the later kernel version) is missing. It's included intools/include/uapi/linux/fs.hwhich header is introduced recently. Does it make sense to have a copy ofmount.hintools/include?tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/Makefile.config +0
-0tools/perf/Makefile.config endif · line 1197
Quoted 5 lines
tools/perf/Makefile.config +1
-1@@ -1194,7 +1194,7 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT + CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent)Does this solve the problem? On my machine, it returns this:
$ pkg-config --cflags libtraceevent -I/usr/include/traceevent
Quoted 7 lines
$ ls /usr/include/traceevent/ event-parse.h event-utils.h kbuffer.h trace-seq.hSo the include path should be "
/usr/include" or we should include <event-parse.h> directly. We may update the every include statements but just curious how it solved your problem.
I think you're right, we should use the path according to the pkg-config outputs. But it's a different problem, for me it's due to the missing of the include path (my libtraceevent is not under the system path). With the fix you proposed and drop the change in my patch:
$ PKG_CONFIG_PATH=/home/yangyicong/Community/libtraceevent/install/usr/local/lib/aarch64-linux-gnu/pkgconfig/ pkg-config --cflags-only-I libtraceevent
-I/home/yangyicong/Community/libtraceevent/install/usr/local/include/traceevent
$ PKG_CONFIG_PATH=/home/yangyicong/Community/libtraceevent/install/usr/local/lib/aarch64-linux-gnu/pkgconfig/ make -C tools/perf NO_LIBPYTHON=1
In file included from bench/../util/session.h:5,
from bench/synthesize.c:12:
bench/../util/trace-event.h:153:10: fatal error: event-parse.h: No such file or directory
153 | #include <event-parse.h>
|
[...]Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)
CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)Thanks.
Quoted 12 lines
Thanks,
NamhyungQuoted 6 lines
tools/perf/Makefile.config +0
-0LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtraceevent) EXTLIBS += $(shell $(PKG_CONFIG) --libs-only-l libtraceevent) LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent).0.0Signature · 1 line
2.24.0.
On Wed, Oct 30, 2024 at 10:45:47AM +0800, Yicong Yang wrote:
[...]
Quoted 39 lines
Quoted 16 lines
tools/perf/Makefile.config endif · line 1197
Quoted 10 lines
tools/perf/Makefile.config +1
-1@@ -1194,7 +1194,7 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT + CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent)Does this solve the problem? On my machine, it returns this:
$ pkg-config --cflags libtraceevent -I/usr/include/traceeventQuoted 7 lines
$ ls /usr/include/traceevent/ event-parse.h event-utils.h kbuffer.h trace-seq.hSo the include path should be "
/usr/include" or we should include <event-parse.h> directly. We may update the every include statements but just curious how it solved your problem.I think you're right, we should use the path according to the pkg-config outputs. But it's a different problem, for me it's due to the missing of the include path (my libtraceevent is not under the system path). With the fix you proposed and drop the change in my patch:
$ PKG_CONFIG_PATH=/home/yangyicong/Community/libtraceevent/install/usr/local/lib/aarch64-linux-gnu/pkgconfig/ pkg-config --cflags-only-I libtraceevent -I/home/yangyicong/Community/libtraceevent/install/usr/local/include/traceevent $ PKG_CONFIG_PATH=/home/yangyicong/Community/libtraceevent/install/usr/local/lib/aarch64-linux-gnu/pkgconfig/ make -C tools/perf NO_LIBPYTHON=1 In file included from bench/../util/session.h:5, from bench/synthesize.c:12: bench/../util/trace-event.h:153:10: fatal error: event-parse.h: No such file or directory 153 | #include <event-parse.h> | [...]
Quoted 4 lines
Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)
The libtracefs.pc file claims requesting libtraceevent, as a result, it returns the header paths for both libtraceevent and libtracefs:
$ pkg-config --cflags libtracefs -I/usr/local/include/tracefs -I/usr/local/include/traceevent
I checked the packages libtraceevent-dev and libtracefs-dev and either can be installed independently. Therefore, it seems to me that this patch is correct for finding the traceevent header path, with no dependency on tracefs.
Thanks,
Leo
Namhyung Kim
maintainerQuoted 51 lines · Leo Yan
On Wed, Oct 30, 2024 at 10:45:47AM +0800, Yicong Yang wrote:
[...]
Quoted 39 lines
Quoted 16 lines
tools/perf/Makefile.config endif · line 1197
Quoted 10 lines
tools/perf/Makefile.config +1
-1@@ -1194,7 +1194,7 @@ endif ifneq ($(NO_LIBTRACEEVENT),1) $(call feature_check,libtraceevent) ifeq ($(feature-libtraceevent), 1) - CFLAGS += -DHAVE_LIBTRACEEVENT + CFLAGS += -DHAVE_LIBTRACEEVENT $(shell $(PKG_CONFIG) --cflags libtraceevent)Does this solve the problem? On my machine, it returns this:
$ pkg-config --cflags libtraceevent -I/usr/include/traceeventQuoted 7 lines
$ ls /usr/include/traceevent/ event-parse.h event-utils.h kbuffer.h trace-seq.hSo the include path should be "
/usr/include" or we should include <event-parse.h> directly. We may update the every include statements but just curious how it solved your problem.I think you're right, we should use the path according to the pkg-config outputs. But it's a different problem, for me it's due to the missing of the include path (my libtraceevent is not under the system path). With the fix you proposed and drop the change in my patch:
$ PKG_CONFIG_PATH=/home/yangyicong/Community/libtraceevent/install/usr/local/lib/aarch64-linux-gnu/pkgconfig/ pkg-config --cflags-only-I libtraceevent -I/home/yangyicong/Community/libtraceevent/install/usr/local/include/traceevent $ PKG_CONFIG_PATH=/home/yangyicong/Community/libtraceevent/install/usr/local/lib/aarch64-linux-gnu/pkgconfig/ make -C tools/perf NO_LIBPYTHON=1 In file included from bench/../util/session.h:5, from bench/synthesize.c:12: bench/../util/trace-event.h:153:10: fatal error: event-parse.h: No such file or directory 153 | #include <event-parse.h> | [...]Quoted 4 lines
Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)The libtracefs.pc file claims requesting libtraceevent, as a result, it returns the header paths for both libtraceevent and libtracefs:
Quoted 7 lines
$ pkg-config --cflags libtracefs -I/usr/local/include/tracefs -I/usr/local/include/traceeventI checked the packages libtraceevent-dev and libtracefs-dev and either can be installed independently. Therefore, it seems to me that this patch is correct for finding the traceevent header path, with no dependency on tracefs.
I'm ok with the patch itself. Can I get your Acked-by, Leo?
Thanks,
Namhyung
Leo Yan
Reviewed-byOn Fri, Nov 01, 2024 at 11:23:27PM -0700, Namhyung Kim wrote:
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)The libtracefs.pc file claims requesting libtraceevent, as a result, it returns the header paths for both libtraceevent and libtracefs:
$ pkg-config --cflags libtracefs -I/usr/local/include/tracefs -I/usr/local/include/traceevent
Quoted 6 lines
Quoted 4 lines
I checked the packages libtraceevent-dev and libtracefs-dev and either can be installed independently. Therefore, it seems to me that this patch is correct for finding the traceevent header path, with no dependency on tracefs.
I'm ok with the patch itself. Can I get your Acked-by, Leo?
Yes.
Guilherme Amadio
Reviewed-byHi Namhyung,
Quoted 20 lines · Leo Yan
On Fri, Nov 01, 2024 at 11:23:27PM -0700, Namhyung Kim wrote:
[...]
Quoted 16 lines
Quoted 15 lines
Quoted 4 lines
Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)The libtracefs.pc file claims requesting libtraceevent, as a result, it returns the header paths for both libtraceevent and libtracefs:
$ pkg-config --cflags libtracefs -I/usr/local/include/tracefs -I/usr/local/include/traceeventI checked the packages libtraceevent-dev and libtracefs-dev and either can be installed independently. Therefore, it seems to me that this patch is correct for finding the traceevent header path, with no dependency on tracefs.
Quoted 5 lines
Quoted 1 line
I'm ok with the patch itself. Can I get your Acked-by, Leo?
Yes.
Reviewed-by Leo Yan <[email protected]>
I agree that this was a mistake I made in my patch. I added the cflags to the feature check in tools/build/Makefile.feature, but in Makefile.config I added it only for libtracefs and missed it for libtraceevent. The fixes tag is correct. This patch fixes my mistake.
Best regards,
-Guilherme
Quoted 27 lines · Guilherme Amadio
Hi Namhyung,
Quoted 24 lines · Leo Yan
On Fri, Nov 01, 2024 at 11:23:27PM -0700, Namhyung Kim wrote:
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)The libtracefs.pc file claims requesting libtraceevent, as a result, it returns the header paths for both libtraceevent and libtracefs:
$ pkg-config --cflags libtracefs -I/usr/local/include/tracefs -I/usr/local/include/traceeventQuoted 6 lines
Quoted 4 lines
I checked the packages libtraceevent-dev and libtracefs-dev and either can be installed independently. Therefore, it seems to me that this patch is correct for finding the traceevent header path, with no dependency on tracefs.
I'm ok with the patch itself. Can I get your Acked-by, Leo?
Yes.
Quoted 9 lines
Quoted 1 line
Reviewed-by Leo Yan <[email protected]>I agree that this was a mistake I made in my patch. I added the cflags to the feature check in
tools/build/Makefile.feature, but in Makefile.config I added it only for libtracefs and missed it for libtraceevent. The fixes tag is correct. This patch fixes my mistake.Reviewed-by Guilherme Amadio <[email protected]>
Thanks for the review by Leo and Guilherme!
Hi Namhyung,
As you noticed we should use the include path from pkg-config [1]. Would you like to post a patch yourself or want me to post this as well? It's correct and we also need this. (I didn't found this may because I changed my custom libtraceevent.pc when debugging and currently approach is ok if libtraceevent's installed system wide).
[1] https://lore.kernel.org/linux-perf-users/[email protected]/
Thanks.
Namhyung Kim
maintainerQuoted 38 lines · Yicong Yang
Quoted 27 lines · Guilherme Amadio
Hi Namhyung,
Quoted 24 lines · Leo Yan
On Fri, Nov 01, 2024 at 11:23:27PM -0700, Namhyung Kim wrote:
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Checked how we handle with libtracefs currently:
ifeq ($(feature-libtracefs), 1)CFLAGS += $(shell $(PKG_CONFIG) --cflags libtracefs) # we've added the cflags from pkg-config LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libtracefs)The libtracefs.pc file claims requesting libtraceevent, as a result, it returns the header paths for both libtraceevent and libtracefs:
$ pkg-config --cflags libtracefs -I/usr/local/include/tracefs -I/usr/local/include/traceeventQuoted 6 lines
Quoted 4 lines
I checked the packages libtraceevent-dev and libtracefs-dev and either can be installed independently. Therefore, it seems to me that this patch is correct for finding the traceevent header path, with no dependency on tracefs.
I'm ok with the patch itself. Can I get your Acked-by, Leo?
Yes.
Quoted 9 lines
Quoted 1 line
Reviewed-by Leo Yan <[email protected]>I agree that this was a mistake I made in my patch. I added the cflags to the feature check in
tools/build/Makefile.feature, but in Makefile.config I added it only for libtracefs and missed it for libtraceevent. The fixes tag is correct. This patch fixes my mistake.Reviewed-by Guilherme Amadio <[email protected]>
Quoted 8 lines
Thanks for the review by Leo and Guilherme!
Hi Namhyung,
As you noticed we should use the include path from pkg-config [1]. Would you like to post a patch yourself or want me to post this as well? It's correct and we also need this. (I didn't found this may because I changed my custom libtraceevent.pc when debugging and currently approach is ok if libtraceevent's installed system wide).
Please do that as a follow-up.
Thanks,
Namhyung
Quoted 10 lines · Yicong Yang
When building with custom libtraceevent, below errors occur:
$ make -C tools/perf NO_LIBPYTHON=1 PKG_CONFIG_PATH=<custom libtraceevent> In file included from util/session.h:5, from builtin-buildid-list.c:17: util/trace-event.h:153:10: fatal error: traceevent/event-parse.h: No such file or directory 153 | #include <traceevent/event-parse.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ <snip similar errors of missing headers>[...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung