Message ID | 20200326030750.173972-1-xiaoyao.li@intel.com (mailing list archive) |
---|---|
Headers | show |
Series | Fix errors when try to build kvm selftests on specified output | expand |
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. 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.) From main Makefile in kernel srcdir make O=/path/to/mydir TARGETS=kvm 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. thanks, -- Shuah
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.
On 3/27/20 7:31 AM, Xiaoyao Li wrote: > 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? > O is the variable for selftests Makefile and which is handled in lib.mk. OUTPUT is internal and shouldn't set when running make. >> >> 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. > Right. That is what needs to be fixed. This is the reason for your source directory getting dirty when kvm test is built. > 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/ ? This is kernel source root directory. The command you would use is: make kselftest-all O=/path/to/mydir TARGETS=kvm > > 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. > Right. It doesn't work for a couple of reasons: 1. The Makefile doesn't create sub-dirs when build is relocatable. 2. Makes source directory dirty. > If the patches are wrong, please point it out and give your comments how > to make it right. > The patches you sent are based on running the command with OUTPUT set. That is why I am asking you start with the right use-cases, and gave you pointers on tests to refer to that have sub-dirs and handle relocatable builds: futex arm64 android >> 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. > > If the test leverages lib.mk headers install logic correctly, you shouldn't see this problem. Yes. It does make the source directory dirty. That is the problem we have to fix. I am seeing issues the issue of x86_64 not being created in the case of relocatable builds. Thanks for working on this by the way. It is one of the tests that identified as the one doesn't support relocatable builds. You will see fixes to others I already fixed in https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next Start withe the following use0-cases to fix and then test your fixes for these use-cases. The goal is to be able to run kvm from target directory and source directory staying clean. You will have to build the kernel first in all of these cases. Let's use kselftest-install which is what you would need if you want build and then run tests later. Also assuming you are doing native build on x86_64. From main kernel Makefile: (from kernel source root dir) Builds in the same source directory: make kselftest-install TARGETS=kvm Relocatable build: (from kernel source root dir) make O=/path/objdir - build kernel make kselftest-install O=/path/objdir TARGETS=kvm From tools/testing/selftests/kvm directory: make O=/path/objdir install Install step is important especially for relocatable builds, as it makes sure all run-time dependencies are copied to the target directory. thanks, -- Shuah
On 3/28/2020 12:03 AM, shuah wrote: > On 3/27/20 7:31 AM, Xiaoyao Li wrote: >> On 3/27/2020 4:57 AM, shuah wrote: >>> On 3/25/20 9:07 PM, Xiaoyao Li wrote: > The patches you sent are based on running the command with OUTPUT > set. The issues are also there when I use make O=/somewher TARGETS=kvm from tools/testing/selftests/ directory, Is it the right usecase? > That is why I am asking you start with the right use-cases, > and gave you pointers on tests to refer to that have sub-dirs > and handle relocatable builds: > > futex > arm64 > android I have read the Makefile in futex, arm64, android to learn how they deal with subdir, they have Makefile in subdir but kvm doesn't. I just want to create the subdir as easy as possible, so I follow the method how to create subdir for LIBKVM_OBJ in kvm. If you dislike it way you can reply it Patch 1 to disclaim clear what you want to fix the subdir. >>> 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. >> >> > > If the test leverages lib.mk headers install logic correctly, you > shouldn't see this problem. > > Yes. It does make the source directory dirty. That is the problem we > have to fix. I am seeing issues the issue of x86_64 not being created > in the case of relocatable builds. > > Thanks for working on this by the way. It is one of the tests that > identified as the one doesn't support relocatable builds. > > You will see fixes to others I already fixed in > > https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next > > > Start withe the following use0-cases to fix and then test your fixes > for these use-cases. The goal is to be able to run kvm from target > directory and source directory staying clean. > > You will have to build the kernel first in all of these cases. > Let's use kselftest-install which is what you would need if you > want build and then run tests later. Also assuming you are doing > native build on x86_64. > > From main kernel Makefile: (from kernel source root dir) > > Builds in the same source directory: > make kselftest-install TARGETS=kvm > > Relocatable build: (from kernel source root dir) > > make O=/path/objdir - build kernel > make kselftest-install O=/path/objdir TARGETS=kvm I don't want to build kernel at all. > From tools/testing/selftests/kvm directory: > make O=/path/objdir install Oh no. This needs to define INSTALL_PATH, and I don't want to install. I just want to build the testcase of kvm to anywhere else to make srcdir clean. Besides this command make both kernel src and selftest/kvm dirty. > Install step is important especially for relocatable builds, > as it makes sure all run-time dependencies are copied to the > target directory. > OK. So, again. is make O=/tmp/kvm-selftest -C tools/testing/selftests \ TARGETS=kvm install INSTALL_PATH=/home/lxy/kvm-selftest the right command for me to start on?
On 3/28/20 2:51 AM, Xiaoyao Li wrote: > On 3/28/2020 12:03 AM, shuah wrote: >> On 3/27/20 7:31 AM, Xiaoyao Li wrote: >>> On 3/27/2020 4:57 AM, shuah wrote: >>>> On 3/25/20 9:07 PM, Xiaoyao Li wrote: >> The patches you sent are based on running the command with OUTPUT >> set. > > The issues are also there when I use > > make O=/somewher TARGETS=kvm > > from tools/testing/selftests/ directory, > > Is it the right usecase? > >> That is why I am asking you start with the right use-cases, >> and gave you pointers on tests to refer to that have sub-dirs >> and handle relocatable builds: >> >> futex >> arm64 >> android > > I have read the Makefile in futex, arm64, android to learn how they > deal with subdir, they have Makefile in subdir but kvm doesn't. > > I just want to create the subdir as easy as possible, so I follow the > method how to create subdir for LIBKVM_OBJ in kvm. > > If you dislike it way you can reply it Patch 1 to disclaim clear what > you want to fix the subdir. > >>>> 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. >>> >>> >> >> If the test leverages lib.mk headers install logic correctly, you >> shouldn't see this problem. >> >> Yes. It does make the source directory dirty. That is the problem we >> have to fix. I am seeing issues the issue of x86_64 not being created >> in the case of relocatable builds. >> >> Thanks for working on this by the way. It is one of the tests that >> identified as the one doesn't support relocatable builds. >> >> You will see fixes to others I already fixed in >> >> https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=next >> >> >> Start withe the following use0-cases to fix and then test your fixes >> for these use-cases. The goal is to be able to run kvm from target >> directory and source directory staying clean. >> >> You will have to build the kernel first in all of these cases. >> Let's use kselftest-install which is what you would need if you >> want build and then run tests later. Also assuming you are doing >> native build on x86_64. >> >> From main kernel Makefile: (from kernel source root dir) >> >> Builds in the same source directory: >> make kselftest-install TARGETS=kvm >> >> Relocatable build: (from kernel source root dir) >> >> make O=/path/objdir - build kernel >> make kselftest-install O=/path/objdir TARGETS=kvm > > I don't want to build kernel at all. > >> From tools/testing/selftests/kvm directory: >> make O=/path/objdir install > > Oh no. This needs to define INSTALL_PATH, and I don't want to install. > I just want to build the testcase of kvm to anywhere else to make srcdir > clean. > > Besides this command make both kernel src and selftest/kvm dirty. > >> Install step is important especially for relocatable builds, >> as it makes sure all run-time dependencies are copied to the >> target directory. >> > > OK. > > So, again. > > is > > make O=/tmp/kvm-selftest -C tools/testing/selftests \ > TARGETS=kvm install INSTALL_PATH=/home/lxy/kvm-selftest > > the right command for me to start on? > Sorry for the delay. Yes the above command will work. Please check https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next branch I fixed kvm build/cross-build problems and applied it to next for testing. https://patchwork.kernel.org/patch/11513471/ thanks, -- Shuah