diff mbox series

[oe,meta-initramfs] klibc: Fix build with clang

Message ID 20181210220813.34072-1-raj.khem@gmail.com
State New
Headers show
Series [oe,meta-initramfs] klibc: Fix build with clang | expand

Commit Message

Khem Raj Dec. 10, 2018, 10:08 p.m. UTC
Newer versions of clang optimize the calls to use unlocked variants of
these functions

Fixes
| capabilities.c:(.text+0xb4): undefined reference to `fread_unlocked'
| arm-yoe-linux-gnueabi-ld.bfd: capabilities.c:(.text+0x11a): undefined
reference to `fwrite_unlocked'

Signed-off-by: Khem Raj <raj.khem@gmail.com>

Cc: Andrea Adami <andrea.adami@gmail.com>
---
 ...-ulocked_-fgets-fread-fwrite-aliases.patch | 49 +++++++++++++++++++
 .../recipes-devtools/klibc/klibc.inc          |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch

-- 
2.20.0

-- 
_______________________________________________
Openembedded-devel mailing list
Openembedded-devel@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
diff mbox series

Patch

diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch
new file mode 100644
index 0000000000..eee144dc4a
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch
@@ -0,0 +1,49 @@ 
+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
+
diff --git a/meta-initramfs/recipes-devtools/klibc/klibc.inc b/meta-initramfs/recipes-devtools/klibc/klibc.inc
index 398dfd1cfa..ec52e9734f 100644
--- a/meta-initramfs/recipes-devtools/klibc/klibc.inc
+++ b/meta-initramfs/recipes-devtools/klibc/klibc.inc
@@ -24,6 +24,7 @@  SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git \
            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 \
            "
 
 ARMPATCHES ?= ""