Skip to content

Commit 2c5af1c

Browse files
bonziniavpatel
authored andcommitted
selftests/kvm: Fix issues with $(SPLIT_TESTS)
The introduction of $(SPLIT_TESTS) also introduced a warning when building selftests on architectures that include get-reg-lists: make: Entering directory '/root/kvm/tools/testing/selftests/kvm' Makefile:272: warning: overriding recipe for target '/root/kvm/tools/testing/selftests/kvm/get-reg-list' Makefile:267: warning: ignoring old recipe for target '/root/kvm/tools/testing/selftests/kvm/get-reg-list' make: Leaving directory '/root/kvm/tools/testing/selftests/kvm' In addition, the rule for $(SPLIT_TESTS_TARGETS) includes _all_ the $(SPLIT_TESTS_OBJS), which only works because there is just one. So fix both by adjusting the rules: - remove $(SPLIT_TESTS_TARGETS) from the $(TEST_GEN_PROGS) rules, and rename it to $(SPLIT_TEST_GEN_PROGS) - fix $(SPLIT_TESTS_OBJS) so that it plays well with $(OUTPUT), rename it to $(SPLIT_TEST_GEN_OBJ), and list the object file explicitly in the $(SPLIT_TEST_GEN_PROGS) link rule Fixes: 17da79e ("KVM: arm64: selftests: Split get-reg-list test code", 2023-08-09) Signed-off-by: Paolo Bonzini <[email protected]> Tested-by: Andrew Jones <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent d206a76 commit 2c5af1c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tools/testing/selftests/kvm/Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,32 +260,36 @@ LIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C))
260260
LIBKVM_S_OBJ := $(patsubst %.S, $(OUTPUT)/%.o, $(LIBKVM_S))
261261
LIBKVM_STRING_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_STRING))
262262
LIBKVM_OBJS = $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ) $(LIBKVM_STRING_OBJ)
263-
SPLIT_TESTS_TARGETS := $(patsubst %, $(OUTPUT)/%, $(SPLIT_TESTS))
264-
SPLIT_TESTS_OBJS := $(patsubst %, $(ARCH_DIR)/%.o, $(SPLIT_TESTS))
263+
SPLIT_TEST_GEN_PROGS := $(patsubst %, $(OUTPUT)/%, $(SPLIT_TESTS))
264+
SPLIT_TEST_GEN_OBJ := $(patsubst %, $(OUTPUT)/$(ARCH_DIR)/%.o, $(SPLIT_TESTS))
265265

266266
TEST_GEN_OBJ = $(patsubst %, %.o, $(TEST_GEN_PROGS))
267267
TEST_GEN_OBJ += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED))
268268
TEST_DEP_FILES = $(patsubst %.o, %.d, $(TEST_GEN_OBJ))
269269
TEST_DEP_FILES += $(patsubst %.o, %.d, $(LIBKVM_OBJS))
270-
TEST_DEP_FILES += $(patsubst %.o, %.d, $(SPLIT_TESTS_OBJS))
270+
TEST_DEP_FILES += $(patsubst %.o, %.d, $(SPLIT_TEST_GEN_OBJ))
271271
-include $(TEST_DEP_FILES)
272272

273-
$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): %: %.o
273+
x := $(shell mkdir -p $(sort $(OUTPUT)/$(ARCH_DIR) $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
274+
275+
$(filter-out $(SPLIT_TEST_GEN_PROGS), $(TEST_GEN_PROGS)) \
276+
$(TEST_GEN_PROGS_EXTENDED): %: %.o
274277
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBKVM_OBJS) $(LDLIBS) -o $@
275278
$(TEST_GEN_OBJ): $(OUTPUT)/%.o: %.c
276279
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
277280

278-
$(SPLIT_TESTS_TARGETS): %: %.o $(SPLIT_TESTS_OBJS)
281+
$(SPLIT_TEST_GEN_PROGS): $(OUTPUT)/%: $(OUTPUT)/%.o $(OUTPUT)/$(ARCH_DIR)/%.o
279282
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
283+
$(SPLIT_TEST_GEN_OBJ): $(OUTPUT)/$(ARCH_DIR)/%.o: $(ARCH_DIR)/%.c
284+
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
280285

281286
EXTRA_CLEAN += $(GEN_HDRS) \
282287
$(LIBKVM_OBJS) \
283-
$(SPLIT_TESTS_OBJS) \
288+
$(SPLIT_TEST_GEN_OBJ) \
284289
$(TEST_DEP_FILES) \
285290
$(TEST_GEN_OBJ) \
286291
cscope.*
287292

288-
x := $(shell mkdir -p $(sort $(dir $(LIBKVM_C_OBJ) $(LIBKVM_S_OBJ))))
289293
$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS)
290294
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
291295

@@ -299,7 +303,7 @@ $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
299303
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
300304

301305
x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
302-
$(SPLIT_TESTS_OBJS): $(GEN_HDRS)
306+
$(SPLIT_TEST_GEN_OBJ): $(GEN_HDRS)
303307
$(TEST_GEN_PROGS): $(LIBKVM_OBJS)
304308
$(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
305309
$(TEST_GEN_OBJ): $(GEN_HDRS)

0 commit comments

Comments
 (0)