tools/tracing: Use tools/build makefiles like perf
v3 cover tools/tracing: Use tools/build makefiles like perf
tools/tracing and tools/verification/rv are using standalone Makefiles and this approach has some drawbacks. For example, code duplication and lack of proper dependency handling, making things harder for users.
Linus suggested using perf's build system, and it is indeed the best way to go.
This series replaces tools/tracing and tools/verification/rv makefiles with makefiles inspired by perf and objtool that use tools/build/ infrastructure.
Thanks, Arnaldo, for the pointers via chat.
Changes from V2:
- Link: https://lore.kernel.org/lkml/[email protected]/
- Fix the log of the first patch, removing the '----- %< ----' because some scripts interpret them as the '---' patch separator, truncating the log.
Changes from V1:
- Link: https://lore.kernel.org/lkml/[email protected]/
- Proper handle O= and OUTPUT= flags fixing "make tools/tracing"
- Cleanups
Daniel Bristot de Oliveira (3):
tools/tracing: Use tools/build makefiles on latency-collector tools/rtla: Use tools/build makefiles to build rtla tools/verification: Use tools/build makefiles on rv
tools/tracing/latency/.gitignore | 5 +- tools/tracing/latency/Build | 1 + tools/tracing/latency/Makefile | 105 ++++++++++-- tools/tracing/latency/Makefile.config | 30 ++++ tools/tracing/rtla/.gitignore | 7 +- tools/tracing/rtla/Build | 1 + tools/tracing/rtla/Makefile | 217 +++++++++---------------- tools/tracing/rtla/Makefile.config | 47 ++++++ tools/tracing/rtla/Makefile.rtla | 80 +++++++++ tools/tracing/rtla/Makefile.standalone | 26 +++ tools/tracing/rtla/src/Build | 11 ++ tools/verification/rv/.gitignore | 6 + tools/verification/rv/Build | 1 + tools/verification/rv/Makefile | 207 +++++++++-------------- tools/verification/rv/Makefile.config | 47 ++++++ tools/verification/rv/Makefile.rv | 51 ++++++ tools/verification/rv/src/Build | 4 + 17 files changed, 549 insertions(+), 297 deletions(-) create mode 100644 tools/tracing/latency/Build create mode 100644 tools/tracing/latency/Makefile.config create mode 100644 tools/tracing/rtla/Build create mode 100644 tools/tracing/rtla/Makefile.config create mode 100644 tools/tracing/rtla/Makefile.rtla create mode 100644 tools/tracing/rtla/Makefile.standalone create mode 100644 tools/tracing/rtla/src/Build create mode 100644 tools/verification/rv/.gitignore create mode 100644 tools/verification/rv/Build create mode 100644 tools/verification/rv/Makefile.config create mode 100644 tools/verification/rv/Makefile.rv create mode 100644 tools/verification/rv/src/Build
Signature · 1 line
2.44.0
PATCH v3 1/3 tools/tracing: Use tools/build makefiles on latency-collector
Use tools/build/ makefiles to build latency-collector, inheriting the benefits of it. For example: Before this patch, a missing tracefs/traceevents headers will result in fail like this:
~/linux/tools/tracing/latency $ make
cc -Wall -Wextra -g -O2 -o latency-collector latency-collector.c -lpthread latency-collector.c:26:10: fatal error: tracefs.h: No such file or directory
26 | #include <tracefs.h>
| ^~~~~~~~~~~ compilation terminated.
make: *** [Makefile:14: latency-collector] Error 1
Which is not that helpful. After this change it reports:
~/linux/tools/tracing/latency# make
Auto-detecting system features:
... libtraceevent: [ OFF ]
... libtracefs: [ OFF ]
libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel libtracefs is missing. Please install libtracefs-dev/libtracefs-devel Makefile.config:29: *** Please, check the errors above.. Stop.
This type of output is common across other tools in tools/ like perf and objtool.
--- tools/tracing/latency/.gitignore | 5 +- tools/tracing/latency/Build | 1 + tools/tracing/latency/Makefile | 105 +++++++++++++++++++++----- tools/tracing/latency/Makefile.config | 30 ++++++++ 4 files changed, 122 insertions(+), 19 deletions(-) create mode 100644 tools/tracing/latency/Build create mode 100644 tools/tracing/latency/Makefile.config
tools/tracing/latency/.gitignore +4 -1
@@ -1,2 +1,5 @@ -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: GPL-2.0-only latency-collector +fixdep +feature +FEATURE-DUMP
tools/tracing/latency/Build new file +1 -0
@@ -0,0 +1 @@ +latency-collector-y += latency-collector.o
tools/tracing/latency/Makefile +87 -18
111 lines not on this page · raw message
tools/tracing/latency/Makefile.config new file +30 -0
@@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0-only + +STOP_ERROR := + +define lib_setup + $(eval EXTLIBS += -l$(1)) + $(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)")) +endef + +$(call feature_check,libtraceevent) +ifeq ($(feature-libtraceevent), 1) + $(call detected,CONFIG_LIBTRACEEVENT) + $(call lib_setup,traceevent) +else + STOP_ERROR := 1 + $(info libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel) +endif + +$(call feature_check,libtracefs) +ifeq ($(feature-libtracefs), 1) + $(call detected,CONFIG_LIBTRACEFS) + $(call lib_setup,tracefs) +else + STOP_ERROR := 1 + $(info libtracefs is missing. Please install libtracefs-dev/libtracefs-devel) +endif + +ifeq ($(STOP_ERROR),1) + $(error Please, check the errors above.) +endif
Signature · 1 line
2.44.0
PATCH v3 2/3 tools/rtla: Use tools/build makefiles to build rtla
In reply to Daniel Bristot de OliveiraUse tools/build/ makefiles to build rtla, inheriting the benefits of it. For example, having a proper way to handle dependencies.
rtla is built using perf infra-structure when building inside the kernel tree.
At this point, rtla diverges from perf in two points: Documentation and tarball generation/build.
At the documentation level, rtla is one step ahead, placing the documentation at Documentation/tools/rtla/, using the same build tools as kernel documentation. The idea is to move perf documentation to the same scheme and then share the same makefiles.
rtla has a tarball target that the (old) RHEL8 uses. The tarball was kept using a simple standalone makefile for compatibility. The standalone makefile shares most of the code, e.g., flags, with regular buildings.
The tarball method was set as deprecated. If necessary, we can make a rtla tarball like perf, which includes the entire tools/build. But this would also require changes in the user side (the directory structure changes, and probably the deps to build the package).
Inspired on perf and objtool.
--- tools/tracing/rtla/.gitignore | 7 +- tools/tracing/rtla/Build | 1 + tools/tracing/rtla/Makefile | 217 +++++++++---------------- tools/tracing/rtla/Makefile.config | 47 ++++++ tools/tracing/rtla/Makefile.rtla | 80 +++++++++ tools/tracing/rtla/Makefile.standalone | 26 +++ tools/tracing/rtla/src/Build | 11 ++ 7 files changed, 244 insertions(+), 145 deletions(-) create mode 100644 tools/tracing/rtla/Build create mode 100644 tools/tracing/rtla/Makefile.config create mode 100644 tools/tracing/rtla/Makefile.rtla create mode 100644 tools/tracing/rtla/Makefile.standalone create mode 100644 tools/tracing/rtla/src/Build
tools/tracing/rtla/.gitignore +6 -1
@@ -1 +1,6 @@ -/rtla +# SPDX-License-Identifier: GPL-2.0-only +rtla +rtla-static +fixdep +feature +FEATURE-DUMP
tools/tracing/rtla/Build new file +1 -0
@@ -0,0 +1 @@ +rtla-y += src/
tools/tracing/rtla/Makefile +73 -144
230 lines not on this page · raw message
tools/tracing/rtla/Makefile.config new file +47 -0
47 lines not on this page · raw message
tools/tracing/rtla/Makefile.rtla new file +80 -0
80 lines not on this page · raw message
tools/tracing/rtla/Makefile.standalone new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only + +VERSION := $(shell cat VERSION) +CFLAGS += $$($(PKG_CONFIG) --cflags libtracefs) +EXTLIBS += $$($(PKG_CONFIG) --libs libtracefs) + +rtla: + +include Makefile.rtla + +SRC := $(wildcard src/*.c) +HDR := $(wildcard src/*.h) +OBJ := $(SRC:.c=.o) +DOCSRC := Documentation/ + +rtla: $(OBJ) + $(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS) $(EXTLIBS) + $(info This is a deprecated method to compile RTLA, please compile from Linux kernel source) + +.PHONY: clean tarball +clean: doc_clean + @test ! -f rtla || rm rtla + @test ! -f rtla-static || rm rtla-static + @test ! -f src/rtla.o || rm src/rtla.o + @test ! -f $(TARBALL) || rm -f $(TARBALL) + @rm -rf *~ $(OBJ) *.tar.$(CEXT)
tools/tracing/rtla/src/Build new file +11 -0
@@ -0,0 +1,11 @@ +rtla-y += trace.o +rtla-y += utils.o +rtla-y += osnoise.o +rtla-y += osnoise_top.o +rtla-y += osnoise_hist.o +rtla-y += timerlat.o +rtla-y += timerlat_top.o +rtla-y += timerlat_hist.o +rtla-y += timerlat_u.o +rtla-y += timerlat_aa.o +rtla-y += rtla.o
Signature · 1 line
2.44.0
PATCH v3 3/3 tools/verification: Use tools/build makefiles on rv
In reply to Daniel Bristot de OliveiraUse tools/build/ makefiles to build rv, inheriting the benefits of it. For example, having a proper way to handle dependencies.
--- tools/verification/rv/.gitignore | 6 + tools/verification/rv/Build | 1 + tools/verification/rv/Makefile | 207 +++++++++----------------- tools/verification/rv/Makefile.config | 47 ++++++ tools/verification/rv/Makefile.rv | 51 +++++++ tools/verification/rv/src/Build | 4 + 6 files changed, 183 insertions(+), 133 deletions(-) create mode 100644 tools/verification/rv/.gitignore create mode 100644 tools/verification/rv/Build create mode 100644 tools/verification/rv/Makefile.config create mode 100644 tools/verification/rv/Makefile.rv create mode 100644 tools/verification/rv/src/Build
tools/verification/rv/.gitignore new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +rv +rv-static +fixdep +feature +FEATURE-DUMP
tools/verification/rv/Build new file +1 -0
@@ -0,0 +1 @@ +rv-y += src/
tools/verification/rv/Makefile +74 -133
220 lines not on this page · raw message
tools/verification/rv/Makefile.config new file +47 -0
47 lines not on this page · raw message
tools/verification/rv/Makefile.rv new file +51 -0
51 lines not on this page · raw message
tools/verification/rv/src/Build new file +4 -0
@@ -0,0 +1,4 @@ +rv-y += trace.o +rv-y += utils.o +rv-y += in_kernel.o +rv-y += rv.o
Signature · 1 line
2.44.0