linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: "Bird, Tim" <Tim.Bird@sony.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	"shuah@kernel.org" <shuah@kernel.org>,
	"bamv2005@gmail.com" <bamv2005@gmail.com>,
	"khilman@baylibre.com" <khilman@baylibre.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests: add build/cross-build dependency check script
Date: Fri, 24 Apr 2020 12:29:09 -0600	[thread overview]
Message-ID: <177a6b62-630d-7b30-dbb6-7e6ca7054790@linuxfoundation.org> (raw)
In-Reply-To: <CY4PR13MB1527A6A6F9BCEADAF14A3C6BFDD00@CY4PR13MB1527.namprd13.prod.outlook.com>

On 4/24/20 11:28 AM, Bird, Tim wrote:
>> -----Original Message-----
>> From: linux-kselftest-owner@vger.kernel.org <linux-kselftest-owner@vger.kernel.org> On Behalf Of Randy Dunlap
>>
>> On 4/14/20 2:22 PM, Shuah Khan wrote:
>>> -CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(MOUNT_CFLAGS)
>>> -LDLIBS += $(MOUNT_LDLIBS)
>>> +CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(VAR_CFLAGS)
>>> +LDLIBS += $(VAR_LDLIBS)
>>
>>
>> (1) Can that series of ../../../.. be replaced by $(objtree)?
>> If so, that would be much cleaner IMO.
> 
> kselftests doesn't set $(objtree) when it is run directly
> (ie make -C tools/testing/selftests)
> 
> I had my own solution which was to use KBUILD_OUTPUT, like so:
> This was a patch in my queue, that I didn't send in because I wasn't
> very happy with it.  I was still considering alternatives.
> 
> ---------------- (patch)
> Subject: [PATCH] selftests/vm: use includes from KBUILD_OUTPUT directory
> 
> The Makefile for the vm tests was specifying a relative path
> (in the source directory) for accessing include files.  This
> doesn't work when the headers files are placed in another
> directory (with O= or KBUILD_OUTPUT).  It may appear to work,
> but ends up using includes from the host machine, which may
> not match the kernel source being compiled against.
> 
> Without this change, when the program userfaultfd.c was
> compiled, it generated errors like the following:
> 
>      userfaultfd.c:267:21: error: 'UFFD_API_RANGE_IOCTLS_BASIC' undeclared
>      here (not in a function)
>        .expected_ioctls = UFFD_API_RANGE_IOCTLS_BASIC,
>                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>      userfaultfd.c: In function 'uffd_poll_thread':
>      userfaultfd.c:529:8: error: 'UFFD_EVENT_FORK' undeclared (first use in
>      this function)
>         case UFFD_EVENT_FORK:
>              ^~~~~~~~~~~~~~~
>      userfaultfd.c:529:8: note: each undeclared identifier is reported only
>      once for each function it appears in
>      userfaultfd.c:531:18: error: 'union <anonymous>' has no member named
>      'fork'
>          uffd = msg.arg.fork.ufd;
>                        ^
> 
> Change the CFLAGS definition in the Makefile to reference
> KBUILD_OUTPUT.
> 
> Signed-off-by: Tim Bird <tim.bird@sony.com>
> ---
>   tools/testing/selftests/vm/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index 7f9a8a8..0208659 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -3,7 +3,7 @@
>   uname_M := $(shell uname -m 2>/dev/null || echo not)
>   ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/')
>   
> -CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
> +CFLAGS = -Wall -I $(KBUILD_OUTPUT)/usr/include $(EXTRA_CFLAGS)
>   LDLIBS = -lrt
>   TEST_GEN_FILES = compaction_test
>   TEST_GEN_FILES += gup_benchmark
> 

This should be $(OUTPUT) instead of $(KBUILD_OUTPUT). OUTPUT is
set by selftests Makefile and lib.mk which is common for all
tests even when make -C is used for compile.

Using KBUILD_OUTPUT will break other use-cases.

Send me the patch when you are ready.

kselftest Makefile invokes headers_install from the main Makefile.

This sequence doesn't install headers again when kselftest make
is done:

Main directory:
# make headers_install
[headers_install runs]

# make headers_install
INSTALL ./usr/include
[does nothing - headers are there]

make kselftest-all
make --no-builtin-rules ARCH=x86 -C ../../.. headers_install
make[2]: Entering directory '/home/shuah/lkml/linux_5.7'
   INSTALL ./usr/include

[Same here - headers aren't installed]

I didn't check O= and KBUILD_OUTPUT cases though.

thanks,
-- Shuah

      reply	other threads:[~2020-04-24 18:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 21:22 [PATCH] selftests: add build/cross-build dependency check script Shuah Khan
2020-04-24  3:25 ` Randy Dunlap
2020-04-24 13:51   ` Shuah Khan
2020-04-24 17:28   ` Bird, Tim
2020-04-24 18:29     ` Shuah Khan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=177a6b62-630d-7b30-dbb6-7e6ca7054790@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=Tim.Bird@sony.com \
    --cc=bamv2005@gmail.com \
    --cc=khilman@baylibre.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).