Re: [PATCH] KVM: selftests: Depend on kernel headers when making selftests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 20, 2023, Colton Lewis wrote:
> Add a makefile dependency for the kernel headers when building KVM
> selftests. As the selftests do depend on the kernel headers, needing
> to do things such as build selftests for a different architecture
> requires rebuilding the headers. That is an extra annoying manual step
> that should be handled by make.

I 100% agree that this is super annoying, but auto-installation of header was
deliberately removed[1][2] (this isn't the first time this type of change has been
proposed[3]) to play nice with an out-of-tree build directory.

Argh, digging a bit deeper, KVM selftests' makefile is all kinds of funky.  It
defines its own header path, LINUX_HDR_PATH, but then also grabs KHDR_INCLUDE
since commit 0cc5963b4cc3 ("selftests: kvm: Add the uapi headers include variable").
That's flawed because KVM selftests will pick up the in-tree headers first, i.e.
out-of-tree builds effectively rely on the in-tree headers not being built.  I'll
send the below as a formal patch.

As for auto-installing headers, for those of us that build directly from the KVM
selftests directory, the best option I've come up with is to add an alias+script
for building selftests and have that do the header installation.

---
 tools/testing/selftests/kvm/Makefile | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 844417601618..01ea083a2cd9 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -186,8 +186,6 @@ LIBKVM += $(LIBKVM_$(ARCH_DIR))
 # which causes the environment variable to override the makefile).
 include ../lib.mk
 
-INSTALL_HDR_PATH = $(top_srcdir)/usr
-LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
 ifeq ($(ARCH),x86_64)
 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
@@ -198,9 +196,8 @@ CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
 	-Wno-gnu-variable-sized-type-not-at-end \
 	-fno-builtin-memcmp -fno-builtin-memcpy -fno-builtin-memset \
 	-fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
-	-I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
-	-I$(<D) -Iinclude/$(ARCH_DIR) -I ../rseq -I.. $(EXTRA_CFLAGS) \
-	$(KHDR_INCLUDES)
+	-I$(LINUX_TOOL_ARCH_INCLUDE) -Iinclude -I$(<D) -Iinclude/$(ARCH_DIR) \
+	-I ../rseq -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
 
 no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
         $(CC) -Werror $(CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie)
@@ -238,7 +235,7 @@ x := $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
 $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
 $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
 
-cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
+cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(top_srcdir)/usr/include include lib ..
 cscope:
 	$(RM) cscope.*
 	(find $(include_paths) -name '*.h' \

base-commit: c57c5ac42480250deb22b306ec6bcbdf0e6b5857
-- 

[1] https://lore.kernel.org/lkml/cover.1657296695.git.guillaume.tucker@xxxxxxxxxxxxx
[2] https://lore.kernel.org/all/b39b9e0b-45f3-1818-39fe-58921182d957@xxxxxxxxxxxxxxxxxxx
[3] https://lore.kernel.org/all/20221219095540.52208-1-likexu@xxxxxxxxxxx



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux