mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas@t-8ch.de>
To: Zhangjin Wu <falcon@tinylab.org>
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, tanyuan@tinylab.org, w@1wt.eu
Subject: Re: [PATCH v1 2/3] selftests/nolibc: fix up O= option support
Date: Fri, 4 Aug 2023 17:05:06 +0200	[thread overview]
Message-ID: <058a264d-45bd-4f1f-8af3-56ed337b3251@t-8ch.de> (raw)
In-Reply-To: <20230804074342.28248-1-falcon@tinylab.org>

On 2023-08-04 15:43:42+0800, Zhangjin Wu wrote:
> Hi, Thomas
> 
> > On 2023-08-03 22:45:52+0800, Zhangjin Wu wrote:
> > > To avoid pollute the source code tree and avoid mrproper for every
> > > architecture switch, the O= argument must be supported.
> > > 
> > > Both IMAGE and .config are from the building directory, let's use
> > > objtree instead of srctree for them.
> > > 
> > > If no O= option specified, means building kernel in source code tree,
> > > objtree should be srctree in such case.
> > > 
> > > Suggested-by: Willy Tarreau <w@1wt.eu>
> > > Link: https://lore.kernel.org/lkml/ZK0AB1OXH1s2xYsh@1wt.eu/
> > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> > > ---
> > >  tools/testing/selftests/nolibc/Makefile | 7 +++++--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> > > index 51fef5e6a152..af590aee063a 100644
> > > --- a/tools/testing/selftests/nolibc/Makefile
> > > +++ b/tools/testing/selftests/nolibc/Makefile
> > > @@ -9,6 +9,9 @@ ifeq ($(srctree),)
> > >  srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR)))
> > >  endif
> > >  
> > > +# add objtree for O= argument, required by IMAGE and .config
> > > +objtree ?= $(srctree)
> > 
> > Isn't this already set by the included tools/scripts/Makefile.include?
> >
> 
> Good question, but it is empty if no O= specified, checked it several
> times before ;-)

For me it is not empty when I am in tools/testing/selftests/nolibc/.

> > Also I'm not entirely if O= works as intended currently.
> > When using O=foo in the $LINUX/tools/testing/selftests/nolibc directory
> 
> It does work, I have used it to test all of the run targets of the
> tinyconfig patches like this:
> 
>     $ make run O=kernel-$arch RUN_OUT=run.$arch.out ...
> 
> Everything about the kernel will be built in $(O).

It does not work for me:

$ cd $HOME/src/linux/tools/testing/selftests/nolibc
$ make O=out kernel
../../../scripts/Makefile.include:4: *** O=out does not exist.  Stop.
$ mkdir out
$ make O=out kernel
... Stuff happens
... all the output is in $HOME/src/linux/out not in
    tools/testing/selftests/nolibc/out where I would expect it.
    The new out directory for which an error was reported before is
    completely empty.

> Just rechecked the O variable in top-level Makefile, selftests/nolibc Makefile
> and tools/nolibc Makefile, all of them get the right O value from command line.

But the one from the command line is a relative path. And it seems to be
resolved from the kernel source tree instead of from where make is
executed.

> From my Makefile experience, an option from command line will be passed
> to every sub Makefile via $(-*-command-variables-*-), it has the highest
> priority then the others, except when we use 'override' keyword
> internally.
> 
> > the build instead is happening in $LINUX/foo. But the Makefile first
> > validates that $LINUX/tools/testing/selftests/nolibc/foo exists.
> >
> 
> Sorry, I didn't get your meaning above?
> 
> Do you mean this line:
> 
>     srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR)))
> 
> by removing tools/testing/selftests/ of curdir's dir (means no nolibc itself),
> srctree above is just the top-level kernel source code tree.

No, srctree should be fine.

> > It seems we need to pass $(COMMAND_O) to the recursive calls to $(MAKE),
> > too?
> >
> 
> So, no need to pass O or COMMAND_O.

As above, it doesn't work for me.

If I add COMMAND_O to all the $(MAKE) commands that are executed
explicitly, how it is also done in Makefile.include itself, things start
to work as I would expect:
All the kernel build output is in out/ in the current directory.

> Thanks,
> Zhangjin
> 
> > > +
> > >  ifeq ($(ARCH),)
> > >  include $(srctree)/scripts/subarch.include
> > >  ARCH = $(SUBARCH)
> > > @@ -217,12 +220,12 @@ kernel: initramfs
> > >  
> > >  # run the tests after building the kernel
> > >  run: kernel
> > > -	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
> > > +	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(objtree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
> > >  	$(Q)$(REPORT) $(CURDIR)/run.out
> > >  
> > >  # re-run the tests from an existing kernel
> > >  rerun:
> > > -	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
> > > +	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(objtree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
> > >  	$(Q)$(REPORT) $(CURDIR)/run.out
> > >  
> > >  # report with existing test log
> > > -- 
> > > 2.25.1
> > > 

  reply	other threads:[~2023-08-04 15:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 14:43 [PATCH v1 0/3] selftests/nolibc: add misc improvments Zhangjin Wu
2023-08-03 14:44 ` [PATCH v1 1/3] selftests/nolibc: allow report with existing test log Zhangjin Wu
2023-08-04 15:30   ` Thomas Weißschuh
2023-08-03 14:45 ` [PATCH v1 2/3] selftests/nolibc: fix up O= option support Zhangjin Wu
2023-08-04  6:25   ` Thomas Weißschuh
2023-08-04  7:43     ` Zhangjin Wu
2023-08-04 15:05       ` Thomas Weißschuh [this message]
2023-08-04 15:52         ` Zhangjin Wu
2023-08-04 16:02           ` Thomas Weißschuh
2023-08-04 16:29             ` Zhangjin Wu
2023-08-04 17:51               ` Thomas Weißschuh
2023-08-04 17:54                 ` Willy Tarreau
2023-08-04 18:40                   ` Zhangjin Wu
2023-08-04 18:43                     ` Willy Tarreau
2023-08-04 19:17                       ` Zhangjin Wu
2023-08-03 14:47 ` [PATCH v1 3/3] tools/nolibc: stackprotector.h: make __stack_chk_init static Zhangjin Wu
2023-08-04 15:38   ` Thomas Weißschuh

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=058a264d-45bd-4f1f-8af3-56ed337b3251@t-8ch.de \
    --to=thomas@t-8ch.de \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=tanyuan@tinylab.org \
    --cc=w@1wt.eu \
    /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

all inboxes | Powered by JetHome®