Skip to contentSkip to conversation

selftests: target selection fixes for cross and LLVM builds

PATCH Applied Sasha Levin 4 participants 10 messages Oct 14 – Nov 3

Subsystems (4)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

cover selftests: target selection fixes for cross and LLVM builds

A few suites select their tests from the build host instead of the target, or depend on the host C library in ways that break cross builds. This series fixes the ones found while building the selftests for several architectures:

- prctl and the Intel thermal suites build nothing when CROSS_COMPILE is set, even for x86, and prctl restricts two generic tests to x86.

- set-anon-vma-name-test fails instead of skipping on kernels built without CONFIG_ANON_VMA_NAME.

- kexec only recognizes the ppc64le spelling of PowerPC and decides about the x86-64 jump test from the build host.

- size links a custom _start against the static C library, which fails on ARM with clang and on LoongArch; it now uses nolibc.

The patches are independent of each other.

Sasha Levin (5):
selftests/prctl: build generated tests for the target architecture selftests/prctl: skip the anonymous VMA naming test when unsupported selftests/thermal: allow cross builds of the Intel tests selftests/kexec: select tests using the target compiler selftests/size: use nolibc startup and syscall wrappers

 tools/testing/selftests/kexec/Makefile        | 26 ++++++++-------
 tools/testing/selftests/prctl/Makefile        | 18 +++++-----
 .../selftests/prctl/set-anon-vma-name-test.c  |  3 ++
 tools/testing/selftests/size/Makefile         |  9 ++++-
 tools/testing/selftests/size/get_size.c       | 33 +++++--------------
 .../thermal/intel/power_floor/Makefile        | 12 +++----
 .../thermal/intel/workload_hint/Makefile      | 12 +++----
 7 files changed, 52 insertions(+), 61 deletions(-)

base-commit: 4eb2586bd40db27d77cc5b724ca9386ed0c71d53

Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/5 selftests/prctl: build generated tests for the target architecture

The prctl Makefile builds nothing when CROSS_COMPILE is set, even when the target is x86, and it lists its compiled programs in TEST_PROGS, which lib.mk treats as source-tree scripts. The binaries are therefore built into the source directory rather than OUTPUT. The architecture check also restricts set-anon-vma-name-test and set-process-name to x86 although neither depends on the architecture.

Build the programs as TEST_GEN_PROGS, build the two generic tests on every architecture, and keep only the TSC tests x86 specific. Select them from the target ARCH when it is given and from the host's SUBARCH otherwise, using a private ARCH_PROCESSED instead of overriding ARCH. The override added by commit 5a1292137e89 ("selftests: fix ARCH normalization to handle command-line argument") changed the value that lib.mk uses to choose the clang target: leaving ARCH unset again lets lib.mk use the compiler's native triple. A command-line ARCH such as x86_64 is still normalized for the TSC test selection, while an ARCH spelling that lib.mk does not know, such as i686 with LLVM=1, is rejected in the same way as for the other selftests.

Fixes f59514b6a8c5 ("Documentation/prctl: don't build tsc tests when cross compiling")
Fixes 5290586186d2 ("selftests: prctl: Add new prctl test for PR_SET_VMA action")
Fixes e0606daeaab4 ("selftests: prctl: Add new prctl test for PR_SET_NAME")
---
 tools/testing/selftests/prctl/Makefile | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
