Skip to contentSkip to conversation

perf build: Add missing cflags when building with custom libtraceevent

PATCH Applied Yicong Yang 4 participants 10 messages Oct 24, 2024 – Nov 5, 2024 perf events

lore
Share & tools
lore
#0 lore raw

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.

Fixes 0f0e1f445690 ("perf build: Use pkg-config for feature check for libtrace{event,fs}")

---
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
index 4ddb27a48eed..53fc5f787a77 100644
@@ -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
maintainer
#1 lore raw

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}")

---
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 +0 -0
index 4ddb27a48eed..53fc5f787a77 100644

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 -0
     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
#2 lore raw
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}")

---
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 +0 -0
index 4ddb27a48eed..53fc5f787a77 100644

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 
Quoted 7 lines
  $ 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.

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

Quoted 6 lines
tools/perf/Makefile.config +0 -0
     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

.

#3 lore raw

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
index 4ddb27a48eed..53fc5f787a77 100644
@@ -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.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.

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

maintainer
#4 lore raw
Quoted 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
index 4ddb27a48eed..53fc5f787a77 100644
@@ -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.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.

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

I'm ok with the patch itself. Can I get your Acked-by, Leo?

Thanks,
Namhyung

Reviewed-by
#5 lore raw

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

Reviewed-by
#6 lore raw

Hi 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/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.

Quoted 5 lines
Quoted 1 line

I'm ok with the patch itself. Can I get your Acked-by, Leo?

Yes.

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

#7 lore raw
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/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.

Quoted 9 lines
Quoted 1 line

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.

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.

maintainer
#8 lore raw
Quoted 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/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.

Quoted 9 lines
Quoted 1 line

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.

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

maintainer Applied
#9 lore raw
In reply to Yicong Yang
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