Skip to content

Commit 801cf69

Browse files
committed
selftests/nolibc: don't use libgcc when building with clang
The logic in clang to find the libgcc.a from a GCC toolchain for a specific ABI does not work reliably and can lead to errors. Instead disable libgcc when building with clang, as it's not needed anyways. Acked-by: Willy Tarreau <[email protected]> Reviewed-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Thomas Weißschuh <[email protected]>
1 parent 27e458b commit 801cf69

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/testing/selftests/nolibc/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wex
157157
$(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_EXTRA)
158158
LDFLAGS :=
159159

160+
LIBGCC := -lgcc
161+
162+
ifneq ($(LLVM),)
163+
# Not needed for clang
164+
LIBGCC :=
165+
endif
166+
160167
# Modify CFLAGS based on LLVM=
161168
include $(srctree)/tools/scripts/Makefile.include
162169

@@ -209,11 +216,11 @@ sysroot/$(ARCH)/include:
209216
ifneq ($(NOLIBC_SYSROOT),0)
210217
nolibc-test: nolibc-test.c nolibc-test-linkage.c sysroot/$(ARCH)/include
211218
$(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
212-
-nostdlib -nostdinc -static -Isysroot/$(ARCH)/include nolibc-test.c nolibc-test-linkage.c -lgcc
219+
-nostdlib -nostdinc -static -Isysroot/$(ARCH)/include nolibc-test.c nolibc-test-linkage.c $(LIBGCC)
213220
else
214221
nolibc-test: nolibc-test.c nolibc-test-linkage.c
215222
$(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
216-
-nostdlib -static -include $(srctree)/tools/include/nolibc/nolibc.h nolibc-test.c nolibc-test-linkage.c -lgcc
223+
-nostdlib -static -include $(srctree)/tools/include/nolibc/nolibc.h nolibc-test.c nolibc-test-linkage.c $(LIBGCC)
217224
endif
218225

219226
libc-test: nolibc-test.c nolibc-test-linkage.c

0 commit comments

Comments
 (0)