tools/testing/selftests/prctl/Makefile +8 -10
index e770e86fad9ac..123f884e9dfa5 100644
@@ -1,14 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0
-ifndef CROSS_COMPILE
-ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+top_srcdir = ../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(shell echo $(or $(ARCH),$(SUBARCH)) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
-ifeq ($(ARCH),x86)
-TEST_PROGS := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test \
-		disable-tsc-test set-anon-vma-name-test set-process-name
-all: $(TEST_PROGS)
+TEST_GEN_PROGS := set-anon-vma-name-test set-process-name
+ifeq ($(ARCH_PROCESSED),x86)
+TEST_GEN_PROGS += disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test \
+		disable-tsc-test
+endif
 
 include ../lib.mk
-
-endif
-endif
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/5 selftests/prctl: skip the anonymous VMA naming test when unsupported

In reply to Sasha Levin

PR_SET_VMA_ANON_NAME is only implemented when CONFIG_ANON_VMA_NAME is enabled. Without it, set_anon_vma_name() returns -EINVAL for every request, so set-anon-vma-name-test reports a failure on kernels that simply do not provide the feature:

# renaming: Expected rename_vma(...) (-22) >= 0
not ok 1 vma.renaming

Probe the interface in the fixture setup by clearing the name of the anonymous mapping, which succeeds whenever the feature is available, and skip the test when the kernel rejects the request with EINVAL.

Fixes 5290586186d2 ("selftests: prctl: Add new prctl test for PR_SET_VMA action")
---
 tools/testing/selftests/prctl/set-anon-vma-name-test.c | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/prctl/set-anon-vma-name-test.c +3 -0
index 5f9589534da8e..d3854ccb2a7a3 100644
@@ -93,6 +93,9 @@ FIXTURE_SETUP(vma) {
 					MAP_PRIVATE, self->fd_not_anon, 0);
 	ASSERT_NE(self->ptr_not_anon, MAP_FAILED);
 	close(self->fd_not_anon);
+
+	if (rename_vma((unsigned long)self->ptr_anon, AREA_SIZE, NULL) == -EINVAL)
+		SKIP(return, "PR_SET_VMA_ANON_NAME is not supported");
 }
 
 FIXTURE_TEARDOWN(vma) {
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 3/5 selftests/thermal: allow cross builds of the Intel tests

In reply to Sasha Levin

The power_floor and workload_hint Makefiles build nothing when CROSS_COMPILE is set, even for an x86 target, and they include lib.mk only on x86. Other architectures therefore have no install or emit_tests rules for these suites, and their installation fails with a missing target.

Select the x86 tests from the target ARCH when it is given and from the host's SUBARCH otherwise, and include lib.mk unconditionally so that the suites install and emit an empty runlist on other architectures. Use a private ARCH_PROCESSED instead of the ARCH override added by commit 5a1292137e89 ("selftests: fix ARCH normalization to handle command-line argument"): the override changed the value lib.mk uses to pick the clang target, whereas leaving ARCH unset lets lib.mk use the compiler's native triple. A command-line ARCH such as x86_64 is still normalized for the selection, while an ARCH spelling that lib.mk does not know, such as i686 with LLVM=1, is rejected as in other selftests.

Fixes 27801542b2b8 ("selftests/thermel/intel: Add test to read workload hint")
Fixes d4d27e5a1a88 ("selftests/thermel/intel: Add test to read power floor status")
---
 .../selftests/thermal/intel/power_floor/Makefile     | 12 +++++-------
 .../selftests/thermal/intel/workload_hint/Makefile   | 12 +++++-------
 2 files changed, 10 insertions(+), 14 deletions(-)
tools/testing/selftests/thermal/intel/power_floor/Makefile +5 -7
index 07463c2160e09..16d26eab55652 100644
@@ -1,12 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
-ifndef CROSS_COMPILE
-ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+top_srcdir = ../../../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(shell echo $(or $(ARCH),$(SUBARCH)) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
-ifeq ($(ARCH),x86)
+ifeq ($(ARCH_PROCESSED),x86)
 TEST_GEN_PROGS := power_floor_test
+endif
 
 include ../../../lib.mk
-
-endif
-endif
tools/testing/selftests/thermal/intel/workload_hint/Makefile +5 -7
index 49e3bc2b20f9d..e53d6ecd9f8de 100644
@@ -1,12 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
-ifndef CROSS_COMPILE
-ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+top_srcdir = ../../../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(shell echo $(or $(ARCH),$(SUBARCH)) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
-ifeq ($(ARCH),x86)
+ifeq ($(ARCH_PROCESSED),x86)
 TEST_GEN_PROGS := workload_hint_test
+endif
 
 include ../../../lib.mk
-
-endif
-endif
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH 3/5] selftests/thermal: allow cross builds of the Intel tests

Quoted 61 lines · Sasha Levin

The power_floor and workload_hint Makefiles build nothing when CROSS_COMPILE is set, even for an x86 target, and they include lib.mk only on x86. Other architectures therefore have no install or emit_tests rules for these suites, and their installation fails with a missing target.

Select the x86 tests from the target ARCH when it is given and from the host's SUBARCH otherwise, and include lib.mk unconditionally so that the suites install and emit an empty runlist on other architectures. Use a private ARCH_PROCESSED instead of the ARCH override added by commit 5a1292137e89 ("selftests: fix ARCH normalization to handle command-line argument"): the override changed the value lib.mk uses to pick the clang target, whereas leaving ARCH unset lets lib.mk use the compiler's native triple. A command-line ARCH such as x86_64 is still normalized for the selection, while an ARCH spelling that lib.mk does not know, such as i686 with LLVM=1, is rejected as in other selftests.

Fixes 27801542b2b8 ("selftests/thermel/intel: Add test to read workload hint")
Fixes d4d27e5a1a88 ("selftests/thermel/intel: Add test to read power floor status")
---
 .../selftests/thermal/intel/power_floor/Makefile     | 12 +++++-------
 .../selftests/thermal/intel/workload_hint/Makefile   | 12 +++++-------
 2 files changed, 10 insertions(+), 14 deletions(-)
tools/testing/selftests/thermal/intel/power_floor/Makefile +5 -7
index 07463c2160e09..16d26eab55652 100644
@@ -1,12 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
-ifndef CROSS_COMPILE
-ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+top_srcdir = ../../../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(shell echo $(or $(ARCH),$(SUBARCH)) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
-ifeq ($(ARCH),x86)
+ifeq ($(ARCH_PROCESSED),x86)
 TEST_GEN_PROGS := power_floor_test
+endif
 
 include ../../../lib.mk
-
-endif
-endif
tools/testing/selftests/thermal/intel/workload_hint/Makefile +3 -3
index 49e3bc2b20f9d..e53d6ecd9f8de 100644
@@ -1,12 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
-ifndef CROSS_COMPILE
-ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-override ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+top_srcdir = ../../../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(shell echo $(or $(ARCH),$(SUBARCH)) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 

tools/testing/selftests/thermal/intel/workload_hint/Makefile

Quoted 10 lines
tools/testing/selftests/thermal/intel/workload_hint/Makefile +2 -5
-ifeq ($(ARCH),x86)
+ifeq ($(ARCH_PROCESSED),x86)
 TEST_GEN_PROGS := workload_hint_test
+endif
 
 include ../../../lib.mk
-
-endif
-endif
--

Applied as 7.4-rc material, thanks!

author maintainer
#5 lore raw

PATCH 4/5 selftests/kexec: select tests using the target compiler

In reply to Sasha Levin

The kexec Makefile recognizes PowerPC only through the ppc64le spelling of ARCH, so the canonical ARCH=powerpc used for cross builds omits the tests. The x86 jump test is selected with IS_64_BIT from scripts/Makefile.arch, which describes the build host rather than the compiler being used. On other architectures the Makefile includes no lib.mk rules at all, so installation and runlist generation fail with missing targets.

Select x86 and PowerPC from the target ARCH when it is given and from the host's SUBARCH otherwise, without assigning ARCH, so that lib.mk keeps choosing the compiler's native clang target. Ask the selected compiler, including USERCFLAGS, whether it targets a 64-bit x86 ABI and whether it targets little-endian 64-bit PowerPC. lib.mk expands the generated program list before it appends USERCFLAGS to CFLAGS, so the flags are passed explicitly to keep both probes consistent. If the compiler cannot be run, select the jump test so that the build fails instead of silently dropping it. Include lib.mk unconditionally so that unsupported targets build, install and emit an empty runlist.

Fixes 65e38e32a959 ("selftests/kexec: Enable secureboot tests for PowerPC")
Fixes 7615b94b6371 ("selftests/kexec: Add x86_64 selftest for kexec-jump and exception handling")
---
 tools/testing/selftests/kexec/Makefile | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
tools/testing/selftests/kexec/Makefile +14 -12
index 874cfdd3b75b3..97d5dd10208a1 100644
@@ -1,20 +1,22 @@
 # SPDX-License-Identifier: GPL-2.0-only
 # Makefile for kexec tests
 
-ARCH ?= $(shell uname -m 2>/dev/null || echo not)
-ARCH_PROCESSED := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+top_srcdir = ../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(shell echo $(or $(ARCH),$(SUBARCH)) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
 
-ifeq ($(ARCH_PROCESSED),$(filter $(ARCH_PROCESSED),x86 ppc64le))
-TEST_PROGS := test_kexec_load.sh test_kexec_file_load.sh
-TEST_FILES := kexec_common_lib.sh
+PROBE_CC = $(filter-out -fuse-ld=%,$(CC)) $(CFLAGS) $(USERCFLAGS) -E -P -x c -
+CC_IS_64BIT = $(shell echo __SIZEOF_LONG__ | $(PROBE_CC) || echo 8)
+PPC64LE = $(shell printf '\043if defined(__powerpc64__) && __BYTE_ORDER__ == \
+	__ORDER_LITTLE_ENDIAN__\n1\n\043endif\n' | $(PROBE_CC))
 
-include ../../../scripts/Makefile.arch
-
-ifeq ($(IS_64_BIT)$(ARCH_PROCESSED),1x86)
-TEST_PROGS += test_kexec_jump.sh
-TEST_GEN_PROGS := test_kexec_jump
+ifeq ($(ARCH_PROCESSED),x86)
+TEST_PROGS = test_kexec_load.sh test_kexec_file_load.sh \
+	$(if $(filter 8,$(CC_IS_64BIT)),test_kexec_jump.sh)
+TEST_GEN_PROGS = $(if $(filter 8,$(CC_IS_64BIT)),test_kexec_jump)
+else ifneq (,$(filter powerpc ppc64le,$(ARCH_PROCESSED)))
+TEST_PROGS = $(if $(filter 1,$(PPC64LE)),test_kexec_load.sh test_kexec_file_load.sh)
 endif
+TEST_FILES = $(if $(TEST_PROGS),kexec_common_lib.sh)
 
 include ../lib.mk
-
-endif
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 4/5] selftests/kexec: select tests using the target compiler

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines

The kexec Makefile recognizes PowerPC only through the ppc64le spelling of ARCH, so the canonical ARCH=powerpc used for cross builds omits the tests. The x86 jump test is selected with IS_64_BIT from scripts/Makefile.arch, which describes the build host rather than the compiler being used. On other architectures the Makefile includes no lib.mk rules at all, so installation and runlist generation fail with missing targets.

Select x86 and PowerPC from the target ARCH when it is given and from the host's SUBARCH otherwise, without assigning ARCH, so that lib.mk keeps choosing the compiler's native clang target. Ask the selected compiler, including USERCFLAGS, whether it targets a 64-bit x86 ABI and whether it targets little-endian 64-bit PowerPC. lib.mk expands the generated program list before it appends USERCFLAGS to CFLAGS, so the flags are passed explicitly to keep both probes consistent. If the compiler cannot be run, select the jump test so that the build fails instead of silently dropping it. Include lib.mk unconditionally so that unsupported targets build, install and emit an empty runlist.

Quoted 3 lines
Fixes 65e38e32a959 ("selftests/kexec: Enable secureboot tests for PowerPC")
Fixes 7615b94b6371 ("selftests/kexec: Add x86_64 selftest for kexec-jump and exception handling")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author maintainer
#7 lore raw

PATCH 5/5 selftests/size: use nolibc startup and syscall wrappers

In reply to Sasha Levin

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.

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, 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.

Fixes 3ce51050fadd ("selftest: size: Add size test for Linux kernel")
Cc [email protected] # 6.18.x
---
 tools/testing/selftests/size/Makefile   |  9 ++++++-
 tools/testing/selftests/size/get_size.c | 33 +++++++------------------
 2 files changed, 17 insertions(+), 25 deletions(-)
tools/testing/selftests/size/Makefile +8 -1
index b87facc00a6e9..884b42d7fd0e2 100644
@@ -1,6 +1,13 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS := -static -ffreestanding -nostartfiles -s
+CFLAGS = -Os -static -nostdlib -nostdinc -ffreestanding -fno-stack-protector -s
+CFLAGS += -isystem $(top_srcdir)/tools/include/nolibc $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := get_size
 
 include ../lib.mk
+
+CC_IS_GCC := $(shell printf '\043if defined(__GNUC__) && !defined(__clang__)\nGCC\n\043endif\n' | \
+	$(CC) $(CFLAGS) -E -P -x c - 2>/dev/null)
+LDLIBS += $(if $(filter GCC,$(CC_IS_GCC)),-lgcc)
+
+$(OUTPUT)/get_size: | headers
tools/testing/selftests/size/get_size.c +9 -24
index 2980b1a63366b..ada6a271711a7 100644
@@ -11,26 +11,12 @@
  * own execution.  It also attempts to have as few dependencies
  * on kernel features as possible.
  *
- * It should be statically linked, with startup libs avoided.  It uses
- * no library calls except the syscall() function for the following 3
- * syscalls:
- *   sysinfo(), write(), and _exit()
- *
- * For output, it avoids printf (which in some C libraries
- * has large external dependencies) by  implementing it's own
- * number output and print routines, and using __builtin_strlen()
- *
- * The test may crash if any of the above syscalls fails because in some
- * libc implementations (e.g. the GNU C Library) errno is saved in
- * thread-local storage, which does not get initialized due to avoiding
- * startup libs.
+ * It is statically linked with nolibc startup and syscall wrappers.
+ * For output, it avoids printf by implementing its own print routines.
  */
 
-#include <sys/sysinfo.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-
-#define STDOUT_FILENO 1
+#include <nolibc.h>
+#include <linux/sysinfo.h>
 
 static int print(const char *s)
 {
@@ -39,7 +25,7 @@ static int print(const char *s)
 	while (s[len] != '\0')
 		len++;
 
-	return syscall(SYS_write, STDOUT_FILENO, s, len);
+	return write(STDOUT_FILENO, s, len);
 }
 
 static inline char *num_to_str(unsigned long num, char *buf, int len)
@@ -80,8 +66,7 @@ static int print_k_value(const char *s, unsigned long num, unsigned long units)
 	return ccode;
 }
 
-/* this program has no main(), as startup libraries are not used */
-void _start(void)
+int main(void)
 {
 	int ccode;
 	struct sysinfo info;
@@ -91,12 +76,12 @@ void _start(void)
 	print("TAP version 13\n");
 	print("# Testing system size.\n");
 
-	ccode = syscall(SYS_sysinfo, &info);
+	ccode = syscall(__NR_sysinfo, &info);
 	if (ccode < 0) {
 		print("not ok 1");
 		print(test_name);
 		print(" ---\n reason: \"could not get sysinfo\"\n ...\n");
-		syscall(SYS_exit, ccode);
+		return 1;
 	}
 	print("ok 1");
 	print(test_name);
@@ -112,5 +97,5 @@ void _start(void)
 	print(" ...\n");
 	print("1..1\n");
 
-	syscall(SYS_exit, 0);
+	return 0;
 }
Signature · 1 line
2.53.0
Reviewed-by on v1 5/5
#8 lore raw

Re: [PATCH 5/5] selftests/size: use nolibc startup and syscall wrappers

Quoted 7 lines · Sasha Levin

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.

Quoted 14 lines

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.

Quoted 1 line

nolibc does not support arc, csky, microblaze, nios2 or xtensa,

yet...

Quoted 4 lines

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.

Quoted 3 lines
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 :-)

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

(...)

Quoted 2 lines
tools/testing/selftests/size/get_size.c +0 -0

(...)

tools/testing/selftests/size/get_size.c line 18

Quoted 6 lines
tools/testing/selftests/size/get_size.c +1 -5
-#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.

Quoted 1 line

+#include <linux/sysinfo.h>

(...)

author maintainer
#9 lore raw
In reply to Sasha Levin

Hi Shuah,

Ping on this one. Rafael took 3/5 through his tree. The other four still apply on 7.4-rc1, and Thomas reviewed 5/5.

KernelCI still can't build prctl on any architecture (the Makefile is skipped whenever CROSS_COMPILE is set), kexec on powerpc, or size with clang on arm and on loongarch. Could you pick up 1/5, 2/5, 4/5 and 5/5?

Signature · 2 lines
Thanks,
Sasha