Skip to contentSkip to conversation

rt-tests: libcpupower feature detection fixes

PATCH In review [email protected] 2 participants 4 messages Dec 4, 2024 – Dec 6, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

cover rt-tests: libcpupower feature detection fixes

From: Tomas Glozar <[email protected]>

Two bugs were found while trying to build cyclictest with libcpupower support inside an RPM build. One bug prevents libcpupower detection when there are spaces inside OBJDIR, CFLAGS, CPPFLAGS or LDFLAGS, the other bug breaks linking against libcpupower when LDFLAGS is passed to make.

Fix both those bugs and unbreak RPM builds with libcpupower support.

Tomas Glozar (2):
rt-tests: Put variables in test-feature in quotes
rt-tests: Handle -lcpupower flag outside LDFLAGS

 Makefile                 | 4 ++--
 feature/test-feature.mak | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.47.0
#1 lore raw

PATCH 1/2 rt-tests: Put variables in test-feature in quotes

From: Tomas Glozar <[email protected]>

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.

---
 feature/test-feature.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
feature/test-feature.mak +1 -1
index 0b3e51c..aef915a 100644
@@ -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
Signature · 1 line
2.47.0
#2 lore raw

Re: [PATCH 1/2] rt-tests: Put variables in test-feature in quotes

Quoted 31 lines · On Wed, 4 Dec 2024, [email protected] wrote:

From: Tomas Glozar <[email protected]>

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.

---
 feature/test-feature.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
feature/test-feature.mak +1 -1
index 0b3e51c..aef915a 100644
@@ -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
Signature · 1 line
2.47.0
#3 lore raw

PATCH 2/2 rt-tests: Handle -lcpupower flag outside LDFLAGS

In reply to [email protected]

From: Tomas Glozar <[email protected]>

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.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index f656e34..0fa0928 100644
@@ -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)
Signature · 1 line
2.47.0