* [PATCH v2 0/3] selftests/nolibc: add misc improvments
@ 2023-08-05 6:09 Zhangjin Wu
2023-08-05 6:11 ` [PATCH v2 1/3] selftests/nolibc: allow report with existing test log Zhangjin Wu
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Zhangjin Wu @ 2023-08-05 6:09 UTC (permalink / raw)
To: thomas, w; +Cc: falcon, arnd, linux-kernel, linux-kselftest
Hi, Willy, Hi Thomas
Based on Thomas' suggestion, V2 comes here with relative path support
for O= option, v1 is [1].
// subdir
$ pwd
/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc
$ mkdir -p out
$ make run-user O=out -C /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/ -j4 | grep status
Makefile:122: srctree=/labs/linux-lab/src/linux-stable
Makefile:123: objtree: out
Makefile:124: COMMAND_O: O=/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/out
Makefile:125: OUTPUT=/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/out/
166 test(s): 158 passed, 8 skipped, 0 failed => status: warning
// topdir
$ pwd
/labs/linux-lab/src/linux-stable
$ mkdir -p out
$ make run-user O=out -C /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/ -j4 | grep status
Makefile:122: srctree=/labs/linux-lab/src/linux-stable
Makefile:123: objtree: out
Makefile:124: COMMAND_O: O=/labs/linux-lab/src/linux-stable/out
Makefile:125: OUTPUT=/labs/linux-lab/src/linux-stable/out/
166 test(s): 158 passed, 8 skipped, 0 failed => status: warning
// outside
$ pwd
/labs/linux-lab/build
$ mkdir -p out
$ make run-user O=out -C /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/ -j4 | grep status
Makefile:122: srctree=/labs/linux-lab/src/linux-stable
Makefile:123: objtree: out
Makefile:124: COMMAND_O: O=/labs/linux-lab/build/out
Makefile:125: OUTPUT=/labs/linux-lab/build/out/
166 test(s): 158 passed, 8 skipped, 0 failed => status: warning
Changes from v1 --> v2:
* selftests/nolibc: allow report with existing test log
tools/nolibc: stackprotector.h: make __stack_chk_init static
Add Reviewed-by line from Thomas
* selftests/nolibc: fix up O= option support
Now with relative path support with the help of $(COMMAND_O).
Suggested by Thomas.
Thanks!
Zhangjin
---
[1]: https://lore.kernel.org/lkml/cover.1691073180.git.falcon@tinylab.org/
Zhangjin Wu (3):
selftests/nolibc: allow report with existing test log
tools/nolibc: stackprotector.h: make __stack_chk_init static
selftests/nolibc: fix up O= option support
tools/include/nolibc/crt.h | 2 +-
tools/include/nolibc/stackprotector.h | 5 ++---
tools/testing/selftests/nolibc/Makefile | 19 +++++++++++++------
3 files changed, 16 insertions(+), 10 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v2 1/3] selftests/nolibc: allow report with existing test log 2023-08-05 6:09 [PATCH v2 0/3] selftests/nolibc: add misc improvments Zhangjin Wu @ 2023-08-05 6:11 ` Zhangjin Wu 2023-08-05 6:12 ` [PATCH v2 2/3] tools/nolibc: stackprotector.h: make __stack_chk_init static Zhangjin Wu 2023-08-05 6:13 ` [PATCH v2 3/3] selftests/nolibc: fix up O= option support Zhangjin Wu 2 siblings, 0 replies; 9+ messages in thread From: Zhangjin Wu @ 2023-08-05 6:11 UTC (permalink / raw) To: thomas, w Cc: falcon, arnd, linux-kernel, linux-kselftest, Thomas Weißschuh After the tests finish, it is valuable to report and summarize with existing test log. This avoid rerun or run the tests again when not necessary. Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/testing/selftests/nolibc/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 16cc33db54e3..51fef5e6a152 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -225,6 +225,10 @@ rerun: $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(REPORT) $(CURDIR)/run.out +# report with existing test log +report: + $(Q)$(REPORT) $(CURDIR)/run.out + clean: $(call QUIET_CLEAN, sysroot) $(Q)rm -rf sysroot -- 2.25.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] tools/nolibc: stackprotector.h: make __stack_chk_init static 2023-08-05 6:09 [PATCH v2 0/3] selftests/nolibc: add misc improvments Zhangjin Wu 2023-08-05 6:11 ` [PATCH v2 1/3] selftests/nolibc: allow report with existing test log Zhangjin Wu @ 2023-08-05 6:12 ` Zhangjin Wu 2023-08-05 6:13 ` [PATCH v2 3/3] selftests/nolibc: fix up O= option support Zhangjin Wu 2 siblings, 0 replies; 9+ messages in thread From: Zhangjin Wu @ 2023-08-05 6:12 UTC (permalink / raw) To: thomas, w Cc: falcon, arnd, linux-kernel, linux-kselftest, Thomas Weißschuh This allows to generate smaller text/data/dec size. As the _start_c() function added by crt.h, __stack_chk_init() is called from _start_c() instead of the assembly _start. So, it is able to mark it with static now. Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/include/nolibc/crt.h | 2 +- tools/include/nolibc/stackprotector.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h index 32e128b0fb62..a5f33fef1672 100644 --- a/tools/include/nolibc/crt.h +++ b/tools/include/nolibc/crt.h @@ -10,7 +10,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -void __stack_chk_init(void); +static void __stack_chk_init(void); static void exit(int); void _start_c(long *sp) diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index b620f2b9578d..13f1d0e60387 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -37,8 +37,7 @@ void __stack_chk_fail_local(void) __attribute__((weak,section(".data.nolibc_stack_chk"))) uintptr_t __stack_chk_guard; -__attribute__((weak,section(".text.nolibc_stack_chk"))) __no_stack_protector -void __stack_chk_init(void) +static __no_stack_protector void __stack_chk_init(void) { my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); /* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */ @@ -46,7 +45,7 @@ void __stack_chk_init(void) __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; } #else /* !defined(_NOLIBC_STACKPROTECTOR) */ -__inline__ void __stack_chk_init(void) {} +static void __stack_chk_init(void) {} #endif /* defined(_NOLIBC_STACKPROTECTOR) */ #endif /* _NOLIBC_STACKPROTECTOR_H */ -- 2.25.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] selftests/nolibc: fix up O= option support 2023-08-05 6:09 [PATCH v2 0/3] selftests/nolibc: add misc improvments Zhangjin Wu 2023-08-05 6:11 ` [PATCH v2 1/3] selftests/nolibc: allow report with existing test log Zhangjin Wu 2023-08-05 6:12 ` [PATCH v2 2/3] tools/nolibc: stackprotector.h: make __stack_chk_init static Zhangjin Wu @ 2023-08-05 6:13 ` Zhangjin Wu 2023-08-06 11:21 ` Willy Tarreau 2 siblings, 1 reply; 9+ messages in thread From: Zhangjin Wu @ 2023-08-05 6:13 UTC (permalink / raw) To: thomas, w Cc: falcon, arnd, linux-kernel, linux-kselftest, Thomas Weißschuh 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. To support relative path, as suggested by Thomas, $(COMMAND_O) is used to pass the O=$(ABSOLUTE_O) to the $(MAKE) commands. Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/lkml/ZK0AB1OXH1s2xYsh@1wt.eu/ Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/lkml/058a264d-45bd-4f1f-8af3-56ed337b3251@t-8ch.de/ Link: https://lore.kernel.org/lkml/500504f6-fed1-45a4-a518-4631a6f3e463@t-8ch.de/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> --- tools/testing/selftests/nolibc/Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 51fef5e6a152..20797ba5d393 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= option, required by IMAGE and .config +objtree ?= $(srctree) + ifeq ($(ARCH),) include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) @@ -52,7 +55,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)) # CROSS_COMPILE: cross toolchain prefix by architecture @@ -173,7 +176,7 @@ sysroot: sysroot/$(ARCH)/include sysroot/$(ARCH)/include: $(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot $(QUIET_MKDIR)mkdir -p sysroot - $(Q)$(MAKE) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone + $(Q)$(MAKE) -C ../../../include/nolibc $(COMMAND_O) ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone $(Q)mv sysroot/sysroot sysroot/$(ARCH) ifneq ($(NOLIBC_SYSROOT),0) @@ -210,19 +213,19 @@ initramfs: nolibc-test $(Q)cp nolibc-test initramfs/init defconfig: - $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare + $(Q)$(MAKE) -C $(srctree) $(COMMAND_O) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare kernel: initramfs - $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs + $(Q)$(MAKE) -C $(srctree) $(COMMAND_O) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/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 "$(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 "$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(REPORT) $(CURDIR)/run.out # report with existing test log -- 2.25.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] selftests/nolibc: fix up O= option support 2023-08-05 6:13 ` [PATCH v2 3/3] selftests/nolibc: fix up O= option support Zhangjin Wu @ 2023-08-06 11:21 ` Willy Tarreau 2023-08-06 12:17 ` Zhangjin Wu 0 siblings, 1 reply; 9+ messages in thread From: Willy Tarreau @ 2023-08-06 11:21 UTC (permalink / raw) To: Zhangjin Wu Cc: thomas, arnd, linux-kernel, linux-kselftest, Thomas Weißschuh On Sat, Aug 05, 2023 at 02:13:11PM +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. > > To support relative path, as suggested by Thomas, $(COMMAND_O) is used > to pass the O=$(ABSOLUTE_O) to the $(MAKE) commands. Zhangjin, I cannot get this one to work, regardless of what I try: $ make -j8 O=$PWD/output-i386 nolibc-test XARCH=i386 CROSS_COMPILE=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux- CC=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux-gcc (...) CC nolibc-test In file included from sysroot/i386/include/stdio.h:14, from nolibc-test.c:13: sysroot/i386/include/errno.h:10:10: fatal error: asm/errno.h: No such file or directory 10 | #include <asm/errno.h> | ^~~~~~~~~~~~~ compilation terminated. I'll leave it aside for now as I've spent way longer than I hoped on these series. I could take the previous two patches however. Thanks, Willy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] selftests/nolibc: fix up O= option support 2023-08-06 11:21 ` Willy Tarreau @ 2023-08-06 12:17 ` Zhangjin Wu 2023-08-26 4:30 ` Zhangjin Wu 0 siblings, 1 reply; 9+ messages in thread From: Zhangjin Wu @ 2023-08-06 12:17 UTC (permalink / raw) To: w; +Cc: arnd, falcon, linux-kernel, linux-kselftest, linux, thomas > On Sat, Aug 05, 2023 at 02:13:11PM +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. > > > > To support relative path, as suggested by Thomas, $(COMMAND_O) is used > > to pass the O=$(ABSOLUTE_O) to the $(MAKE) commands. > > Zhangjin, I cannot get this one to work, regardless of what I try: > > $ make -j8 O=$PWD/output-i386 nolibc-test XARCH=i386 CROSS_COMPILE=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux- CC=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux-gcc > (...) > CC nolibc-test > In file included from sysroot/i386/include/stdio.h:14, > from nolibc-test.c:13: > sysroot/i386/include/errno.h:10:10: fatal error: asm/errno.h: No such file or directory > 10 | #include <asm/errno.h> > | ^~~~~~~~~~~~~ > compilation terminated. > Willy, I also just reproduced the issue, seems only i386 sysroot has no asm/errno.h, will check why it is no rightly installed later. $ find sysroot/ -name "errno.h" sysroot/arm/include/errno.h sysroot/arm/include/asm-generic/errno.h sysroot/arm/include/asm/errno.h sysroot/arm/include/linux/errno.h sysroot/riscv/include/errno.h sysroot/riscv/include/asm-generic/errno.h sysroot/riscv/include/asm/errno.h sysroot/riscv/include/linux/errno.h sysroot/s390/include/errno.h sysroot/s390/include/asm-generic/errno.h sysroot/s390/include/asm/errno.h sysroot/s390/include/linux/errno.h sysroot/arm64/include/errno.h sysroot/arm64/include/asm-generic/errno.h sysroot/arm64/include/asm/errno.h sysroot/arm64/include/linux/errno.h sysroot/mips/include/errno.h sysroot/mips/include/asm-generic/errno.h sysroot/mips/include/asm/errno.h sysroot/mips/include/linux/errno.h sysroot/x86_64/include/errno.h sysroot/x86_64/include/asm-generic/errno.h sysroot/x86_64/include/asm/errno.h sysroot/x86_64/include/linux/errno.h sysroot/i386/include/errno.h sysroot/i386/include/asm-generic/errno.h sysroot/i386/include/linux/errno.h sysroot/powerpc/include/errno.h sysroot/powerpc/include/asm-generic/errno.h sysroot/powerpc/include/asm/errno.h sysroot/powerpc/include/linux/errno.h > I'll leave it aside for now as I've spent way longer than I hoped on > these series. I could take the previous two patches however. > Ok, let's ignore this one, I will find why sysroot not install well for i386. Thanks, Zhangjin > Thanks, > Willy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] selftests/nolibc: fix up O= option support 2023-08-06 12:17 ` Zhangjin Wu @ 2023-08-26 4:30 ` Zhangjin Wu 2023-08-26 18:29 ` Yuan Tan 0 siblings, 1 reply; 9+ messages in thread From: Zhangjin Wu @ 2023-08-26 4:30 UTC (permalink / raw) To: w; +Cc: falcon, arnd, linux-kernel, linux-kselftest, linux, thomas, Yuan Tan Hi, Willy > > On Sat, Aug 05, 2023 at 02:13:11PM +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. > > > > > > To support relative path, as suggested by Thomas, $(COMMAND_O) is used > > > to pass the O=$(ABSOLUTE_O) to the $(MAKE) commands. > > > > Zhangjin, I cannot get this one to work, regardless of what I try: > > > > $ make -j8 O=$PWD/output-i386 nolibc-test XARCH=i386 CROSS_COMPILE=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux- CC=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux-gcc > > (...) > > CC nolibc-test > > In file included from sysroot/i386/include/stdio.h:14, > > from nolibc-test.c:13: > > sysroot/i386/include/errno.h:10:10: fatal error: asm/errno.h: No such file or directory > > 10 | #include <asm/errno.h> > > | ^~~~~~~~~~~~~ > > compilation terminated. > > > > Willy, I also just reproduced the issue, seems only i386 sysroot has no > asm/errno.h, will check why it is no rightly installed later. > > $ find sysroot/ -name "errno.h" > sysroot/arm/include/errno.h > sysroot/arm/include/asm-generic/errno.h > sysroot/arm/include/asm/errno.h > sysroot/arm/include/linux/errno.h > sysroot/riscv/include/errno.h > sysroot/riscv/include/asm-generic/errno.h > sysroot/riscv/include/asm/errno.h > sysroot/riscv/include/linux/errno.h > sysroot/s390/include/errno.h > sysroot/s390/include/asm-generic/errno.h > sysroot/s390/include/asm/errno.h > sysroot/s390/include/linux/errno.h > sysroot/arm64/include/errno.h > sysroot/arm64/include/asm-generic/errno.h > sysroot/arm64/include/asm/errno.h > sysroot/arm64/include/linux/errno.h > sysroot/mips/include/errno.h > sysroot/mips/include/asm-generic/errno.h > sysroot/mips/include/asm/errno.h > sysroot/mips/include/linux/errno.h > sysroot/x86_64/include/errno.h > sysroot/x86_64/include/asm-generic/errno.h > sysroot/x86_64/include/asm/errno.h > sysroot/x86_64/include/linux/errno.h > sysroot/i386/include/errno.h > sysroot/i386/include/asm-generic/errno.h > sysroot/i386/include/linux/errno.h > sysroot/powerpc/include/errno.h > sysroot/powerpc/include/asm-generic/errno.h > sysroot/powerpc/include/asm/errno.h > sysroot/powerpc/include/linux/errno.h > > > I'll leave it aside for now as I've spent way longer than I hoped on > > these series. I could take the previous two patches however. > > > > Ok, let's ignore this one, I will find why sysroot not install well for i386. > Thanks to Yuan, he have done some testing and have found the root cause, that is mrproper on top-level source code tree is required before installing sysroot, otherwise, the 'generated' headers will not be installed (removed by scripts/Makefile.asm-generic). After mrproper (not with O=out, must on top-level source code tree), the asm/errno.h will be there: ubuntu@linux-lab:/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc$ find sysroot/ -name "errno.h" sysroot/i386/include/errno.h sysroot/i386/include/asm-generic/errno.h sysroot/i386/include/asm/errno.h --> here it is sysroot/i386/include/linux/errno.h sysroot/x86/include/errno.h sysroot/x86/include/asm-generic/errno.h sysroot/x86/include/asm/errno.h --> here it is sysroot/x86/include/linux/errno.h That also means, to use O=out for run-user, we also need to use O=out for defconfig (and kernel ...) too, otherwise, the top-level source code tree will be polluated. Seems a manual mrproper on top-level source code tree is always required for a new iteration, so, it may be ok to pick this patch with a note on the potential error. Best Regards, Zhangjin > Thanks, > Zhangjin > > > Thanks, > > Willy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] selftests/nolibc: fix up O= option support 2023-08-26 4:30 ` Zhangjin Wu @ 2023-08-26 18:29 ` Yuan Tan 2023-08-27 7:09 ` Zhangjin Wu 0 siblings, 1 reply; 9+ messages in thread From: Yuan Tan @ 2023-08-26 18:29 UTC (permalink / raw) To: Zhangjin Wu, w Cc: arnd, linux-kernel, linux-kselftest, linux, thomas, Yuan Tan Hi Zhangjin and Willy, On 8/26/2023 12:30 PM, Zhangjin Wu wrote: > Hi, Willy > >>> On Sat, Aug 05, 2023 at 02:13:11PM +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. >>>> >>>> To support relative path, as suggested by Thomas, $(COMMAND_O) is used >>>> to pass the O=$(ABSOLUTE_O) to the $(MAKE) commands. >>> Zhangjin, I cannot get this one to work, regardless of what I try: >>> >>> $ make -j8 O=$PWD/output-i386 nolibc-test XARCH=i386 CROSS_COMPILE=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux- CC=/f/tc/nolibc/gcc-12.3.0-nolibc/i386-linux/bin/i386-linux-gcc >>> (...) >>> CC nolibc-test >>> In file included from sysroot/i386/include/stdio.h:14, >>> from nolibc-test.c:13: >>> sysroot/i386/include/errno.h:10:10: fatal error: asm/errno.h: No such file or directory >>> 10 | #include <asm/errno.h> >>> | ^~~~~~~~~~~~~ >>> compilation terminated. >>> >> Willy, I also just reproduced the issue, seems only i386 sysroot has no >> asm/errno.h, will check why it is no rightly installed later. >> >> $ find sysroot/ -name "errno.h" >> sysroot/arm/include/errno.h >> sysroot/arm/include/asm-generic/errno.h >> sysroot/arm/include/asm/errno.h >> sysroot/arm/include/linux/errno.h >> sysroot/riscv/include/errno.h >> sysroot/riscv/include/asm-generic/errno.h >> sysroot/riscv/include/asm/errno.h >> sysroot/riscv/include/linux/errno.h >> sysroot/s390/include/errno.h >> sysroot/s390/include/asm-generic/errno.h >> sysroot/s390/include/asm/errno.h >> sysroot/s390/include/linux/errno.h >> sysroot/arm64/include/errno.h >> sysroot/arm64/include/asm-generic/errno.h >> sysroot/arm64/include/asm/errno.h >> sysroot/arm64/include/linux/errno.h >> sysroot/mips/include/errno.h >> sysroot/mips/include/asm-generic/errno.h >> sysroot/mips/include/asm/errno.h >> sysroot/mips/include/linux/errno.h >> sysroot/x86_64/include/errno.h >> sysroot/x86_64/include/asm-generic/errno.h >> sysroot/x86_64/include/asm/errno.h >> sysroot/x86_64/include/linux/errno.h >> sysroot/i386/include/errno.h >> sysroot/i386/include/asm-generic/errno.h >> sysroot/i386/include/linux/errno.h >> sysroot/powerpc/include/errno.h >> sysroot/powerpc/include/asm-generic/errno.h >> sysroot/powerpc/include/asm/errno.h >> sysroot/powerpc/include/linux/errno.h >> >>> I'll leave it aside for now as I've spent way longer than I hoped on >>> these series. I could take the previous two patches however. >>> >> Ok, let's ignore this one, I will find why sysroot not install well for i386. >> > Thanks to Yuan, he have done some testing and have found the root cause, that > is mrproper on top-level source code tree is required before installing > sysroot, otherwise, the 'generated' headers will not be installed (removed by > scripts/Makefile.asm-generic). More specifically, building kernel will generate 'linux/arch/x86/include/generated/uapi/asm/errno.h', which prevents nolibc-test with O= generate 'output-x86/arch/x86/include/generated/asm/errno.h'. > > After mrproper (not with O=out, must on top-level source code tree), the > asm/errno.h will be there: > > ubuntu@linux-lab:/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc$ find sysroot/ -name "errno.h" > sysroot/i386/include/errno.h > sysroot/i386/include/asm-generic/errno.h > sysroot/i386/include/asm/errno.h --> here it is > sysroot/i386/include/linux/errno.h > sysroot/x86/include/errno.h > sysroot/x86/include/asm-generic/errno.h > sysroot/x86/include/asm/errno.h --> here it is > sysroot/x86/include/linux/errno.h > > That also means, to use O=out for run-user, we also need to use O=out for > defconfig (and kernel ...) too, otherwise, the top-level source code tree will > be polluated. > > Seems a manual mrproper on top-level source code tree is always required for a > new iteration, so, it may be ok to pick this patch with a note on the potential > error. There are two potential solutions for addressing this issue. The first option involves copying 'linux/arch/x86/include/generated/uapi/asm/' to 'sysroot/x86/include/' during the make of target headers_standalone. The second approach entails displaying an error message when the code tree is not clean and prompting users to manually execute 'make mrproper'. In this case, we can utilize the target 'outputmakefile' from the root makefile directly. Willy, which method do you prefer? Do you have any alternative suggestions? :) Besides. using x86_64-linux-gnu- won't reproduce this issue. It searched and found 'asm/errno.h' in '/usr/include/x86_64-linux-gnu', whereas 'x86_64-linux' lacks these libraries. > > Best Regards, > Zhangjin > >> Thanks, >> Zhangjin >> >>> Thanks, >>> Willy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] selftests/nolibc: fix up O= option support 2023-08-26 18:29 ` Yuan Tan @ 2023-08-27 7:09 ` Zhangjin Wu 0 siblings, 0 replies; 9+ messages in thread From: Zhangjin Wu @ 2023-08-27 7:09 UTC (permalink / raw) To: tanyuan; +Cc: arnd, falcon, linux-kernel, linux-kselftest, linux, thomas, w Hi, Yuan > Hi Zhangjin and Willy, > > On 8/26/2023 12:30 PM, Zhangjin Wu wrote: [...] > > > > ubuntu@linux-lab:/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc$ find sysroot/ -name "errno.h" > > sysroot/i386/include/errno.h > > sysroot/i386/include/asm-generic/errno.h > > sysroot/i386/include/asm/errno.h --> here it is > > sysroot/i386/include/linux/errno.h > > sysroot/x86/include/errno.h > > sysroot/x86/include/asm-generic/errno.h > > sysroot/x86/include/asm/errno.h --> here it is > > sysroot/x86/include/linux/errno.h > > > > That also means, to use O=out for run-user, we also need to use O=out for > > defconfig (and kernel ...) too, otherwise, the top-level source code tree will > > be polluated. > > > > Seems a manual mrproper on top-level source code tree is always required for a > > new iteration, so, it may be ok to pick this patch with a note on the potential > > error. > > There are two potential solutions for addressing this issue. > > The first option involves copying > 'linux/arch/x86/include/generated/uapi/asm/' to 'sysroot/x86/include/' > during the make of target headers_standalone. > Will this work when linux/arch/x86/include/generated/uapi/asm/ is stale? for example, when linux/arch/x86/include/generated/uapi/asm/ is there for v6.1, but we are installing v6.5 sysroot? > The second approach entails displaying an error message when the code > tree is not clean and prompting users to manually execute 'make > mrproper'. In this case, we can utilize the target 'outputmakefile' from > the root makefile directly. > A question is, without O= option, will this 'outputmakefile' always require to do mrproper (when we have already done defconfig, kernel or run without O=)? but currently, seems we don't require to do so. Currently, the asm/errno.h is installed whenever the source code tree is clean or not, the issue is asm/errno.h will not be installed only when O= specified. The root solution may be the generic-y (or generated-y?) in scripts/Makefile.asm-generic should be corrected to work with O= option? but this common code want us to be more careful. > Willy, which method do you prefer? Do you have any alternative > suggestions? :) > > > Besides. using x86_64-linux-gnu- won't reproduce this issue. It searched > and found 'asm/errno.h' in '/usr/include/x86_64-linux-gnu', whereas > 'x86_64-linux' lacks these libraries. > So, the -gnu- toolchain may hide some issues in scripts/Makefile.asm-generic for O= option. Thanks, Zhangjin ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-08-27 7:10 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-08-05 6:09 [PATCH v2 0/3] selftests/nolibc: add misc improvments Zhangjin Wu 2023-08-05 6:11 ` [PATCH v2 1/3] selftests/nolibc: allow report with existing test log Zhangjin Wu 2023-08-05 6:12 ` [PATCH v2 2/3] tools/nolibc: stackprotector.h: make __stack_chk_init static Zhangjin Wu 2023-08-05 6:13 ` [PATCH v2 3/3] selftests/nolibc: fix up O= option support Zhangjin Wu 2023-08-06 11:21 ` Willy Tarreau 2023-08-06 12:17 ` Zhangjin Wu 2023-08-26 4:30 ` Zhangjin Wu 2023-08-26 18:29 ` Yuan Tan 2023-08-27 7:09 ` Zhangjin Wu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox