From: Sean Christopherson <seanjc@google.com>
To: Colton Lewis <coltonlewis@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>, Marc Zyngier <maz@kernel.org>,
David Matlack <dmatlack@google.com>,
Oliver Upton <oliver.upton@linux.dev>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Ben Gardon <bgardon@google.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Depend on kernel headers when making selftests
Date: Wed, 22 Feb 2023 09:49:21 -0800 [thread overview]
Message-ID: <Y/ZVoSR0sYyceEAr@google.com> (raw)
In-Reply-To: <20230220203529.136013-1-coltonlewis@google.com>
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@collabora.com
[2] https://lore.kernel.org/all/b39b9e0b-45f3-1818-39fe-58921182d957@linuxfoundation.org
[3] https://lore.kernel.org/all/20221219095540.52208-1-likexu@tencent.com
next prev parent reply other threads:[~2023-02-22 17:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 20:35 [PATCH] KVM: selftests: Depend on kernel headers when making selftests Colton Lewis
2023-02-22 17:49 ` Sean Christopherson [this message]
2023-02-22 17:59 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/ZVoSR0sYyceEAr@google.com \
--to=seanjc@google.com \
--cc=bgardon@google.com \
--cc=coltonlewis@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.