mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/nolibc: only use libgcc when really necessary
@ 2026-04-04 12:59 Thomas Weißschuh
  2026-04-04 13:43 ` Willy Tarreau
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2026-04-04 12:59 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: linux-kernel, Thomas Weißschuh

nolibc should work without libgcc to be compatible with as many
toolchains as possible. Currently the functionality tested by
nolibc-test does not contain any dependencies, make sure it stays
this way by not linking libgcc anymore.

On the ppc target GCC always emits references to '_restgpr_' functions,
so keep linking libgcc there.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 tools/testing/selftests/nolibc/Makefile.nolibc | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index 2d32cec1105f..f30bc68470cc 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -232,23 +232,14 @@ ifeq ($(origin XARCH),command line)
 CFLAGS_XARCH = $(CFLAGS_$(XARCH))
 endif
 
+LDLIBS_ppc = $(if $(LLVM),,-lgcc)
+LDLIBS = $(LDLIBS_$(XARCH))
+
 include Makefile.include
 
 CFLAGS  ?= $(CFLAGS_NOLIBC_TEST) $(CFLAGS_XARCH) $(CFLAGS_EXTRA)
 LDFLAGS :=
 
-LIBGCC := -lgcc
-
-ifeq ($(ARCH),x86)
-# Not needed on x86, probably not present for x32
-LIBGCC :=
-endif
-
-ifneq ($(LLVM),)
-# Not needed for clang
-LIBGCC :=
-endif
-
 # Modify CFLAGS based on LLVM=
 include $(srctree)/tools/scripts/Makefile.include
 
@@ -304,7 +295,7 @@ 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_SOURCES) $(LIBGCC)
+	  -nostdlib -nostdinc -static -Isysroot/$(ARCH)/include $(NOLIBC_TEST_SOURCES) $(LDLIBS)
 
 libc-test: $(NOLIBC_TEST_SOURCES)
 	$(QUIET_CC)$(HOSTCC) -o $@ $(NOLIBC_TEST_SOURCES)

---
base-commit: 4b31f409c33f6661a72f52b90b6a61c9bd7034ad
change-id: 20260404-nolibc-libgcc-eb5bc6bc5ff5

Best regards,
--  
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-04 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-04 12:59 [PATCH] selftests/nolibc: only use libgcc when really necessary Thomas Weißschuh
2026-04-04 13:43 ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®