klibc: Upgrade to 2.0.8 release

Adjust klcc to work with clang

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Andrea Adami <andrea.adami@gmail.com>
This commit is contained in:
Khem Raj 2021-02-04 23:43:00 -08:00
parent ac8a6e43b9
commit 16dd9dfe3f
18 changed files with 72 additions and 139 deletions

View File

@ -1,49 +0,0 @@
From 241f423a015279cb29b7ad1a34386ef1c32007fc Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 9 Dec 2018 16:47:16 -0800
Subject: [PATCH] Define ulocked_{fgets|fread|fwrite} aliases
latest clang converts the normal calls to the unlocked variant
equivalents
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Andrea Adami <andrea.adami@gmail.com>
---
usr/klibc/fgets.c | 2 ++
usr/klibc/fread2.c | 2 ++
usr/klibc/fwrite2.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/usr/klibc/fgets.c b/usr/klibc/fgets.c
index dbf742c6..2e9fcb65 100644
--- a/usr/klibc/fgets.c
+++ b/usr/klibc/fgets.c
@@ -25,3 +25,5 @@ char *fgets(char *s, int n, FILE *f)
return s;
}
+char *fgets_unlocked(char *s, int n, FILE *f)
+ __alias("fgets");
diff --git a/usr/klibc/fread2.c b/usr/klibc/fread2.c
index 7dca56b1..5c234766 100644
--- a/usr/klibc/fread2.c
+++ b/usr/klibc/fread2.c
@@ -11,3 +11,5 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE * f)
{
return _fread(ptr, size * nmemb, f) / size;
}
+size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *f)
+ __alias("fread");
diff --git a/usr/klibc/fwrite2.c b/usr/klibc/fwrite2.c
index cebc017c..3e0bb57d 100644
--- a/usr/klibc/fwrite2.c
+++ b/usr/klibc/fwrite2.c
@@ -11,3 +11,5 @@ size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * f)
{
return _fwrite(ptr, size * nmemb, f) / size;
}
+size_t fwrite_unlocked(void *ptr, size_t size, size_t nmemb, FILE *f)
+ __alias("fwrite");
--
2.19.2

View File

@ -1,28 +0,0 @@
From 4b4147b76518d31a88fb2c58cdbf2236e159a25c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 8 Sep 2017 23:10:54 -0700
Subject: [PATCH] Kbuild.klibc: Add path to compiler headers via -isystem
We need to include this path so it can find compiler headers e.g.
stdarg.h which is called from wrapper stdarg.h using include_next
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
scripts/Kbuild.klibc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index 101f86f..1d5cdc4 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -105,7 +105,8 @@ KLIBCOBJCOPY := $(OBJCOPY)
KLIBCOBJDUMP := $(OBJDUMP)
# klibc include paths
-KLIBCCPPFLAGS := -nostdinc -iwithprefix include \
+KLIBCCPPFLAGS := -nostdinc -iwithprefix include \
+ -isystem $(shell $(CC) -print-file-name=include) \
-I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \
-I$(KLIBCINC)/bits$(KLIBCBITSIZE) \
-I$(KLIBCOBJ)/../include \

View File

@ -1,28 +0,0 @@
From b6185401fc3daa7fa8ba2b84db3e4da3b94a9867 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 26 Jul 2017 16:13:16 -0700
Subject: [PATCH] Kbuild.klibc: Use -print-libgcc-file-name instead of
--print-libgcc
-print-libgcc-file-name works with clang and gcc unlike --print-libgcc
which is gcc specific
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
scripts/Kbuild.klibc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index f500d53..101f86f 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -128,7 +128,7 @@ KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \
KLIBCAFLAGS += -D__ASSEMBLY__ $(KLIBCCFLAGS)
KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note
-KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc)
+KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) -print-libgcc-file-name)
KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF)
KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
KLIBCLIBC := $(KLIBCOBJ)/libc.a

View File

@ -14,8 +14,6 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
usr/klibc/arch/arm/MCONFIG | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr/klibc/arch/arm/MCONFIG b/usr/klibc/arch/arm/MCONFIG
index 303c6ac..48d2685 100644
--- a/usr/klibc/arch/arm/MCONFIG
+++ b/usr/klibc/arch/arm/MCONFIG
@@ -10,7 +10,7 @@

View File

@ -12,11 +12,9 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
usr/klibc/Kbuild | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 98caf2e9..b34521e0 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -168,7 +168,8 @@ $(SOHASH): $(SOLIB) $(SOLIB).hash
@@ -183,7 +183,8 @@ $(SOHASH): $(SOLIB) $(SOLIB).hash
targets += interp.o
quiet_cmd_interp = BUILD $@
@ -25,4 +23,4 @@ index 98caf2e9..b34521e0 100644
+ -D__ASSEMBLY__ \
-DLIBDIR=\"$(SHLIBDIR)\" \
-DSOHASH=\"$(SOLIBHASH)\" \
-c -o $@ $<
$(KLIBCSTACKFLAGS) \

View File

@ -10,11 +10,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
usr/klibc/SYSCALLS.def | 1 +
1 file changed, 1 insertion(+)
diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index 6b3bf4c..d4184ba 100644
--- a/usr/klibc/SYSCALLS.def
+++ b/usr/klibc/SYSCALLS.def
@@ -274,6 +274,7 @@ int syslog::klogctl(int, char *, int);
@@ -275,6 +275,7 @@ int syslog::klogctl(int, char *, int);
int sysinfo(struct sysinfo *);
long kexec_load(void *, unsigned long, struct kexec_segment *, unsigned long);
<x86_64,ppc64,s390x> long kexec_file_load(int, int, unsigned long, const char *, unsigned long);
@ -22,6 +20,3 @@ index 6b3bf4c..d4184ba 100644
/*
* Low-level I/O (generally architecture-specific);
--
2.7.4

View File

@ -10,11 +10,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
usr/klibc/SYSCALLS.def | 1 +
1 file changed, 1 insertion(+)
diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index c56e8f9..6b3bf4c 100644
--- a/usr/klibc/SYSCALLS.def
+++ b/usr/klibc/SYSCALLS.def
@@ -273,6 +273,7 @@ int reboot::__reboot(int, int, int, void *);
@@ -274,6 +274,7 @@ int reboot::__reboot(int, int, int, void
int syslog::klogctl(int, char *, int);
int sysinfo(struct sysinfo *);
long kexec_load(void *, unsigned long, struct kexec_segment *, unsigned long);
@ -22,6 +20,3 @@ index c56e8f9..6b3bf4c 100644
/*
* Low-level I/O (generally architecture-specific);
--
2.7.4

View File

@ -0,0 +1,24 @@
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -113,10 +113,8 @@ KLIBCCPPFLAGS := -nostdinc -iwithpref
-I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \
-I$(KLIBCINC)/bits$(KLIBCBITSIZE) \
-I$(KLIBCOBJ)/../include \
- -I$(KLIBCINC)
-ifeq ($(cc-name),clang)
-KLIBCCPPFLAGS += -I$(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-file-name=include)
-endif
+ -I$(KLIBCINC) \
+ -I$(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-file-name=include)
# kernel include paths
KLIBCKERNELSRC ?= $(srctree)
@@ -137,7 +135,7 @@ KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(K
KLIBCAFLAGS += -D__ASSEMBLY__ $(KLIBCCFLAGS)
KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note
-KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) $(if $(filter gcc,$(cc-name)),--print-libgcc,--print-libgcc-file-name))
+KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc-file-name)
KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF)
KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
KLIBCLIBC := $(KLIBCOBJ)/libc.a

View File

@ -5,10 +5,22 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/klcc/klcc.in
+++ b/klcc/klcc.in
@@ -207,6 +207,12 @@ while ( defined($a = shift(@ARGV)) ) {
@@ -207,6 +207,24 @@ while ( defined($a = shift(@ARGV)) ) {
} elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
# Override gcc encoded sysroot
push(@ccopt, $a);
+ } elsif ( $a eq '-nostartfiles' ) {
+ # Allow clang options
+ push(@ccopt, $a);
+ } elsif ( $a eq '-nostdlib' ) {
+ # Allow clang options
+ push(@ccopt, $a);
+ } elsif ( $a eq '-nodefaultlibs' ) {
+ # Allow clang options
+ push(@ccopt, $a);
+ } elsif ( $a eq '-no-pie' ) {
+ # Allow clang options
+ push(@ccopt, $a);
+ } elsif ( $a eq '-no-integrated-as' ) {
+ # Allow clang options
+ push(@ccopt, $a);

View File

@ -10,8 +10,6 @@ that /usr/bin/env perl will always return ours (if it has been built).
Signed-off-by: Tom Rini <tom_rini@mentor.com>
Index: klibc-1.5.20/klcc/makeklcc.pl
===================================================================
--- a/klcc/makeklcc.pl
+++ b/klcc/makeklcc.pl
@@ -26,7 +26,7 @@ sub pathsearch($) {

View File

@ -15,13 +15,11 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/libs/klibc/2.0/klibc-${PV}.tar.xz \
file://0001-include-linux-sysinfo.h-directly.patch \
file://0001-mkfifo-Implement-mkfifo.patch \
file://0001-always-use-bfd-linker.patch \
file://0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch \
file://0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch \
file://0001-arm-Do-not-set-a-fallback-march-and-mtune.patch \
file://0001-klibc_2.0.4-add-kexec_file_load-syscall.patch \
file://0001-klibc-add-getrandom-syscall.patch \
file://0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch \
file://0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch \
file://cross-clang.patch \
"
ARMPATCHES ?= ""
@ -29,9 +27,7 @@ ARMPATCHES ?= ""
ARMPATCHES_arm = " \
file://armv4-fix-v4bx.patch \
"
SRC_URI[md5sum] = "712f8bc1a069e03d92584b7f5380c521"
SRC_URI[sha256sum] = "abef2637ca823485d9c90ce9512e2b08a65047ec4da204635eeaef95a41a9122"
SRC_URI[sha256sum] = "4e48f1398cfe3ce0b6df55ce6e70acf54fc8488e3aea3fb3610ee1622d9cb436"
S = "${WORKDIR}/klibc-${PV}"

View File

@ -10,11 +10,9 @@ Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
purgatory/Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/purgatory/Makefile b/purgatory/Makefile
index 49ce80a..1542b3a 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -47,7 +47,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
@@ -47,7 +47,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/s
$(PURGATORY): CC=$(TARGET_CC)
$(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
@ -23,14 +21,14 @@ index 49ce80a..1542b3a 100644
-fno-zero-initialized-in-bss \
-fno-PIC -fno-PIE -fno-stack-protector
@@ -59,8 +59,8 @@ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
@@ -59,8 +59,8 @@ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATO
-Iinclude \
-I$(shell $(CC) -print-file-name=include)
$(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
- -Wl,--no-undefined -nostartfiles -nostdlib \
- -nodefaultlibs -e purgatory_start -r \
+ -Wl,--no-undefined -Wl,-no-pie -Wl,-nostartfiles -Wl,-nostdlib \
+ -Wl,-nodefaultlibs -Wl,--entry=purgatory_start -Wl,-r \
+ -Wl,--no-undefined -no-pie -nostartfiles -nostdlib \
+ -nodefaultlibs -Wl,--entry=purgatory_start -Wl,-r \
-Wl,-Map=$(PURGATORY_MAP)
$(PURGATORY): $(PURGATORY_OBJS)

View File

@ -0,0 +1,22 @@
--- a/kexec/Makefile
+++ b/kexec/Makefile
@@ -110,7 +110,7 @@ $(KEXEC): $(KEXEC_OBJS) $(UTIL_LIB)
@$(MKDIR) -p $(@D)
$(LINK.o) -o $@ $^ $(CFLAGS) $(LIBS)
-$(KEXEC): CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)/include
+$(KEXEC): CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)/include -I$(shell $(CC) -print-file-name=include)
kexec/fs2dt.o: CPPFLAGS+=$($(ARCH)_FS2DT_INCLUDE)
--- a/Makefile.in
+++ b/Makefile.in
@@ -46,7 +46,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@
# Base compiler flags. These are extended by the subcomponent-Makefiles
# where necessary.
CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -I$(srcdir)/util_lib/include \
- -Iinclude/ $($(ARCH)_CPPFLAGS)
+ -Iinclude/ $($(ARCH)_CPPFLAGS) -I$(shell $(CC) -print-file-name=include)
CFLAGS = @CFLAGS@ -static -fno-strict-aliasing -Wall -Wstrict-prototypes
PURGATORY_EXTRA_CFLAGS = @PURGATORY_EXTRA_CFLAGS@
ASFLAGS = @ASFLAGS@ $($(ARCH)_ASFLAGS)

View File

@ -32,7 +32,9 @@ KLIBC_PATCHES += " \
file://0013-sha256.h-avoid-inclusion-of-sys-types.h.patch \
file://0014-add-if_nameindex-from-musl.patch \
file://0015-vmcore-dmesg-fix-warning.patch \
file://klibc-reboot.patch"
file://klibc-reboot.patch \
file://include_next.patch \
"
WARNING_FIXES = ""
FROM_OE_CORE = "file://arm_crashdump-fix-buffer-align.patch \