aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2022-10-02 00:23:26 +0200
committerBen Hutchings <ben@decadent.org.uk>2022-10-02 00:27:43 +0200
commiteec04ea422f69d09288da8475c82e030c0300a60 (patch)
treecd044608d187d920ec3ef8d8746cce16e94c6b31
parent7b813e0f793a78a6bf01afe371ea5b66144daa43 (diff)
downloadklibc-eec04ea422f69d09288da8475c82e030c0300a60.tar.gz
[klibc] zalloc: Fix infinite recursion with Clang 14klibc-2.0.11
zalloc() calls malloc() followed by memset(), which Clang 14 optimises to a call to calloc(). But our calloc() calls zalloc(), so this results in recursion until the stack is exhausted. Use the option -fno-builtin-malloc to inhibit this optimisation for zalloc.c. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/klibc/Kbuild4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 973b0c8179d85b..eb13a70ed57193 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -89,6 +89,10 @@ endif
KLIBCCFLAGS_sprintf.o += $(call cc-option,-Wno-format-truncation, )
KLIBCCFLAGS_vsprintf.o += $(call cc-option,-Wno-format-truncation, )
+# Clang 14 optimises zalloc() to recursively call calloc(), without
+# this option
+KLIBCCFLAGS_zalloc.o += $(call cc-option,-fno-builtin-malloc, )
+
# sigsuspend.c includes <klibc/havesyscall.h> generated by syscalls/
# build, so require that to build first
$(obj)/sigsuspend.o: $(obj)/syscalls/klib.list