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 19:51:50 +0200	[thread overview]
Message-ID: <d909cf7d-a7b0-4830-89cf-64e8980c4c32@t-8ch.de> (raw)
In-Reply-To: <20230804162910.305533-1-falcon@tinylab.org>

On 2023-08-05 00:29:10+0800, Zhangjin Wu wrote:
> > On 2023-08-04 23:52:18+0800, Zhangjin Wu wrote:
> > > > 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/.
> > > >
> > > 
> > > Interesting, here is the code I added to check the value:
> > > 
> > >     diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> > >     index 22f1e1d73fa8..1ae19e896e24 100644
> > >     --- a/tools/testing/selftests/nolibc/Makefile
> > >     +++ b/tools/testing/selftests/nolibc/Makefile
> > >     @@ -12,6 +12,8 @@ include $(srctree)/scripts/subarch.include
> > >      ARCH = $(SUBARCH)
> > >      endif
> > >     
> > >     +$(error objtree=$(objtree), srctree=$(srctree))
> > >     +
> > > 
> > > Whenever I do defconfig or run,
> > > 
> > >     $ make help
> > >     Makefile:15: *** objtree=, srctree=/labs/linux-lab/src/linux-stable.  Stop.
> > > 
> > > It is only not empty when we pass O explicitly:
> > > 
> > >     $ mkdir out
> > >     $ make help O=out
> > >     Makefile:15: *** objtree=out, srctree=/labs/linux-lab/src/linux-stable.  Stop.
> > >     $ make help O=$PWD/out
> > >     Makefile:15: *** objtree=/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/out, srctree=/labs/linux-lab/src/linux-stable.  Stop.
> > 
> > Welp, now it's the same for me.
> > I guess I messed it up before, maybe I forgot to remove your changes
> > while testing?
> > 
> > Anyways instead of having to manually do stuff with $(objtree) we could
> > also use $(OUTPUT)$(IMAGE) to always get the correct image.
> >
> 
> Do you mean here?
> 
>     # kernel image names by architecture
>     IMAGE_i386    = arch/x86/boot/bzImage
>     IMAGE_x86     = arch/x86/boot/bzImage
>     IMAGE_arm64   = arch/arm64/boot/Image
>     IMAGE_arm     = arch/arm/boot/zImage
>     IMAGE_mips    = vmlinuz
>     IMAGE_riscv   = arch/riscv/boot/Image
>     IMAGE         = $(IMAGE_$(ARCH))
>     IMAGE_NAME    = $(notdir $(IMAGE))
> 
> It does save another KERNEL_IMAGE macro in my future patch ;-)
> 
> But without O=, OUTPUT is also empty like objtree and when empty, it is
> assigned as $(CURDIR), not $(srctree) as we expected for IMAGE and .config. To
> be cleaner, objtree should also be used:
> 
>     - IMAGE         = $(IMAGE_$(ARCH))
>     + IMAGE         = $(objtree)/$(IMAGE_$(ARCH))
> 
> Is this what you want?

More like:

-	$(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 "$(OUTPUT)$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"

My assumption was that it's weird that we need to define such variables
ourselves.

Using an empty $(OUTPUT) would have been fine if make is run from the
root of the kernel tree. But that is not the case.

It still feels weird but I can't think of a nicer way, and it's not
a big issue. So let's keep that part the same.

Or maybe Willy has a better idea.

  reply	other threads:[~2023-08-04 17:52 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
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 [this message]
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=d909cf7d-a7b0-4830-89cf-64e8980c4c32@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®