[klibc] [PATCH v2 3/5] Kbuild: use "libc.a" with clang
morbo at google.com
Sun Mar 29 04:40:19 PDT 2020
I uploaded "v3" to address all of your and Thorsten's comments. PTAL.
On Sat, Mar 28, 2020 at 8:46 AM Ben Hutchings <ben at decadent.org.uk> wrote:
> On Fri, 2020-03-27 at 15:29 -0700, Bill Wendling wrote:
> > 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.
> Doesn't this contradict the comment added for KLIBCLIBGCC_DEF?
> > 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
> This doesn't seem to be an optimisation option. It belongs in
> KLIBCARCHREQFLAGS if it's really arch-specific. But it appears to be
> arch-independent, in which case scripts/Kbuild.klibc should add it to
> > endif
> > KLIBCBITSIZE = 64
> Ben Hutchings
> This sentence contradicts itself - no actually it doesn't.
More information about the klibc