linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bug in KBUILD_OUTPUT handling - for relative paths in kselftest
@ 2019-09-26  4:11 Tim.Bird
  2019-09-26 17:42 ` shuah
  0 siblings, 1 reply; 2+ messages in thread
From: Tim.Bird @ 2019-09-26  4:11 UTC (permalink / raw)
  To: linux-kselftest; +Cc: linux-kernel

I found a bug in kselftest KBUILD_OUTPUT handling.

The following works:
$ cd /home/tbird/work/linux
$ export KBUILD_OUTPUT=/home/tbird/work/kbuild
$ yes '' | make localmodconfig
$ make TARGETS=size kselftest

But this doesn't work:
$ cd /home/tbird/work/linux
$ export KBUILD_OUTPUT=../kbuild
$ yes '' | make localmodconfig
$ make TARGETS=size kselftest

I see the following:
make[1]: Entering directory '/home/tbird/work/kbuild'
 make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \
 	ARCH=x86 -C ../../.. headers_install
   INSTALL ../kbuild/kselftest/usr/include
 gcc -static -ffreestanding -nostartfiles -s    get_size.c  -o ../kbuild/kselftest/size/get_size
   /usr/bin/ld: cannot open output file ../kbuild/kselftest/size/get_size: No such file or directory
 collect2: error: ld returned 1 exit status
   ../lib.mk:138: recipe for target '../kbuild/kselftest/size/get_size' failed
 make[3]: *** [../kbuild/kselftest/size/get_size] Error 1
 Makefile:136: recipe for target 'all' failed
 make[2]: *** [all] Error 2
 /home/tbird/work/linux/Makefile:1240: recipe for target 'kselftest' failed
 make[1]: *** [kselftest] Error 2
 make[1]: Leaving directory '/home/tbird/work/kbuild'
 Makefile:179: recipe for target 'sub-make' failed
 make: *** [sub-make] Error 2

This is due to the relative path for KBUILD_OUTPUT being handled incorrectly (I believe)
in tools/testing/selftests/Makefile.

There are these lines in the Makefile, which are responsible for creating the output
directory:
    BUILD_TARGET=$$BUILD/$$TARGET
    mkdir $$BUILD_TARGET -p

But these are executed from working directory tools/testing/selftests,
so the 'size' directory gets created at tools/testing/kbuild/kselftest/size,
instead of /home/tbird/work/kbuild/kselftest/size.

I can add some code to the Makefile to change the assignment of the
variable BUILD, so that if it is a relative path it is relative to $(top_srcdir)
instead of the current directory.   But I wanted to check and make sure that
I'm not  breaking anyone else's workflow.

I'm not sure what the expectation would be for someone who did this:
 $ export KBUILD_OUTPUT=../kbuild ; make  -C tools/testing/selftests run_tests

But I assume if someone is running the kernel's 'make' from the top-level
kernel source directory, and they have a relative KBUILD_OUTPUT directory,
then they want that output directory to be relative to the top-level directory
and not somewhere else.

Should I just code up something for review?

I use relative KBUILD_OUTPUT paths for a number of my kernel build scripts,
and right now these are incompatible with kselftests.

Thanks,
 -- Tim


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bug in KBUILD_OUTPUT handling - for relative paths in kselftest
  2019-09-26  4:11 bug in KBUILD_OUTPUT handling - for relative paths in kselftest Tim.Bird
@ 2019-09-26 17:42 ` shuah
  0 siblings, 0 replies; 2+ messages in thread
From: shuah @ 2019-09-26 17:42 UTC (permalink / raw)
  To: Tim.Bird, linux-kselftest; +Cc: linux-kernel, shuah

On 9/25/19 10:11 PM, Tim.Bird@sony.com wrote:
> I found a bug in kselftest KBUILD_OUTPUT handling.
> 
> The following works:
> $ cd /home/tbird/work/linux
> $ export KBUILD_OUTPUT=/home/tbird/work/kbuild
> $ yes '' | make localmodconfig
> $ make TARGETS=size kselftest
> 
> But this doesn't work:
> $ cd /home/tbird/work/linux
> $ export KBUILD_OUTPUT=../kbuild
> $ yes '' | make localmodconfig
> $ make TARGETS=size kselftest
> 
> I see the following:
> make[1]: Entering directory '/home/tbird/work/kbuild'
>   make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \
>   	ARCH=x86 -C ../../.. headers_install
>     INSTALL ../kbuild/kselftest/usr/include
>   gcc -static -ffreestanding -nostartfiles -s    get_size.c  -o ../kbuild/kselftest/size/get_size
>     /usr/bin/ld: cannot open output file ../kbuild/kselftest/size/get_size: No such file or directory
>   collect2: error: ld returned 1 exit status
>     ../lib.mk:138: recipe for target '../kbuild/kselftest/size/get_size' failed
>   make[3]: *** [../kbuild/kselftest/size/get_size] Error 1
>   Makefile:136: recipe for target 'all' failed
>   make[2]: *** [all] Error 2
>   /home/tbird/work/linux/Makefile:1240: recipe for target 'kselftest' failed
>   make[1]: *** [kselftest] Error 2
>   make[1]: Leaving directory '/home/tbird/work/kbuild'
>   Makefile:179: recipe for target 'sub-make' failed
>   make: *** [sub-make] Error 2
> 
> This is due to the relative path for KBUILD_OUTPUT being handled incorrectly (I believe)
> in tools/testing/selftests/Makefile.
> 

Thanks Tim! I will take a look as part of my work to simplify kselftest
use-cases.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-26 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-26  4:11 bug in KBUILD_OUTPUT handling - for relative paths in kselftest Tim.Bird
2019-09-26 17:42 ` shuah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).