Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Shuah Khan <shuah@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org
Cc: Xiaoyao Li <xiaoyao.li@intel.com>
Subject: [PATCH 2/2] selftests: export INSTALL_HDR_PATH if using "O" to specify output dir
Date: Sun, 15 Mar 2020 17:34:25 +0800	[thread overview]
Message-ID: <20200315093425.33600-3-xiaoyao.li@intel.com> (raw)
In-Reply-To: <20200315093425.33600-1-xiaoyao.li@intel.com>

When build kvm selftests in tools/testing/selftests directory with

	make O=~/kselftests TARGETS=kvm

it fails building some kvm test binaries due to lack of header files,
e.g.,

x86_64/vmx_set_nested_state_test.c: In function ‘set_default_vmx_state’:
x86_64/vmx_set_nested_state_test.c:85:7: error: ‘struct
kvm_nested_state’ has no member named ‘hdr’
  state->hdr.vmx.vmxon_pa = 0x1000;

kvm's Makefile unconditionally thinks kernel headers are installed
in the "kernel-src/usr" with "INSTALL_HDR_PATH = $(top_srcdir)/usr".
However, with "O" is specified, it also takes effect on
"make headers_install", that causes no header files generated in
"kernel-src/usr".

Export INSTALL_HDR_PATH when "O" is specified, so that kvm get the right
kernel headers by checking if INSTALL_HDR_PATH is defined.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 tools/testing/selftests/Makefile     | 6 +++++-
 tools/testing/selftests/kvm/Makefile | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 6ec503912bea..5fd72d955e24 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -116,6 +116,10 @@ ARCH           ?= $(SUBARCH)
 export KSFT_KHDR_INSTALL_DONE := 1
 export BUILD
 
+ifneq (1,$(DEFAULT_INSTALL_HDR_PATH))
+export	INSTALL_HDR_PATH := $(BUILD)/usr
+endif
+
 # build and run gpio when output directory is the src dir.
 # gpio has dependency on tools/gpio and builds tools/gpio
 # objects in the src directory in all cases making the src
@@ -148,7 +152,7 @@ khdr:
 ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
 	$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
 else
-	$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
+	$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(INSTALL_HDR_PATH) \
 		ARCH=$(ARCH) -C $(top_srcdir) headers_install
 endif
 
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index 86797e0242d4..c14d23c978d5 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -44,7 +44,7 @@ TEST_GEN_PROGS_s390x += kvm_create_max_vcpus
 TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
 LIBKVM += $(LIBKVM_$(UNAME_M))
 
-INSTALL_HDR_PATH = $(top_srcdir)/usr
+INSTALL_HDR_PATH ?= $(top_srcdir)/usr
 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include
 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
-- 
2.20.1


  parent reply	other threads:[~2020-03-15  9:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-15  9:34 [PATCH 0/2] Fix errors when try to build kvm selftests on Xiaoyao Li
2020-03-15  9:34 ` [PATCH 1/2] kvm: selftests: Fix no directory error when OUTPUT specified Xiaoyao Li
2020-03-23 15:40   ` shuah
2020-03-24  1:51     ` Xiaoyao Li
2020-03-15  9:34 ` Xiaoyao Li [this message]
2020-03-18 13:13 ` [PATCH 0/2] Fix errors when try to build kvm selftests on Paolo Bonzini
2020-03-23 15:33   ` shuah
2020-03-23 15:44   ` shuah
2020-03-23 19:42     ` Paolo Bonzini

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=20200315093425.33600-3-xiaoyao.li@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox