Bill Wendling
2020-Mar-27 22:29 UTC
[klibc] [PATCH v2 3/5] Kbuild: use "libc.a" with clang
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
Ben Hutchings
2020-Mar-28 15:46 UTC
[klibc] [PATCH v2 3/5] Kbuild: use "libc.a" with clang
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-bcmpThis 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 KLIBCREQFLAGS. Ben.> endif > > KLIBCBITSIZE = 64-- Ben Hutchings This sentence contradicts itself - no actually it doesn't. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20200328/4b5380c7/attachment.sig>
Thorsten Glaser
2020-Mar-29 00:03 UTC
[klibc] [PATCH v2 3/5] Kbuild: use "libc.a" with 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.Do they also result in a warning only if you add -Werror? This is how I test most of the things in mksh, and besides sarge?s GCC failing to error out on __attribute__((bounded)) it mostly catches those cases? if not, suggest that to the clang developers. bye, //mirabilos -- 11:56??liwakura:#!/bin/mksh? also, i wanted to add mksh to my own distro ? i was disappointed that there is no makefile ? but somehow the Build.sh is the least painful built system i've ever seen ? honours CC, {CPP,C,LD}FLAGS properly ? looks cleary like done by someone who knows what they are doing
Bill Wendling
2020-Mar-29 11:40 UTC
[klibc] [PATCH v2 3/5] Kbuild: use "libc.a" with clang
Hi Ben, 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 > KLIBCREQFLAGS. > > Ben. > > > endif > > > > KLIBCBITSIZE = 64 > -- > Ben Hutchings > This sentence contradicts itself - no actually it doesn't. >
Apparently Analagous Threads
- [PATCH v2 3/5] Kbuild: use "libc.a" with clang
- [kvm-unit-tests PATCH v3 1/4] Kbuild: add support for clang builds
- [klibc:master] Kbuild: add support for clang builds
- [PATCH v2 1/5] Kbuild: add support for clang builds
- [PATCH v2 1/5] Kbuild: add support for clang builds