Re: A question of KVM selftests' makefile

Sean Christopherson
2023-01-25T17:27:04Z

On Wed, Jan 25, 2023, Yu Zhang wrote:
> Hi all,
>
> Currently, unlike the build system of Linux kernel, KVM selftests will
> have to run "make clean && make" to rebuild the entire test suite, once
> a header file is modified.
>
> Is it designed like this on purpose,

My #1 rule: never assume anything weird in KVM was an explicit design choice :-)

> or does anyone wanna change it?

Yes!

> I hacked the makefile by using "-MD" as EXTRA_CFLAGS, so that dependency
> rules can be generated for each target object, whose prerequisites contains
> the source file and the included header files as well.
>
> However, this change has its own costs. E.g., new ".o" and ".d" files will
> occupy more storage. And performance-wise, the benifit could be limited,
> because for now, most header files are needed by almost every ".c" files.
> But with the evolution of KVM selftests, more ".h" files may be added. Some
> of which may be of special usage. E.g., file "include/x86_64/mce.h" is only
> used by "x86_64/ucna_injection_test". Having to rebuild the whole test suite
> just because one specific header is touched would be annoying.
>
> I am not sure if this change is worthy,

Absolutely worthy, I've run afoul of the lack of dependency tracking far too many
times.

> or if there's a better solution.

This part I don't know. I would have cobbled together something long ago if I
wasn't so clueless about Makefiles.