Skip to contentSkip to conversation

libnfc: Fix build with musl

PATCH New Khem Raj 2 participants 4 messages May 21, 2019

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/2 libnfc: Fix build with musl

---
v2: Pass _GNU_SOURCE on cmdline

 ...-usbbus-Include-stdint.h-for-uintX_t.patch | 24 +++++++++++++++++++
 meta-oe/recipes-core/libnfc/libnfc_git.bb     |  5 +++-
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-core/libnfc/libnfc/0001-usbbus-Include-stdint.h-for-uintX_t.patch
meta-oe/recipes-core/libnfc/libnfc/0001-usbbus-Include-stdint.h-for-uintX_t.patch new file +24 -0
new file mode 100644
index 0000000000..b8ed87aa0f
@@ -0,0 +1,24 @@
+From cb2a3991545ba9e885704226ed3e831bd5e4cb27 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Mon, 20 May 2019 22:10:05 -0700
+Subject: [PATCH] usbbus: Include stdint.h for uintX_t
+
+stdint.h is needed for uintX_t typedefs which are
+used to replace u_intX_t in libusb API headers in the cmake files
+
+Upstream-Status: Submitted [https://github.com/nfc-tools/libnfc/pull/544]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ libnfc/buses/usbbus.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/libnfc/buses/usbbus.h
++++ b/libnfc/buses/usbbus.h
+@@ -35,6 +35,7 @@
+ 
+ #ifndef _WIN32
+ // Under POSIX system, we use libusb (>= 0.1.12)
++#include <stdint.h>
+ #include <usb.h>
+ #define USB_TIMEDOUT ETIMEDOUT
+ #define _usb_strerror( X ) strerror(-X)
meta-oe/recipes-core/libnfc/libnfc_git.bb +4 -1
index d00733bf58..7efd3443dd 100644
@@ -9,6 +9,9 @@ inherit autotools pkgconfig
 
 S = "${WORKDIR}/git"
 SRCREV = "c42e2502d4627d3ea62f83c32677b100bb3cebdc"
-SRC_URI = "git://github.com/nfc-tools/libnfc.git"
+SRC_URI = "git://github.com/nfc-tools/libnfc.git \
+           file://0001-usbbus-Include-stdint.h-for-uintX_t.patch \
+          "
 
+CFLAGS_append_libc-musl = " -D_GNU_SOURCE"
 DEPENDS = "libusb"
Signature · 1 line
2.21.0
author
#1 lore raw

PATCH 2/2 openocd: Fix build on x86_64

---
 ...fine-PAGE_SIZE-if-its-not-already-de.patch | 37 +++++++++++++++++++
 .../recipes-devtools/openocd/openocd_git.bb   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch
meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch new file +37 -0
new file mode 100644
index 0000000000..6fe5b27891
@@ -0,0 +1,37 @@
+From 531c96b4fd99ea046750591af36c5b3f92479fa6 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Mon, 20 May 2019 23:24:26 -0700
+Subject: [PATCH] esirisc_flash: Define PAGE_SIZE if its not already defined
+
+Fixes
+| src/flash/nor/esirisc_flash.c:95:9: error: 'PAGE_SIZE' macro redefined [-Werror,-Wmacro-redefined]
+| #define PAGE_SIZE                       4096
+|         ^
+| /mnt/a/yoe/build/tmp/work/core2-64-yoe-linux-musl/openocd/0.10+gitrAUTOINC+7ee618692f-r0/recipe-sysroot/usr/inclu
+de/limits.h:89:9: note: previous definition is here
+| #define PAGE_SIZE PAGESIZE
+
+Change-Id: I195b303fc88a7c848ca4e55fd6ba893796df55cc
+Signed-off-by: Khem Raj <[email protected]>
+Upstream-Status: Submitted [http://openocd.zylin.com/#/c/5180/]
+---
+ src/flash/nor/esirisc_flash.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/flash/nor/esirisc_flash.c b/src/flash/nor/esirisc_flash.c
+index 4e33b9429..90661b77b 100644
+--- a/src/flash/nor/esirisc_flash.c
++++ b/src/flash/nor/esirisc_flash.c
+@@ -92,7 +92,9 @@
+ #endif
+ 
+ #define CONTROL_TIMEOUT		5000		/* 5s    */
++#ifndef PAGE_SIZE
+ #define PAGE_SIZE			4096
++#endif
+ #define PB_MAX				32
+ 
+ #define NUM_NS_PER_S		1000000000ULL
+-- 
+2.21.0
+
meta-oe/recipes-devtools/openocd/openocd_git.bb +1 -0
index 9a8a09a913..9054e69b6c 100644
@@ -9,6 +9,7 @@ SRC_URI = " \
     git://repo.or.cz/r/git2cl.git;protocol=http;destsuffix=tools/git2cl;name=git2cl \
     git://repo.or.cz/r/jimtcl.git;protocol=http;destsuffix=git/jimtcl;name=jimtcl \
     git://repo.or.cz/r/libjaylink.git;protocol=http;destsuffix=git/src/jtag/drivers/libjaylink;name=libjaylink \
+    file://0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch \
 "
 
 SRCREV_FORMAT = "openocd"
Signature · 1 line
2.21.0
#2 lore raw

Re: [meta-oe][PATCH 2/2] openocd: Fix build on x86_64

Quoted 10 lines · Khem Raj

...

meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch new file +8 -0
+Fixes
+| src/flash/nor/esirisc_flash.c:95:9: error: 'PAGE_SIZE' macro redefined [-Werror,-Wmacro-redefined]
+| #define PAGE_SIZE                       4096
+|         ^
+| /mnt/a/yoe/build/tmp/work/core2-64-yoe-linux-musl/openocd/0.10+gitrAUTOINC+7ee618692f-r0/recipe-sysroot/usr/inclu
+de/limits.h:89:9: note: previous definition is here
+| #define PAGE_SIZE PAGESIZE
...
+--- a/src/flash/nor/esirisc_flash.c

meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch line 32

Quoted 10 lines
meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch new file +9 -0
++++ b/src/flash/nor/esirisc_flash.c
+@@ -92,7 +92,9 @@
+ #endif
+ 
+ #define CONTROL_TIMEOUT		5000		/* 5s    */
++#ifndef PAGE_SIZE
+ #define PAGE_SIZE			4096
++#endif
+ #define PB_MAX				32
...

Are you sure this is correct?
This looks like two completely unrelated defines that just happen to have the same name.
And it worked by chance since they have the same value on x86_64.

Renaming to something like ESIRISC_PAGE_SIZE would be a proper fix.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
author
#3 lore raw

Re: [meta-oe][PATCH 2/2] openocd: Fix build on x86_64

Quoted 28 lines · Adrian Bunk
Quoted 10 lines · Khem Raj

...

meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch new file +8 -0
+Fixes
+| src/flash/nor/esirisc_flash.c:95:9: error: 'PAGE_SIZE' macro redefined [-Werror,-Wmacro-redefined]
+| #define PAGE_SIZE                       4096
+|         ^
+| /mnt/a/yoe/build/tmp/work/core2-64-yoe-linux-musl/openocd/0.10+gitrAUTOINC+7ee618692f-r0/recipe-sysroot/usr/inclu
+de/limits.h:89:9: note: previous definition is here
+| #define PAGE_SIZE PAGESIZE
...
+--- a/src/flash/nor/esirisc_flash.c

meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch line 32

Quoted 10 lines
meta-oe/recipes-devtools/openocd/openocd/0001-esirisc_flash-Define-PAGE_SIZE-if-its-not-already-de.patch new file +9 -0
++++ b/src/flash/nor/esirisc_flash.c
+@@ -92,7 +92,9 @@
+ #endif
+
+ #define CONTROL_TIMEOUT             5000            /* 5s    */
++#ifndef PAGE_SIZE
+ #define PAGE_SIZE                   4096
++#endif
+ #define PB_MAX                              32
...

Are you sure this is correct?
This looks like two completely unrelated defines that just happen to have the same name.
And it worked by chance since they have the same value on x86_64.

Quoted 2 lines

Renaming to something like ESIRISC_PAGE_SIZE would be a proper fix.

yes, upstream clarified that too. v2 is on cards.

Quoted 10 lines

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed