[klibc] [PATCH v2 3/5] Kbuild: use "libc.a" with clang

Bill Wendling morbo at google.com
Fri Mar 27 15:29:44 PDT 2020


Clang doesn't have a suitable replacement for libgcc readily available.
Supply one that we know exists. Use "-fno-builtin-bcmp" to prevent clang
from calling a function that doesn't exist.

Signed-off-by: Bill Wendling <morbo at google.com>
---
 scripts/Kbuild.klibc          | 2 ++
 usr/klibc/arch/x86_64/MCONFIG | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index 411d7ea9bea6..ba3f389626b3 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -141,6 +141,8 @@ KLIBCSTRIPFLAGS  += --strip-all -R .comment -R .note
 # Don't attempt to set it if we are using clang.
 ifneq ($(cc-name),clang)
 KLIBCLIBGCC_DEF  := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc)
+else
+KLIBCLIBGCC_DEF  := $(KLIBCOBJ)/libc.a
 endif
 KLIBCLIBGCC	 ?= $(KLIBCLIBGCC_DEF)
 KLIBCCRT0        := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG
index ac1ac074c00a..a6ba7c85c68b 100644
--- a/usr/klibc/arch/x86_64/MCONFIG
+++ b/usr/klibc/arch/x86_64/MCONFIG
@@ -26,6 +26,8 @@ ifneq ($(cc-name),clang)
 # These options are not supported by clang but only result in a warning
 # so we can't use a cc-option test to filter them.
 KLIBCOPTFLAGS     += -falign-functions=1 -falign-jumps=1 -falign-loops=1
+else
+KLIBCOPTFLAGS     += -fno-builtin-bcmp
 endif
 
 KLIBCBITSIZE      = 64
-- 
2.26.0.rc2.310.g2932bb562d-goog



More information about the klibc mailing list