[PATCH 0/3] tools/nolibc: LTO compatibility

From: Thomas Weißschuh
Date: Sat Aug 10 2024 - 06:55:26 EST


A few tiny bugfixes and refactoring to provide compatibility with GCCs
and clangs -flto.

$ CFLAGS_EXTRA=-flto ./run-tests.sh -m user -l
i386: 195 test(s): 193 passed, 2 skipped, 0 failed => status: warning
x86_64: 195 test(s): 193 passed, 2 skipped, 0 failed => status: warning
arm64: 195 test(s): 193 passed, 2 skipped, 0 failed => status: warning
arm: 195 test(s): 193 passed, 2 skipped, 0 failed => status: warning
mips32le: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
mips32be: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
ppc: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
ppc64: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
ppc64le: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
riscv: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
s390: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning
loongarch: 195 test(s): 192 passed, 3 skipped, 0 failed => status: warning

$ CFLAGS_EXTRA=-flto ./run-tests.sh -m user
i386: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
x86_64: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
arm64: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
arm: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
mips32le: 195 test(s): 190 passed, 3 skipped, 2 failed => status: failure
mips32be: 195 test(s): 190 passed, 3 skipped, 2 failed => status: failure
ppc: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
ppc64: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
ppc64le: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
riscv: 195 test(s): 191 passed, 2 skipped, 2 failed => status: failure
s390: 195 test(s): 190 passed, 3 skipped, 2 failed => status: failure
loongarch: 195 test(s): 190 passed, 3 skipped, 2 failed => status: failure

Note that on GCC two tests always fail, as with -fLTO the constructor
order is inverted, for which nolibc-test contains two testcases.
See [0].

This series depends on the nolibc LLVM support.

[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103080
[1] https://lore.kernel.org/lkml/20240807-nolibc-llvm-v2-0-c20f2f5fc7c2@xxxxxxxxxxxxxx/

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
Thomas Weißschuh (3):
tools/nolibc: crt: mark _start_c() as used
tools/nolibc: stackprotector: mark implicitly used symbols as used
tools/nolibc: x86_64: wrap asm functions in functions

tools/include/nolibc/arch-x86_64.h | 80 +++++++++++++++++++----------------
tools/include/nolibc/crt.h | 2 +-
tools/include/nolibc/stackprotector.h | 4 +-
3 files changed, 47 insertions(+), 39 deletions(-)
---
base-commit: 6164f3d0f577a2ab82b8235129fd20b2142e03b1
change-id: 20240728-nolibc-lto-331813b72a0b

Best regards,
--
Thomas Weißschuh <linux@xxxxxxxxxxxxxx>