[2/6] rtla: Revert Makefile changes for rtla

Message ID 20240819074202.34144-3-patrick.barsanti@amarulasolutions.com
State New
Headers show
Series
  • Add support for rtla tool
Related show

Commit Message

Patrick Barsanti Aug. 19, 2024, 7:41 a.m. UTC
With this specific linux upstream commit, the building process for rtla
is broken inside Yocto:

| Auto-detecting system features:
| ...                           libtraceevent: [ on  ]
| ...                              libtracefs: [ OFF ]
|
| libtracefs is missing. Please install libtracefs-dev/libtracefs-devel

Since it is working correctly with linux-yocto_6.6%, and after
confirming this commit is in fact the only cause of incorrect behaviour,
add a patch to revert it.

Signed-off-by: Patrick Barsanti <patrick.barsanti@amarulasolutions.com>
---
 ...a-Use-tools-build-makefiles-to-build.patch | 414 ++++++++++++++++++
 meta/recipes-kernel/linux/linux-yocto_6.10.bb |   3 +-
 2 files changed, 416 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-kernel/linux/files/0001-Revert-tools-rtla-Use-tools-build-makefiles-to-build.patch

Patch

diff --git a/meta/recipes-kernel/linux/files/0001-Revert-tools-rtla-Use-tools-build-makefiles-to-build.patch b/meta/recipes-kernel/linux/files/0001-Revert-tools-rtla-Use-tools-build-makefiles-to-build.patch
new file mode 100644
index 0000000000..0578730e7f
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/0001-Revert-tools-rtla-Use-tools-build-makefiles-to-build.patch
@@ -0,0 +1,414 @@ 
+From a3d719bdd9fb6b787d7098004e2bf588a2dd67c6 Mon Sep 17 00:00:00 2001
+From: Patrick Barsanti <patrick.barsanti@amarulasolutions.com>
+Date: Fri, 16 Aug 2024 18:05:58 +0200
+Subject: [PATCH] Revert "tools/rtla: Use tools/build makefiles to build rtla"
+
+This reverts commit 01474dc706cabbdaab600a46a107220ac5de9386.
+
+Upstream-Status: Pending
+Signed-Off-By: Patrick Barsanti <patrick.barsanti@amarulasolutions.com>
+---
+ tools/tracing/rtla/.gitignore          |   7 +-
+ tools/tracing/rtla/Build               |   1 -
+ tools/tracing/rtla/Makefile            | 217 ++++++++++++++++---------
+ tools/tracing/rtla/Makefile.rtla       |  80 ---------
+ tools/tracing/rtla/Makefile.standalone |  26 ---
+ tools/tracing/rtla/src/Build           |  11 --
+ 6 files changed, 145 insertions(+), 197 deletions(-)
+ delete mode 100644 tools/tracing/rtla/Build
+ delete mode 100644 tools/tracing/rtla/Makefile.rtla
+ delete mode 100644 tools/tracing/rtla/Makefile.standalone
+ delete mode 100644 tools/tracing/rtla/src/Build
+
+diff --git a/tools/tracing/rtla/.gitignore b/tools/tracing/rtla/.gitignore
+index 293f0dbb0ca2..e9df32419b2b 100644
+--- a/tools/tracing/rtla/.gitignore
++++ b/tools/tracing/rtla/.gitignore
+@@ -1,6 +1 @@
+-# SPDX-License-Identifier: GPL-2.0-only
+-rtla
+-rtla-static
+-fixdep
+-feature
+-FEATURE-DUMP
++/rtla
+diff --git a/tools/tracing/rtla/Build b/tools/tracing/rtla/Build
+deleted file mode 100644
+index 6c9d5b36a315..000000000000
+--- a/tools/tracing/rtla/Build
++++ /dev/null
+@@ -1 +0,0 @@
+-rtla-y += src/
+diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
+index b5878be36125..afd18c678ff5 100644
+--- a/tools/tracing/rtla/Makefile
++++ b/tools/tracing/rtla/Makefile
+@@ -1,86 +1,157 @@
+-# SPDX-License-Identifier: GPL-2.0-only
+-
+-ifeq ($(srctree),)
+-  srctree	:= $(patsubst %/,%,$(dir $(CURDIR)))
+-  srctree	:= $(patsubst %/,%,$(dir $(srctree)))
+-  srctree	:= $(patsubst %/,%,$(dir $(srctree)))
++NAME	:=	rtla
++# Follow the kernel version
++VERSION :=	$(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion | grep -v make)
++
++# From libtracefs:
++# Makefiles suck: This macro sets a default value of $(2) for the
++# variable named by $(1), unless the variable has been set by
++# environment or command line. This is necessary for CC and AR
++# because make sets default values, so the simpler ?= approach
++# won't work as expected.
++define allow-override
++  $(if $(or $(findstring environment,$(origin $(1))),\
++            $(findstring command line,$(origin $(1)))),,\
++    $(eval $(1) = $(2)))
++endef
++
++# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
++$(call allow-override,CC,$(CROSS_COMPILE)gcc)
++$(call allow-override,AR,$(CROSS_COMPILE)ar)
++$(call allow-override,STRIP,$(CROSS_COMPILE)strip)
++$(call allow-override,PKG_CONFIG,pkg-config)
++$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
++$(call allow-override,LDCONFIG,ldconfig)
++
++INSTALL	=	install
++MKDIR	=	mkdir
++FOPTS	:=	-flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
++		-fasynchronous-unwind-tables -fstack-clash-protection
++WOPTS	:= 	-Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
++
++ifeq ($(CC),clang)
++  FOPTS := $(filter-out -ffat-lto-objects, $(FOPTS))
++  WOPTS := $(filter-out -Wno-maybe-uninitialized, $(WOPTS))
+ endif
+ 
+-include $(srctree)/tools/scripts/Makefile.include
+-
+-# O is an alias for OUTPUT
+-OUTPUT          := $(O)
+-
+-ifeq ($(OUTPUT),)
+-  OUTPUT        := $(CURDIR)
++TRACEFS_HEADERS	:= $$($(PKG_CONFIG) --cflags libtracefs)
++
++CFLAGS	:=	-O -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(TRACEFS_HEADERS) $(EXTRA_CFLAGS)
++LDFLAGS	:=	-flto=auto -ggdb $(EXTRA_LDFLAGS)
++LIBS	:=	$$($(PKG_CONFIG) --libs libtracefs)
++
++SRC	:=	$(wildcard src/*.c)
++HDR	:=	$(wildcard src/*.h)
++OBJ	:=	$(SRC:.c=.o)
++DIRS	:=	src
++FILES	:=	Makefile README.txt
++CEXT	:=	bz2
++TARBALL	:=	$(NAME)-$(VERSION).tar.$(CEXT)
++TAROPTS	:=	-cvjf $(TARBALL)
++BINDIR	:=	/usr/bin
++DATADIR	:=	/usr/share
++DOCDIR	:=	$(DATADIR)/doc
++MANDIR	:=	$(DATADIR)/man
++LICDIR	:=	$(DATADIR)/licenses
++SRCTREE	:=	$(or $(BUILD_SRC),$(CURDIR))
++
++# If running from the tarball, man pages are stored in the Documentation
++# dir. If running from the kernel source, man pages are stored in
++# Documentation/tools/rtla/.
++ifneq ($(wildcard Documentation/.*),)
++DOCSRC	=	Documentation/
+ else
+-  # subdir is used by the ../Makefile in $(call descend,)
+-  ifneq ($(subdir),)
+-    OUTPUT        := $(OUTPUT)/$(subdir)
+-  endif
+-endif
+-
+-ifneq ($(patsubst %/,,$(lastword $(OUTPUT))),)
+-  OUTPUT        := $(OUTPUT)/
++DOCSRC	=	$(SRCTREE)/../../../Documentation/tools/rtla/
+ endif
+ 
+-RTLA		:= $(OUTPUT)rtla
+-RTLA_IN		:= $(RTLA)-in.o
++LIBTRACEEVENT_MIN_VERSION = 1.5
++LIBTRACEFS_MIN_VERSION = 1.3
+ 
+-VERSION		:= $(shell sh -c "make -sC ../../.. kernelversion | grep -v make")
+-DOCSRC		:= ../../../Documentation/tools/rtla/
++.PHONY:	all warnings show_warnings
++all:	warnings rtla
+ 
+-FEATURE_TESTS	:= libtraceevent
+-FEATURE_TESTS	+= libtracefs
+-FEATURE_DISPLAY	:= libtraceevent
+-FEATURE_DISPLAY	+= libtracefs
+-
+-ifeq ($(V),1)
+-  Q		=
+-else
+-  Q		= @
++TEST_LIBTRACEEVENT = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEEVENT_MIN_VERSION) libtraceevent > /dev/null 2>&1 || echo n")
++ifeq ("$(TEST_LIBTRACEEVENT)", "n")
++WARNINGS = show_warnings
++MISSING_LIBS += echo "**   libtraceevent version $(LIBTRACEEVENT_MIN_VERSION) or higher";
++MISSING_PACKAGES += "libtraceevent-devel"
++MISSING_SOURCE += echo "**  https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ ";
+ endif
+ 
+-all: $(RTLA)
+-
+-include $(srctree)/tools/build/Makefile.include
+-include Makefile.rtla
+-
+-# check for dependencies only on required targets
+-NON_CONFIG_TARGETS := clean install tarball doc doc_clean doc_install
+-
+-config		:= 1
+-ifdef MAKECMDGOALS
+-ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
+- config		:= 0
+-endif
++TEST_LIBTRACEFS = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEFS_MIN_VERSION) libtracefs > /dev/null 2>&1 || echo n")
++ifeq ("$(TEST_LIBTRACEFS)", "n")
++WARNINGS = show_warnings
++MISSING_LIBS += echo "**   libtracefs version $(LIBTRACEFS_MIN_VERSION) or higher";
++MISSING_PACKAGES += "libtracefs-devel"
++MISSING_SOURCE += echo "**  https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ ";
+ endif
+ 
+-ifeq ($(config),1)
+-  include $(srctree)/tools/build/Makefile.feature
+-  include Makefile.config
++define show_dependencies
++	@echo "********************************************";				\
++	echo "** NOTICE: Failed build dependencies";					\
++	echo "**";									\
++	echo "** Required Libraries:";							\
++	$(MISSING_LIBS)									\
++	echo "**";									\
++	echo "** Consider installing the latest libtracefs from your";			\
++	echo "** distribution, e.g., 'dnf install $(MISSING_PACKAGES)' on Fedora,";	\
++	echo "** or from source:";							\
++	echo "**";									\
++	$(MISSING_SOURCE)								\
++	echo "**";									\
++	echo "********************************************"
++endef
++
++show_warnings:
++	$(call show_dependencies);
++
++ifneq ("$(WARNINGS)", "")
++ERROR_OUT = $(error Please add the necessary dependencies)
++
++warnings: $(WARNINGS)
++	$(ERROR_OUT)
+ endif
+ 
+-CFLAGS		+= $(INCLUDES) $(LIB_INCLUDES)
+-
+-export CFLAGS OUTPUT srctree
+-
+-$(RTLA): $(RTLA_IN)
+-	$(QUIET_LINK)$(CC) $(LDFLAGS) -o $(RTLA) $(RTLA_IN) $(EXTLIBS)
+-
+-static: $(RTLA_IN)
+-	$(eval LDFLAGS += -static)
+-	$(QUIET_LINK)$(CC) -static $(LDFLAGS) -o $(RTLA)-static $(RTLA_IN)  $(EXTLIBS)
+-
+-rtla.%: fixdep FORCE
+-	make -f $(srctree)/tools/build/Makefile.build dir=. $@
+-
+-$(RTLA_IN): fixdep FORCE
+-	make $(build)=rtla
+-
+-clean: doc_clean fixdep-clean
+-	$(call QUIET_CLEAN, rtla)
+-	$(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
+-	$(Q)rm -f rtla rtla-static fixdep FEATURE-DUMP rtla-*
+-	$(Q)rm -rf feature
+-.PHONY: FORCE clean
++rtla: $(OBJ)
++	$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)
++
++static: $(OBJ)
++	$(CC) -o rtla-static $(LDFLAGS) --static $(OBJ) $(LIBS) -lpthread -ldl
++
++.PHONY: install
++install: doc_install
++	$(MKDIR) -p $(DESTDIR)$(BINDIR)
++	$(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR)
++	$(STRIP) $(DESTDIR)$(BINDIR)/rtla
++	@test ! -f $(DESTDIR)$(BINDIR)/osnoise || rm $(DESTDIR)$(BINDIR)/osnoise
++	ln -s rtla $(DESTDIR)$(BINDIR)/osnoise
++	@test ! -f $(DESTDIR)$(BINDIR)/hwnoise || rm $(DESTDIR)$(BINDIR)/hwnoise
++	ln -s rtla $(DESTDIR)$(BINDIR)/hwnoise
++	@test ! -f $(DESTDIR)$(BINDIR)/timerlat || rm $(DESTDIR)$(BINDIR)/timerlat
++	ln -s rtla $(DESTDIR)$(BINDIR)/timerlat
++
++.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)
++
++tarball: clean
++	rm -rf $(NAME)-$(VERSION) && mkdir $(NAME)-$(VERSION)
++	echo $(VERSION) > $(NAME)-$(VERSION)/VERSION
++	cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION)
++	mkdir $(NAME)-$(VERSION)/Documentation/
++	cp -rp $(SRCTREE)/../../../Documentation/tools/rtla/* $(NAME)-$(VERSION)/Documentation/
++	tar $(TAROPTS) --exclude='*~' $(NAME)-$(VERSION)
++	rm -rf $(NAME)-$(VERSION)
++
++.PHONY: doc doc_clean doc_install
++doc:
++	$(MAKE) -C $(DOCSRC)
++
++doc_clean:
++	$(MAKE) -C $(DOCSRC) clean
++
++doc_install:
++	$(MAKE) -C $(DOCSRC) install
+diff --git a/tools/tracing/rtla/Makefile.rtla b/tools/tracing/rtla/Makefile.rtla
+deleted file mode 100644
+index 3ff0b8970896..000000000000
+--- a/tools/tracing/rtla/Makefile.rtla
++++ /dev/null
+@@ -1,80 +0,0 @@
+-# SPDX-License-Identifier: GPL-2.0-only
+-
+-define allow-override
+-  $(if $(or $(findstring environment,$(origin $(1))),\
+-            $(findstring command line,$(origin $(1)))),,\
+-    $(eval $(1) = $(2)))
+-endef
+-
+-# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
+-$(call allow-override,CC,$(CROSS_COMPILE)gcc)
+-$(call allow-override,AR,$(CROSS_COMPILE)ar)
+-$(call allow-override,STRIP,$(CROSS_COMPILE)strip)
+-$(call allow-override,PKG_CONFIG,pkg-config)
+-$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
+-$(call allow-override,LDCONFIG,ldconfig)
+-export CC AR STRIP PKG_CONFIG LD_SO_CONF_PATH LDCONFIG
+-
+-FOPTS		:= -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong	\
+-		-fasynchronous-unwind-tables -fstack-clash-protection
+-WOPTS		:= -O -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2		\
+-		-Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
+-
+-ifeq ($(CC),clang)
+-  FOPTS		:= $(filter-out -flto=auto -ffat-lto-objects, $(FOPTS))
+-  WOPTS		:= $(filter-out -Wno-maybe-uninitialized, $(WOPTS))
+-endif
+-
+-CFLAGS		:= -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(WOPTS) $(CFLAGS)
+-LDFLAGS		:= -ggdb $(LDFLAGS)
+-
+-RM		:= rm -rf
+-LN		:= ln -s
+-INSTALL		:= install
+-MKDIR		:= mkdir
+-STRIP		:= strip
+-BINDIR		:= /usr/bin
+-
+-.PHONY: install
+-install: doc_install
+-	@$(MKDIR) -p $(DESTDIR)$(BINDIR)
+-	$(call QUIET_INSTALL,rtla)$(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR)
+-	@$(STRIP) $(DESTDIR)$(BINDIR)/rtla
+-	@test ! -f $(DESTDIR)$(BINDIR)/osnoise || $(RM) $(DESTDIR)$(BINDIR)/osnoise
+-	@$(LN) rtla $(DESTDIR)$(BINDIR)/osnoise
+-	@test ! -f $(DESTDIR)$(BINDIR)/hwnoise || $(RM) $(DESTDIR)$(BINDIR)/hwnoise
+-	@$(LN) -s rtla $(DESTDIR)$(BINDIR)/hwnoise
+-	@test ! -f $(DESTDIR)$(BINDIR)/timerlat || $(RM) $(DESTDIR)$(BINDIR)/timerlat
+-	@$(LN) -s rtla $(DESTDIR)$(BINDIR)/timerlat
+-
+-.PHONY: doc doc_clean doc_install
+-doc:
+-	$(MAKE) -C $(DOCSRC)
+-
+-doc_clean:
+-	$(MAKE) -C $(DOCSRC) clean
+-
+-doc_install:
+-	$(MAKE) -C $(DOCSRC) install
+-
+-# This section is neesary for the tarball, when the tarball
+-# support is removed, we can delete these entries.
+-NAME		:= rtla
+-DIRS		:= src
+-FILES		:= Makefile README.txt
+-CEXT		:= bz2
+-TARBALL		:= $(NAME)-$(VERSION).tar.$(CEXT)
+-TAROPTS		:= -cvjf $(TARBALL)
+-SRCTREE		:=	$(or $(BUILD_SRC),$(CURDIR))
+-
+-tarball: clean
+-	$(RM) $(NAME)-$(VERSION) && $(MKDIR) $(NAME)-$(VERSION)
+-	echo $(VERSION) > $(NAME)-$(VERSION)/VERSION
+-	cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION)
+-	$(MKDIR) $(NAME)-$(VERSION)/Documentation/
+-	cp -rp $(SRCTREE)/../../../Documentation/tools/$(NAME)/* $(NAME)-$(VERSION)/Documentation/
+-	cp Makefile.standalone $(NAME)-$(VERSION)/Makefile
+-	cp Makefile.$(NAME) $(NAME)-$(VERSION)/
+-	tar $(TAROPTS) --exclude='*~' $(NAME)-$(VERSION)
+-	$(RM) $(NAME)-$(VERSION)
+-.PHONY: tarball
+diff --git a/tools/tracing/rtla/Makefile.standalone b/tools/tracing/rtla/Makefile.standalone
+deleted file mode 100644
+index 86d07cb52fa5..000000000000
+--- a/tools/tracing/rtla/Makefile.standalone
++++ /dev/null
+@@ -1,26 +0,0 @@
+-# 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)
+diff --git a/tools/tracing/rtla/src/Build b/tools/tracing/rtla/src/Build
+deleted file mode 100644
+index dbed9e31829b..000000000000
+--- a/tools/tracing/rtla/src/Build
++++ /dev/null
+@@ -1,11 +0,0 @@
+-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
+-- 
+2.46.0
+
diff --git a/meta/recipes-kernel/linux/linux-yocto_6.10.bb b/meta/recipes-kernel/linux/linux-yocto_6.10.bb
index c0b1b0b6cc..c022d86c8c 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.10.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.10.bb
@@ -41,7 +41,8 @@  PN:class-devupstream = "linux-yocto-upstream"
 KBRANCH:class-devupstream = "v6.10/base"
 
 SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH};protocol=https \
-           git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.10;destsuffix=${KMETA};protocol=https"
+           git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-6.10;destsuffix=${KMETA};protocol=https \
+           file://${THISDIR}/files/0001-Revert-tools-rtla-Use-tools-build-makefiles-to-build.patch"
 
 LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
 LINUX_VERSION ?= "6.10.3"