Commit 08b96aa9 authored by Thomas Weißschuh's avatar Thomas Weißschuh
Browse files

selftests/nolibc: only use libgcc when really necessary



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: default avatarThomas Weißschuh <linux@weissschuh.net>
Acked-by: default avatarWilly Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260404-nolibc-libgcc-v1-1-eb3ecfe0e176@weissschuh.net
parent e70a7bb5
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -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)