Re: [RFC v3 0/3] Fix errors when try to build kvm selftests on specified output

From: Xiaoyao Li
Date: Fri Mar 27 2020 - 09:31:17 EST


On 3/27/2020 4:57 AM, shuah wrote:
On 3/25/20 9:07 PM, Xiaoyao Li wrote:
Hi Shuah,

Hope you're happy with this version that I only touch KVM's Makefile.

I attempted to build KVM selftests on a specified dir, unfortunately
neitherÂÂÂ "make O=/path/to/mydir TARGETS=kvm" in tools/testing/selftests, nor
"make OUTPUT=/path/to/mydir" in tools/testing/selftests/kvm work.


Why are you running "make OUTPUT=/path/to/mydir"

It isn't correct.

So what's the meaning of

ifeq (0,$(MAKELEVEL))
ifeq ($(OUTPUT),)
OUTPUT := $(shell pwd)
DEFAULT_INSTALL_HDR_PATH := 1
endif
endif

in lib.mk?


make O=/path/to/mydir is what you have to use. Please main Makefile
as well for O= and KBUILD_OUTPUT usages.

Please see Documentation/dev-tools/kselftest.rst for use-cases.

make O=/path/to/mydir TARGETS=kvm is a right use-case and I can see
it will fail to create x86_64 directory.

Let's start with the following two commands and try to fix the
problems you are seeing.

make O=/path/to/mydir in kvm directory (this is supported,
however, the following command from the main Makefile is
recommended use.)

Of course we can do this, but the "O=/path/to/mydir" only has effect on header install, the *.o files still generated in kvm/ directory.

And kvm's INSTALL_HDR_PATH cannot find the right headers.

That's why I choose to use "OUTPUT=/somewhere"

From main Makefile in kernel srcdir
make O=/path/to/mydir TARGETS=kvm

I guess "kernel srcdir" means "kselftest srcdir", i.e., tools/testing/selftests/ ?

Well, as I said in the first place, I tried

make O=/path/to/mydir TARGETS=kvm

but it doesn't work. So I did some fixup, and sent out the Patches.

If the patches are wrong, please point it out and give your comments how to make it right.

Also, just build isn't sufficient for you to be able to run the
tests.

make kselftest-install O=/path/to/mydir TARGETS=kvm will generate
run script.

This command also has the x86_64 directory not created issue.
Since it generates header files in kernel_src/usr/include, it doesn't have headers path issue. But as result, the kernel_src directory is not clean, this requires me to run "make mrproper", I *really* don't like it.