diff mbox series

[4/5] selftests/nolibc: support out-of-tree builds

Message ID 20231010-nolibc-out-of-tree-v1-4-b6a263859596@weissschuh.net (mailing list archive)
State Accepted
Commit 69620b3a5bc5e6798724ab9bf0dd1b3c980a4949
Headers show
Series selftests/nolibc: various build improvements | expand

Commit Message

Thomas Weißschuh Oct. 10, 2023, 12:33 p.m. UTC
Out of tree builds are much more convenient when building for multiple
architectures or configurations in parallel.

Only absolute O= parameters are supported as Makefile.include will
always resolve relative paths in relation to $(srctree) instead of the
current directory.

Add a call to "make outputmakefile" to verify that the sourcetree is
clean.

This is based on Zhangjins out-of-tree patch.
It extends that work for get_init_cpio support and also drops relative
O= specifications explicitly.

Link: https://lore.kernel.org/lkml/06d96bd81fe812a9718098a383678ad3beba98b1.1691215074.git.falcon@tinylab.org/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/testing/selftests/nolibc/Makefile | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Comments

Willy Tarreau Oct. 22, 2023, 9:31 a.m. UTC | #1
On Tue, Oct 10, 2023 at 02:33:59PM +0200, Thomas Weißschuh wrote:
> Out of tree builds are much more convenient when building for multiple
> architectures or configurations in parallel.
> 
> Only absolute O= parameters are supported as Makefile.include will
> always resolve relative paths in relation to $(srctree) instead of the
> current directory.
> 
> Add a call to "make outputmakefile" to verify that the sourcetree is
> clean.

At first this worried me, I thought you meant clean in the git meaning,
but it's clean as in "make clean" from what I'm seeing. Yeah that sounds
reasonable.

> This is based on Zhangjins out-of-tree patch.
> It extends that work for get_init_cpio support and also drops relative
> O= specifications explicitly.

Yeah I remember these discussions about these shortcomings, that's
pretty reasonable.

> Link: https://lore.kernel.org/lkml/06d96bd81fe812a9718098a383678ad3beba98b1.1691215074.git.falcon@tinylab.org/
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
(...)

I think you should add a Suggested-by at least since Zhangjin attempted
that work quite a few times already and allowed to make progress in that
direction (maybe even co-developed, I'm not sure).

Acked-by: Willy Tarreau <w@1wt.eu>
Willy
Thomas Weißschuh Oct. 24, 2023, 4:09 p.m. UTC | #2
Oct 22, 2023 11:31:32 Willy Tarreau <w@1wt.eu>:

> On Tue, Oct 10, 2023 at 02:33:59PM +0200, Thomas Weißschuh wrote:
>> Out of tree builds are much more convenient when building for multiple
>> architectures or configurations in parallel.
>>
>> Only absolute O= parameters are supported as Makefile.include will
>> always resolve relative paths in relation to $(srctree) instead of the
>> current directory.
>>
>> Add a call to "make outputmakefile" to verify that the sourcetree is
>> clean.
>
> At first this worried me, I thought you meant clean in the git meaning,
> but it's clean as in "make clean" from what I'm seeing. Yeah that sounds
> reasonable.
>
>> This is based on Zhangjins out-of-tree patch.
>> It extends that work for get_init_cpio support and also drops relative
>> O= specifications explicitly.
>
> Yeah I remember these discussions about these shortcomings, that's
> pretty reasonable.
>
>> Link: https://lore.kernel.org/lkml/06d96bd81fe812a9718098a383678ad3beba98b1.1691215074.git.falcon@tinylab.org/
>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> (...)
>
> I think you should add a Suggested-by at least since Zhangjin attempted
> that work quite a few times already and allowed to make progress in that
> direction (maybe even co-developed, I'm not sure).

Indeed. For a proper Co-developed-by I also need
a Signed-off-by by Zhangjin.

Zhangjin, are you fine with giving me one for this
patch?

> Acked-by: Willy Tarreau <w@1wt.eu>

Thanks!
Zhangjin Wu Oct. 26, 2023, 5:50 p.m. UTC | #3
Hi, Thomas

> Oct 22, 2023 11:31:32 Willy Tarreau <w@1wt.eu>:
> 
> > (...)
> >
> > I think you should add a Suggested-by at least since Zhangjin attempted
> > that work quite a few times already and allowed to make progress in that
> > direction (maybe even co-developed, I'm not sure).
> 
> Indeed. For a proper Co-developed-by I also need
> a Signed-off-by by Zhangjin.
> 
> Zhangjin, are you fine with giving me one for this
> patch?
>

It is ok for me, thanks very much to make it really works!

BR,
Zhangjin Wu

> > Acked-by: Willy Tarreau <w@1wt.eu>
> 
> Thanks!
diff mbox series

Patch

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 598d53c5cb7b..21e3f7da2ecf 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -1,9 +1,16 @@ 
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for nolibc tests
 include ../../../scripts/Makefile.include
+include ../../../scripts/utilities.mak
 # We need this for the "cc-option" macro.
 include ../../../build/Build.include
 
+ifneq ($(O),)
+ifneq ($(call is-absolute,$(O)),y)
+$(error Only absolute O= parameters are supported)
+endif
+endif
+
 # we're in ".../tools/testing/selftests/nolibc"
 ifeq ($(srctree),)
 srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR)))
@@ -14,6 +21,8 @@  include $(srctree)/scripts/subarch.include
 ARCH = $(SUBARCH)
 endif
 
+objtree ?= $(srctree)
+
 # XARCH extends the kernel's ARCH with a few variants of the same
 # architecture that only differ by the configuration, the toolchain
 # and the Qemu program used. It is copied as-is into ARCH except for
@@ -52,7 +61,7 @@  IMAGE_ppc64le    = arch/powerpc/boot/zImage
 IMAGE_riscv      = arch/riscv/boot/Image
 IMAGE_s390       = arch/s390/boot/bzImage
 IMAGE_loongarch  = arch/loongarch/boot/vmlinuz.efi
-IMAGE            = $(IMAGE_$(XARCH))
+IMAGE            = $(objtree)/$(IMAGE_$(XARCH))
 IMAGE_NAME       = $(notdir $(IMAGE))
 
 # default kernel configurations that appear to be usable
@@ -167,6 +176,7 @@  sysroot: sysroot/$(ARCH)/include
 sysroot/$(ARCH)/include:
 	$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
 	$(QUIET_MKDIR)mkdir -p sysroot
+	$(Q)$(MAKE) -C $(srctree) outputmakefile
 	$(Q)$(MAKE) -C $(srctree)/tools/include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
 	$(Q)mv sysroot/sysroot sysroot/$(ARCH)
 
@@ -199,7 +209,7 @@  run-user: nolibc-test
 	$(Q)$(REPORT) $(CURDIR)/run.out
 
 initramfs.cpio: kernel nolibc-test
-	$(QUIET_GEN)echo 'file /init nolibc-test 755 0 0' | $(srctree)/usr/gen_init_cpio - > initramfs.cpio
+	$(QUIET_GEN)echo 'file /init nolibc-test 755 0 0' | $(objtree)/usr/gen_init_cpio - > initramfs.cpio
 
 initramfs: nolibc-test
 	$(QUIET_MKDIR)mkdir -p initramfs
@@ -217,12 +227,12 @@  kernel-standalone: initramfs
 
 # run the tests after building the kernel
 run: kernel initramfs.cpio
-	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
+	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -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)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
+	$(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
 	$(Q)$(REPORT) $(CURDIR)/run.out
 
 # report with existing test log