[PATCH v2 0/5] -ffreestanding/-fno-builtin-* patches

From: Nick Desaulniers
Date: Wed Aug 19 2020 - 15:17:11 EST


A recent "libcall optimization" addition to LLVM will emit libcalls to
stpcpy, which the kernel doesn't provide an implementation, breaking
almost all kernel builds with ToT Clang. Disable it for clang.

We discussed providing an implementation, but the interface is generally
unsafe as it provides no bounds checking.

-fno-builtin-foo doesn't prevent GCC from emitting calls to foo, and GCC
doesn't currently do the same libcall optimizations. If it ever does,
then we can resurrect these implementations, but right now, YAGNI. So we
only add these flags to CLANG_FLAGS to solve a Clang specific issue.

The first patch is critical, I'm hoping Masahiro will pick it for the
Kbuild tree and help us to get the fix in 5.9.

The rest are cleanups; sending them for feedback/review/testing. Once
the first hits mainline, I plan to resend the rest to the x86
maintainers for inclusion in tip.

Nick Desaulniers (5):
Makefile: add -fno-builtin-stpcpy
Makefile: add -fno-builtin-bcmp
Revert "lib/string.c: implement a basic bcmp"
x86/boot: use -fno-builtin-bcmp
x86: don't build CONFIG_X86_32 as -ffreestanding

Makefile | 2 ++
arch/x86/Makefile | 3 ---
arch/x86/boot/Makefile | 1 +
arch/x86/boot/string.c | 8 --------
include/linux/string.h | 3 ---
lib/string.c | 20 --------------------
6 files changed, 3 insertions(+), 34 deletions(-)

--
2.28.0.297.g1956fa8f8d-goog