Fix building against libcpupower

JIRA: https://issues.redhat.com/browse/RHEL-65487

In order to build cyclictest with --deepest-idle-state support,
a BuildRequires for kernel-tools-libs-devel, which contains
libcpupower, is needed, as well as kernel-headers for cpuidle.h.

Add the dependencies, and also pull upstream patches to fix feature
detection in RPM builds.

Signed-off-by: Tomas Glozar <tglozar@redhat.com>
This commit is contained in:
Tomas Glozar 2024-12-04 10:22:40 +01:00
parent a4afbc3033
commit 19d524fcdf
3 changed files with 88 additions and 3 deletions

View File

@ -0,0 +1,33 @@
From cb0d857539d2fedc31533390021b600edb906352 Mon Sep 17 00:00:00 2001
From: Tomas Glozar <tglozar@redhat.com>
Date: Wed, 4 Dec 2024 16:40:03 +0100
Subject: [PATCH 1/2] rt-tests: Put variables in test-feature in quotes
test-feature passes several variables (OBJDIR, CFLAGS, CPPFLAGS,
LDFLAGS) to make via a shell command from inside the Makefile. If there
are spaces in either of these, it gets parsed as a second argument
to make and feature detection fails.
Add quotes around the values to prevent them being passed as multiple
arguments.
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
feature/test-feature.mak | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/feature/test-feature.mak b/feature/test-feature.mak
index 0b3e51c..aef915a 100644
--- a/feature/test-feature.mak
+++ b/feature/test-feature.mak
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-or-later
define test-feature
-$(shell $(MAKE) OBJDIR=$(OBJDIR) CFLAGS=$(CFLAGS) CPPFLAGS=$(CPPFLAGS) LDFLAGS=$(LDFLAGS) \
+$(shell $(MAKE) OBJDIR="$(OBJDIR)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" \
-f feature/Makefile feature-$1 clean >/dev/null 2>/dev/null; echo $$?)
endef
--
2.43.5

View File

@ -0,0 +1,45 @@
From 623f6908ef3bc8367661a2e1440dd8c5bee91397 Mon Sep 17 00:00:00 2001
From: Tomas Glozar <tglozar@redhat.com>
Date: Wed, 4 Dec 2024 16:40:04 +0100
Subject: [PATCH 2/2] rt-tests: Handle -lcpupower flag outside LDFLAGS
The rt-tests Makefile adds -lcpupower to LDFLAGS if libcpupower support
is detected on the system. However, this does not work when LDFLAGS is
overwritten by an external source.
Add separate variable LIBCPUPOWER to contain the flag and pass it to the
cyclictest linking phase. This also avoids unnecessarily passing the
flag to the linking of other rt-tests binaries which do not use
libcpupower.
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index f656e34..0fa0928 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ PYLIB ?= $(shell python3 -m get_pylib)
ifneq ($(no_libcpupower), 1)
ifeq ($(call test-feature,libcpupower), 0)
CPPFLAGS += -DHAVE_LIBCPUPOWER_SUPPORT
-LDFLAGS += -lcpupower
+LIBCPUPOWER += -lcpupower
else
$(warning libcpupower is missing, building without --deepest-idle-state support.)
$(warning Please install libcpupower-dev/kernel-tools-libs-devel)
@@ -135,7 +135,7 @@ $(OBJDIR):
-include $(addprefix $(OBJDIR)/,$(sources:.c=.d))
cyclictest: $(OBJDIR)/cyclictest.o $(OBJDIR)/librttest.a $(OBJDIR)/librttestnuma.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB) $(RTTESTNUMA)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB) $(RTTESTNUMA) $(LIBCPUPOWER)
cyclicdeadline: $(OBJDIR)/cyclicdeadline.o $(OBJDIR)/librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB)
--
2.43.5

View File

@ -6,7 +6,7 @@ Name: realtime-tests
# Numa argument to make: NUMA=1
#
Version: 2.8
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2
URL: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
Source0: https://www.kernel.org/pub/linux/utils/rt-tests/rt-tests-%{version}.tar.xz
@ -16,10 +16,13 @@ BuildRequires: make
BuildRequires: gcc
BuildRequires: numactl-devel
BuildRequires: python3-devel
BuildRequires: kernel-headers
BuildRequires: kernel-tools-libs-devel
Requires: bash
Requires: bc
#Patches
Patch1: 0001-rt-tests-Put-variables-in-test-feature-in-quotes.patch
Patch2: 0002-rt-tests-Handle-lcpupower-flag-outside-LDFLAGS.patch
%description
realtime-tests is a set of programs that test and measure various components of
@ -27,7 +30,7 @@ real-time kernel behavior. This package measures timer, signal, and hardware
latency. It also tests the functioning of priority-inheritance mutexes.
%prep
%setup -q -n rt-tests-%{version}
%autosetup -p1 -n rt-tests-%{version}
%build
%set_build_flags
@ -78,6 +81,10 @@ latency. It also tests the functioning of priority-inheritance mutexes.
%{_mandir}/man8/determine_maximum_mpps.8.*
%changelog
* Wed Dec 09 2024 Tomas Glozar <tglozar@redhat.com> - 2.8-2
- Fix building against libcpupower
Resolves: RHEL-65487
* Fri Nov 29 2024 John Kacur <jkacur@redhat.com> - 2.8-1
- Rebase to rt-tests-2.8 upstream
Resolves: RHEL-68658