mbox series

[0/4] Fix kselftest build with sub-directory

Message ID cover.1657296695.git.guillaume.tucker@collabora.com (mailing list archive)
Headers show
Series Fix kselftest build with sub-directory | expand

Message

Guillaume Tucker July 8, 2022, 4:23 p.m. UTC
Earlier attempts to get "make O=build kselftest-all" to work were
not successful as they made undesirable changes to some functions
in the top-level Makefile.  This series takes a different
approach by removing the root cause of the problem within
kselftest, which is when the sub-Makefile tries to install kernel
headers "backwards" by calling make with the top-level Makefile.
The actual issue comes from the fact that $(srctree) is ".." when
building in a sub-directory with "O=build" which then obviously
makes "-C $(top_srcdir)" point outside of the real source tree.

With this series, the generic kselftest targets work as expected
from the top level with or without a build directory e.g.:

  $ make kselftest-all

  $ make O=build kselftest-all

Then in order to build using the sub-Makefile explicitly, the
headers have to be installed first.  This is arguably a valid
requirement to have when building a tool from a sub-Makefile.
For example, "make -C tools/testing/nvdimm/" fails in a similar
way until <asm/rwonce.h> has been generated by a kernel build.

Guillaume Tucker (4):
  selftests: drop khdr make target
  selftests: stop using KSFT_KHDR_INSTALL
  selftests: drop KSFT_KHDR_INSTALL make target
  Makefile: add headers_install to kselftest targets

 Makefile                                      |  4 +-
 tools/testing/selftests/Makefile              | 28 +-------------
 tools/testing/selftests/arm64/mte/Makefile    |  1 -
 tools/testing/selftests/arm64/signal/Makefile |  1 -
 .../selftests/arm64/signal/test_signals.h     |  4 +-
 .../selftests/drivers/s390x/uvdevice/Makefile |  1 -
 .../selftests/futex/functional/Makefile       |  1 -
 tools/testing/selftests/kvm/Makefile          |  1 -
 tools/testing/selftests/landlock/Makefile     |  1 -
 tools/testing/selftests/lib.mk                | 38 -------------------
 tools/testing/selftests/net/Makefile          |  1 -
 tools/testing/selftests/net/mptcp/Makefile    |  1 -
 tools/testing/selftests/tc-testing/Makefile   |  1 -
 tools/testing/selftests/vm/Makefile           |  1 -
 14 files changed, 5 insertions(+), 79 deletions(-)

--
2.30.2

Comments

Shuah Khan July 8, 2022, 5:14 p.m. UTC | #1
On 7/8/22 10:23 AM, Guillaume Tucker wrote:
> Earlier attempts to get "make O=build kselftest-all" to work were
> not successful as they made undesirable changes to some functions
> in the top-level Makefile.  This series takes a different
> approach by removing the root cause of the problem within
> kselftest, which is when the sub-Makefile tries to install kernel
> headers "backwards" by calling make with the top-level Makefile.
> The actual issue comes from the fact that $(srctree) is ".." when
> building in a sub-directory with "O=build" which then obviously
> makes "-C $(top_srcdir)" point outside of the real source tree.
> 
> With this series, the generic kselftest targets work as expected
> from the top level with or without a build directory e.g.:
> 
>    $ make kselftest-all
> 
>    $ make O=build kselftest-all
> 
> Then in order to build using the sub-Makefile explicitly, the
> headers have to be installed first.  This is arguably a valid
> requirement to have when building a tool from a sub-Makefile.
> For example, "make -C tools/testing/nvdimm/" fails in a similar
> way until <asm/rwonce.h> has been generated by a kernel build.
> 
> Guillaume Tucker (4):
>    selftests: drop khdr make target
>    selftests: stop using KSFT_KHDR_INSTALL
>    selftests: drop KSFT_KHDR_INSTALL make target
>    Makefile: add headers_install to kselftest targets
> 

This takes us to back to the state before b2d35fa5fc80 added
khdr support. I reluctantly agreed to the change and it has
proven to be a problematic change. I would rather have had the
dependency stated that headers should be installed prior to
building tests - test build depends on kernel build anyway and
having dependency on headers having build isn't a huge deal.

