[PATCH 2/4] selftests/nolibc: validate NOLIBC_IGNORE_ERRNO compilation

From: Thomas Weißschuh

Date: Wed Mar 11 2026 - 18:05:59 EST


When NOLIBC_IGNORE_ERRNO is set, various bits of nolibc are disabled.

Make sure that all the ifdeffery does not result in any compilation
errors by compiling a dummy source file.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
tools/testing/selftests/nolibc/Makefile.include | 2 +-
tools/testing/selftests/nolibc/nolibc-test-ignore-errno.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/nolibc/Makefile.include b/tools/testing/selftests/nolibc/Makefile.include
index 6455373d56be..41a0039f774c 100644
--- a/tools/testing/selftests/nolibc/Makefile.include
+++ b/tools/testing/selftests/nolibc/Makefile.include
@@ -9,4 +9,4 @@ CFLAGS_NOLIBC_TEST ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -
$(call cc-option,-fno-stack-protector) $(call cc-option,-Wmissing-prototypes) \
$(_CFLAGS_STACKPROTECTOR) $(_CFLAGS_SANITIZER)

-NOLIBC_TEST_SOURCES := nolibc-test.c nolibc-test-linkage.c
+NOLIBC_TEST_SOURCES := nolibc-test.c nolibc-test-linkage.c nolibc-test-ignore-errno.c
diff --git a/tools/testing/selftests/nolibc/nolibc-test-ignore-errno.c b/tools/testing/selftests/nolibc/nolibc-test-ignore-errno.c
new file mode 100644
index 000000000000..aea816da4fca
--- /dev/null
+++ b/tools/testing/selftests/nolibc/nolibc-test-ignore-errno.c
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#define NOLIBC_IGNORE_ERRNO
+
+/* Include all of nolibc and make sure everything compiles */
+#include <stdlib.h>

--
2.53.0