Re: [PATCH 1/4] selftests: Fix kselftest O=objdir build from cluttering top level objdir
From: Kevin Hilman
Date: Wed Mar 11 2020 - 18:58:35 EST
Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx> writes:
> make kselftest-all O=objdir builds create generated objects in objdir.
> This clutters the top level directory with kselftest objects. Fix it
> to create sub-directory under objdir for kselftest objects.
>
> Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
Only somewhat related to this patch, another problem that wasn't in your
doci is that the current O= support doesn't support relative paths.
For example, using O=/tmp/build-arm64 works, but O=build-arm64 doesn't.
Try this:
$ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 defconfig
$ make ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- O=build-arm64 kselftest-all
make[1]: Entering directory '/work/kernel/linux/build-arm64'
make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \
ARCH=arm64 -C ../../.. headers_install
make[4]: ../scripts/Makefile.build: No such file or directory
make[4]: *** No rule to make target '../scripts/Makefile.build'. Stop.
Makefile:500: recipe for target 'scripts_basic' failed
make[3]: *** [scripts_basic] Error 2
Makefile:151: recipe for target 'khdr' failed
make[2]: *** [khdr] Error 2
/work/kernel/linux/Makefile:1220: recipe for target 'kselftest-all' failed
make[1]: *** [kselftest-all] Error 2
make[1]: Leaving directory '/work/kernel/linux/build-arm64'
Makefile:179: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
Kevin
> ---
> tools/testing/selftests/Makefile | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index 6ec503912bea..cd77df3e6bb8 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -91,7 +91,7 @@ override LDFLAGS =
> override MAKEFLAGS =
> endif
>
> -# Append kselftest to KBUILD_OUTPUT to avoid cluttering
> +# Append kselftest to KBUILD_OUTPUT and O to avoid cluttering
> # KBUILD_OUTPUT with selftest objects and headers installed
> # by selftests Makefile or lib.mk.
> ifdef building_out_of_srctree
> @@ -99,7 +99,7 @@ override LDFLAGS =
> endif
>
> ifneq ($(O),)
> - BUILD := $(O)
> + BUILD := $(O)/kselftest
> else
> ifneq ($(KBUILD_OUTPUT),)
> BUILD := $(KBUILD_OUTPUT)/kselftest
> --
> 2.20.1