So I am in favor of getting rid of khdr support. However, this
khdr support was a change originated from Linaro test ring. Undoing
this might have implication on their workflow.

I will pull them into the discussion so they are aware of it and
be prepared for this change.

thanks,
-- Shuah
Bird, Tim July 8, 2022, 5:37 p.m. UTC | #2
> -----Original Message-----
> From: Shuah Khan <skhan@linuxfoundation.org>
> 
> On 7/8/22 10:23 AM, Guillaume Tucker wrote:
> > Earlier attempts to get "make O=build kselftest-all" to work were
> > not successful as they made undesirable changes to some functions
> > in the top-level Makefile.  This series takes a different
> > approach by removing the root cause of the problem within
> > kselftest, which is when the sub-Makefile tries to install kernel
> > headers "backwards" by calling make with the top-level Makefile.
> > The actual issue comes from the fact that $(srctree) is ".." when
> > building in a sub-directory with "O=build" which then obviously
> > makes "-C $(top_srcdir)" point outside of the real source tree.
> >
> > With this series, the generic kselftest targets work as expected
> > from the top level with or without a build directory e.g.:
> >
> >    $ make kselftest-all
> >
> >    $ make O=build kselftest-all
> >
> > Then in order to build using the sub-Makefile explicitly, the
> > headers have to be installed first.  This is arguably a valid
> > requirement to have when building a tool from a sub-Makefile.
> > For example, "make -C tools/testing/nvdimm/" fails in a similar
> > way until <asm/rwonce.h> has been generated by a kernel build.
> >
> > Guillaume Tucker (4):
> >    selftests: drop khdr make target
> >    selftests: stop using KSFT_KHDR_INSTALL
> >    selftests: drop KSFT_KHDR_INSTALL make target
> >    Makefile: add headers_install to kselftest targets
> >
> 
> This takes us to back to the state before b2d35fa5fc80 added
> khdr support. I reluctantly agreed to the change and it has
> proven to be a problematic change. I would rather have had the
> dependency stated that headers should be installed prior to
> building tests - test build depends on kernel build anyway and
> having dependency on headers having build isn't a huge deal.
> 
> So I am in favor of getting rid of khdr support. However, this
> khdr support was a change originated from Linaro test ring. Undoing
> this might have implication on their workflow.
> 
> I will pull them into the discussion so they are aware of it and
> be prepared for this change.

I ran into this bug quite a while ago.  I reported it here:
https://lore.kernel.org/all/ECADFF3FD767C149AD96A924E7EA6EAF977BD214@USCULXMSG01.am.sony.com/
it was fixed here:
https://lore.kernel.org/all/20191015014505.14259-1-skhan@linuxfoundation.org/
but apparently reverting it was discussed, based on this:
https://lore.kernel.org/all/8d34a9b9-f8f3-0e37-00bf-c342cf3d4074@arm.com/

I'm not sure what happened after that.

I was able to work around it by avoiding
putting the build directory inside the source tree.

I strongly support getting rid of the khdr stuff, as it's quite hard
to follow.  I think my workflow would not be affected (but I should
run off and test it.)

Thanks for working on this Guillaume!
 -- Tim
