On 2026-10-14 16:01:27-0400, Sasha Levin wrote:
> get_size provides its own _start and is linked statically against the C
> library with -nostartfiles. That combination assumes startup and TLS
> details that vary between architectures and C library versions: errno
> lives in thread-local storage that is never set up, and the static link
> expects symbols from the skipped startup files. CI builds have failed
> with undefined _init/_fini on ARM with clang and an undefined _DYNAMIC
> on LoongArch.

I get the _DYNAMIC failures even on my boring x86_64 distro setup.

> Build the test with the in-tree nolibc instead. nolibc provides the
> startup code, so the test returns from main(), and it provides the
> write() and syscall() wrappers without the TLS errno problem. A failing
> sysinfo() is now reported as a TAP failure instead of crashing the
> test. Keep the static link and the existing TAP output.
> 
> Since the test no longer uses the system C library headers, the kernel
> UAPI headers have to be installed before it is built. Add the headers
> target as an order-only prerequisite, as nolibc-test does, so that a
> standalone build installs them. Link libgcc only when the selected
> compiler is GCC, which needs it for division helpers on ARM, and detect
> that from the compiler rather than from LLVM so that CC=clang builds do
> not try to link a libgcc that clang does not provide.
> 
> nolibc does not support arc, csky, microblaze, nios2 or xtensa,

yet...

> so the
> test can no longer be built for those architectures. This conversion
> also makes the separate i386 vDSO workaround proposed for get_size
> unnecessary.

Nobody seems to build the selftests for these architectures anyways.

> Link: https://lore.kernel.org/r/[email protected]
> Fixes: 3ce51050fadd ("selftest: size: Add size test for Linux kernel")
> Cc: [email protected] # 6.18.x

I am not so excited about Fixes and Cc: stable.
But if it breaks, it will land on your plate anyways :-)

> Signed-off-by: Sasha Levin <[email protected]>

Reviewed-by: Thomas Weißschuh <[email protected]>

> ---
>  tools/testing/selftests/size/Makefile   |  9 ++++++-
>  tools/testing/selftests/size/get_size.c | 33 +++++++------------------
>  2 files changed, 17 insertions(+), 25 deletions(-)

(...)

> --- a/tools/testing/selftests/size/get_size.c
> +++ b/tools/testing/selftests/size/get_size.c

(...)
 
> -#include <sys/sysinfo.h>
> -#include <unistd.h>
> -#include <sys/syscall.h>
> -
> -#define STDOUT_FILENO 1
> +#include <nolibc.h>

Note:

The newfangled way to use nolibc would be to stick to the regular libc
includes:

#include <unistd.h>
#include <sys/syscall.h>
#include <linux/sysinfo.h>

But what you have also works, obviously.

> +#include <linux/sysinfo.h>

(...)

Reply via email to