selftests/nolibc: add a variable for nolibc-test source files

The list of the nolibc-test source files is repeated many times.
Another source file is about to be added, adding to the mess.

Introduce a common variable instead.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260311-nolibc-err-h-v1-1-735a9de7f15d@weissschuh.net
This commit is contained in:
Thomas Weißschuh 2026-03-11 23:00:49 +01:00
parent e83b07dc8c
commit e290017632
3 changed files with 8 additions and 6 deletions

View File

@ -13,9 +13,9 @@ $(OUTPUT)/nolibc-test: CFLAGS = -nostdlib -nostdinc -static \
-isystem $(top_srcdir)/tools/include/nolibc -isystem $(top_srcdir)/usr/include \
$(CFLAGS_NOLIBC_TEST)
$(OUTPUT)/nolibc-test: LDLIBS = $(if $(LLVM),,-lgcc)
$(OUTPUT)/nolibc-test: nolibc-test.c nolibc-test-linkage.c | headers
$(OUTPUT)/nolibc-test: $(NOLIBC_TEST_SOURCES) | headers
$(OUTPUT)/libc-test: nolibc-test.c nolibc-test-linkage.c
$(OUTPUT)/libc-test: $(NOLIBC_TEST_SOURCES)
$(call msg,CC,,$@)
$(Q)$(LINK.c) $^ -o $@

View File

@ -8,3 +8,5 @@ _CFLAGS_SANITIZER ?= $(call cc-option,-fsanitize=undefined -fsanitize-trap=all)
CFLAGS_NOLIBC_TEST ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \
$(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

View File

@ -302,12 +302,12 @@ sysroot/$(ARCH)/include:
$(Q)$(MAKE) -C $(srctree)/tools/include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone headers_check
$(Q)mv sysroot/sysroot sysroot/$(ARCH)
nolibc-test: nolibc-test.c nolibc-test-linkage.c sysroot/$(ARCH)/include
nolibc-test: $(NOLIBC_TEST_SOURCES) sysroot/$(ARCH)/include
$(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
-nostdlib -nostdinc -static -Isysroot/$(ARCH)/include nolibc-test.c nolibc-test-linkage.c $(LIBGCC)
-nostdlib -nostdinc -static -Isysroot/$(ARCH)/include $(NOLIBC_TEST_SOURCES) $(LIBGCC)
libc-test: nolibc-test.c nolibc-test-linkage.c
$(QUIET_CC)$(HOSTCC) -o $@ nolibc-test.c nolibc-test-linkage.c
libc-test: $(NOLIBC_TEST_SOURCES)
$(QUIET_CC)$(HOSTCC) -o $@ $(NOLIBC_TEST_SOURCES)
# local libc-test
run-libc-test: libc-test