Anders Roxell July 11, 2022, 12:13 p.m. UTC | #3
On Fri, 8 Jul 2022 at 19:14, Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 7/8/22 10:23 AM, Guillaume Tucker wrote:
> > Earlier attempts to get "make O=build kselftest-all" to work were
> > not successful as they made undesirable changes to some functions
> > in the top-level Makefile.  This series takes a different
> > approach by removing the root cause of the problem within
> > kselftest, which is when the sub-Makefile tries to install kernel
> > headers "backwards" by calling make with the top-level Makefile.
> > The actual issue comes from the fact that $(srctree) is ".." when
> > building in a sub-directory with "O=build" which then obviously
> > makes "-C $(top_srcdir)" point outside of the real source tree.
> >
> > With this series, the generic kselftest targets work as expected
> > from the top level with or without a build directory e.g.:
> >
> >    $ make kselftest-all
> >
> >    $ make O=build kselftest-all
> >
> > Then in order to build using the sub-Makefile explicitly, the
> > headers have to be installed first.  This is arguably a valid
> > requirement to have when building a tool from a sub-Makefile.
> > For example, "make -C tools/testing/nvdimm/" fails in a similar
> > way until <asm/rwonce.h> has been generated by a kernel build.
> >
> > Guillaume Tucker (4):
> >    selftests: drop khdr make target
> >    selftests: stop using KSFT_KHDR_INSTALL
> >    selftests: drop KSFT_KHDR_INSTALL make target
> >    Makefile: add headers_install to kselftest targets
> >
>
> This takes us to back to the state before b2d35fa5fc80 added
> khdr support. I reluctantly agreed to the change and it has
> proven to be a problematic change. I would rather have had the
> dependency stated that headers should be installed prior to
> building tests - test build depends on kernel build anyway and
> having dependency on headers having build isn't a huge deal.

I agree that it's not a huge deal.

>
> So I am in favor of getting rid of khdr support. However, this
> khdr support was a change originated from Linaro test ring. Undoing
> this might have implication on their workflow.

It shouldn't be a problem.
I've been running these patches through a smoke test and it looks
good.

Tested-by: Anders Roxell <anders.roxell@linaro.org>


Cheers,
Anders

>
> I will pull them into the discussion so they are aware of it and
> be prepared for this change.
>
> thanks,
> -- Shuah
>
>
Shuah Khan July 11, 2022, 11:08 p.m. UTC | #4
On 7/11/22 6:13 AM, Anders Roxell wrote:
> On Fri, 8 Jul 2022 at 19:14, Shuah Khan <skhan@linuxfoundation.org> wrote:
>>
>> On 7/8/22 10:23 AM, Guillaume Tucker wrote:
>>> Earlier attempts to get "make O=build kselftest-all" to work were
>>> not successful as they made undesirable changes to some functions
>>> in the top-level Makefile.  This series takes a different
>>> approach by removing the root cause of the problem within
>>> kselftest, which is when the sub-Makefile tries to install kernel
>>> headers "backwards" by calling make with the top-level Makefile.
>>> The actual issue comes from the fact that $(srctree) is ".." when
>>> building in a sub-directory with "O=build" which then obviously
>>> makes "-C $(top_srcdir)" point outside of the real source tree.
>>>
>>> With this series, the generic kselftest targets work as expected
>>> from the top level with or without a build directory e.g.:
>>>
>>>     $ make kselftest-all
>>>
>>>     $ make O=build kselftest-all
>>>
>>> Then in order to build using the sub-Makefile explicitly, the
>>> headers have to be installed first.  This is arguably a valid
>>> requirement to have when building a tool from a sub-Makefile.
>>> For example, "make -C tools/testing/nvdimm/" fails in a similar
>>> way until <asm/rwonce.h> has been generated by a kernel build.
>>>
>>> Guillaume Tucker (4):
>>>     selftests: drop khdr make target
>>>     selftests: stop using KSFT_KHDR_INSTALL
>>>     selftests: drop KSFT_KHDR_INSTALL make target
>>>     Makefile: add headers_install to kselftest targets
>>>
>>
>> This takes us to back to the state before b2d35fa5fc80 added
>> khdr support. I reluctantly agreed to the change and it has
>> proven to be a problematic change. I would rather have had the
>> dependency stated that headers should be installed prior to
>> building tests - test build depends on kernel build anyway and
>> having dependency on headers having build isn't a huge deal.
> 
> I agree that it's not a huge deal.
> 
>>
>> So I am in favor of getting rid of khdr support. However, this
>> khdr support was a change originated from Linaro test ring. Undoing
>> this might have implication on their workflow.
> 
> It shouldn't be a problem.
> I've been running these patches through a smoke test and it looks
> good.
> 
> Tested-by: Anders Roxell <anders.roxell@linaro.org>
> 
> 

Thank you Anders for confirming this isn't a problem for Linaro workflow
and testing.

Than you Guillaume for fixing the problem. I will apply these for 5.20-rc1.

thanks,
-- Shuah