[v2] perf/build: fix broken dependency check for libtracefs

Message ID 20230711135338.397473-1-tmricht@linux.ibm.com
State New
Headers
Series [v2] perf/build: fix broken dependency check for libtracefs |

Commit Message

Thomas Richter July 11, 2023, 1:53 p.m. UTC
  Perf build auto-detects features and packages already installed
for its build. This is done in directory tools/build/feature. This
directory contains small sample programs. When they successfully
compile the necessary prereqs in form of libraries and header
files are present.

Such a check is also done for libtracefs. And this check fails:

Output before:
 # rm -f test-libtracefs.bin; make test-libtracefs.bin
 gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
	 > test-libtracefs.make.output 2>&1 -ltracefs
 make: *** [Makefile:211: test-libtracefs.bin] Error 1
 # cat test-libtracefs.make.output
 In file included from test-libtracefs.c:2:
 /usr/include/tracefs/tracefs.h:11:10: fatal error: \
	 event-parse.h: No such file or directory
   11 | #include <event-parse.h>
      |          ^~~~~~~~~~~~~~~
 compilation terminated.
 #

The root cause of this compile error is
commit 880885d9c22e ("libtracefs: Remove "traceevent/" from referencing libtraceevent headers")
in the libtracefs project hosted here:
 https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/

That mentioned patch removes the traceevent/ directory name from
the include statement, causing the file not to be included even
when the libtraceevent-devel package is installed. This package contains
the file referred to in tracefs/tracefs.h:
 # rpm -ql libtraceevent-devel
 /usr/include/traceevent
 /usr/include/traceevent/event-parse.h  <----- here
 /usr/include/traceevent/event-utils.h
 /usr/include/traceevent/kbuffer.h
 /usr/include/traceevent/trace-seq.h
 /usr/lib64/libtraceevent.so
 /usr/lib64/pkgconfig/libtraceevent.pc
 #

With this patch the compile succeeds.

Output after:
 # rm -f test-libtracefs.bin; make test-libtracefs.bin
 gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
	 > test-libtracefs.make.output 2>&1 -I/usr/include/traceevent -ltracefs
 #

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: jolsa@kernel.org
Cc: rostedt@goodmis.org
---
 tools/build/feature/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Arnaldo Carvalho de Melo July 11, 2023, 4:15 p.m. UTC | #1
Em Tue, Jul 11, 2023 at 03:53:38PM +0200, Thomas Richter escreveu:
> Perf build auto-detects features and packages already installed
> for its build. This is done in directory tools/build/feature. This
> directory contains small sample programs. When they successfully
> compile the necessary prereqs in form of libraries and header
> files are present.
> 
> Such a check is also done for libtracefs. And this check fails:
> 
> Output before:
>  # rm -f test-libtracefs.bin; make test-libtracefs.bin
>  gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
> 	 > test-libtracefs.make.output 2>&1 -ltracefs
>  make: *** [Makefile:211: test-libtracefs.bin] Error 1
>  # cat test-libtracefs.make.output
>  In file included from test-libtracefs.c:2:
>  /usr/include/tracefs/tracefs.h:11:10: fatal error: \
> 	 event-parse.h: No such file or directory
>    11 | #include <event-parse.h>
>       |          ^~~~~~~~~~~~~~~
>  compilation terminated.
>  #
> 
> The root cause of this compile error is
> commit 880885d9c22e ("libtracefs: Remove "traceevent/" from referencing libtraceevent headers")
> in the libtracefs project hosted here:
>  https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
> 
> That mentioned patch removes the traceevent/ directory name from
> the include statement, causing the file not to be included even
> when the libtraceevent-devel package is installed. This package contains
> the file referred to in tracefs/tracefs.h:
>  # rpm -ql libtraceevent-devel
>  /usr/include/traceevent
>  /usr/include/traceevent/event-parse.h  <----- here
>  /usr/include/traceevent/event-utils.h
>  /usr/include/traceevent/kbuffer.h
>  /usr/include/traceevent/trace-seq.h
>  /usr/lib64/libtraceevent.so
>  /usr/lib64/pkgconfig/libtraceevent.pc
>  #
> 
> With this patch the compile succeeds.
> 
> Output after:
>  # rm -f test-libtracefs.bin; make test-libtracefs.bin
>  gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
> 	 > test-libtracefs.make.output 2>&1 -I/usr/include/traceevent -ltracefs
>  #

Thanks! I test it like this:

Committer testing:

  $ make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools -C tools/perf install-bin

Before:

  $ cat /tmp/build/perf-tools/feature/test-libtracefs.make.output
  In file included from test-libtracefs.c:2:
  /usr/include/tracefs/tracefs.h:11:10: fatal error: event-parse.h: No such file or directory
     11 | #include <event-parse.h>
        |          ^~~~~~~~~~~~~~~
  compilation terminated.
  $
  $ grep -i tracefs /tmp/build/perf-tools/FEATURE-DUMP
  feature-libtracefs=0
  $

After:

  $ cat /tmp/build/perf-tools/feature/test-libtracefs.make.output
  $
  $ grep -i tracefs /tmp/build/perf-tools/FEATURE-DUMP
  feature-libtracefs=1
  $

Applied to perf-tools, for v6.5.

- Arnaldo
  
Arnaldo Carvalho de Melo July 11, 2023, 4:18 p.m. UTC | #2
Em Tue, Jul 11, 2023 at 01:15:29PM -0300, Arnaldo Carvalho de Melo escreveu:
 
> Applied to perf-tools, for v6.5.

I also changed the subject line to add that this was caused by a change
in the external library, it is reading like this in my local repo:

  perf build: Fix broken feature check for libtracefs due to external lib changes

- Arnaldo
  

Patch

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 0f0aa9b7d7b5..2cd6dbbee088 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -208,7 +208,7 @@  $(OUTPUT)test-libtraceevent.bin:
 	$(BUILD) -ltraceevent
 
 $(OUTPUT)test-libtracefs.bin:
-	$(BUILD) -ltracefs
+	 $(BUILD) $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null) -ltracefs
 
 $(OUTPUT)test-libcrypto.bin:
 	$(BUILD) -lcrypto