[PATCH] cpupower: fix building cpufreq-bench with STATIC=true and O=

From: Sasha Levin

Date: Sun Oct 11 2026 - 18:34:27 EST


With STATIC=true, cpufreq-bench links lib/cpufreq.o and lib/cpupower.o,
which it expects in $(OUTPUT)../lib/. That is where the parent Makefile
builds them when bench's OUTPUT is the bench directory, but with O=,
bench gets the parent's output directory and the objects are in
$(OUTPUT)lib/. bench then tries to build them itself, outside the output
directory, and fails:

Fatal error: can't create <O>//../lib/cpufreq.o: No such file or directory

Use the objects in lib/ under the parent's output directory, which is
one level up from bench when it is a relative path.

Fixes: e51207f003047 ("cpupower: Provide STATIC variable in Makefile for debug builds")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/power/cpupower/bench/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/power/cpupower/bench/Makefile b/tools/power/cpupower/bench/Makefile
index 34e5894476eba..ea74ef4d01b64 100644
--- a/tools/power/cpupower/bench/Makefile
+++ b/tools/power/cpupower/bench/Makefile
@@ -10,11 +10,12 @@ ifneq ($(O),)
OUTPUT := $(O)/
endif
endif
+LIBOUTPUT := $(if $(filter /%,$(OUTPUT)),,../)$(OUTPUT)

ifeq ($(strip $(STATIC)),true)
LIBS = -L../ -L$(OUTPUT) -lm
OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o \
- $(OUTPUT)../lib/cpufreq.o $(OUTPUT)../lib/cpupower.o
+ $(LIBOUTPUT)lib/cpufreq.o $(LIBOUTPUT)lib/cpupower.o
else
LIBS = -L../ -L$(OUTPUT) -lm -lcpupower
OBJS = $(OUTPUT)main.o $(OUTPUT)parse.o $(OUTPUT)system.o $(OUTPUT)benchmark.o
--
2.53.0