Skip to content

Fix kselftest build with sub-directory

Guillaume Tucker linux-kbuild linux-kselftest lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 5 repliesIn review
  2. v14 patches 7 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4selftests: drop khdr make targettools/testing/selftests/Makefile+2 -250 replies
2/4selftests: stop using KSFT_KHDR_INSTALLtools/testing/selftests/arm64/mte/Makefile tools/testing/selftests/arm64/signal/Makefile tools/testing/selftests/arm64/signal/test_signals.h +8 more+1 -130 replies
3/4selftests: drop KSFT_KHDR_INSTALL make targettools/testing/selftests/Makefile tools/testing/selftests/lib.mk+0 -392 replies
4/4Makefile: add headers to kselftest targetsMakefile+2 -22 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchNicolas Schier
1/4
2/4
3/4
4/4T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] Fix kselftest build with sub-directory

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.

v2: replace headers_install with headers

Guillaume Tucker (4):
selftests: drop khdr make target
selftests: stop using KSFT_KHDR_INSTALL
selftests: drop KSFT_KHDR_INSTALL make target
Makefile: add headers 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