diff mbox series

[meta-oe] libnvme: apply patch already upstream to fix build with musl

Message ID 20231009194750.131009-1-cvubrugier@fastmail.fm
State Under Review
Headers show
Series [meta-oe] libnvme: apply patch already upstream to fix build with musl | expand

Commit Message

Christophe Vu-Brugier Oct. 9, 2023, 7:47 p.m. UTC
From: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>

Build failure with musl due to conflicting definitions of ioctl()
between glibc and musl has been fixed by libnvme developers with this
commit:

 * https://github.com/linux-nvme/libnvme/commit/ca47ba3119365eafac0ab25a86cab9d9a1b29bd4

Signed-off-by: Christophe Vu-Brugier <christophe.vu-brugier@seagate.com>
---
 ...l-Check-for-ioctl-signature-for-musl.patch | 38 -----------
 ...01-test-handle-POSIX-ioctl-prototype.patch | 68 +++++++++++++++++++
 .../recipes-support/libnvme/libnvme_1.6.bb    |  2 +-
 3 files changed, 69 insertions(+), 39 deletions(-)
 delete mode 100644 meta-oe/recipes-support/libnvme/libnvme/0001-ioctl-Check-for-ioctl-signature-for-musl.patch
 create mode 100644 meta-oe/recipes-support/libnvme/libnvme/0001-test-handle-POSIX-ioctl-prototype.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/libnvme/libnvme/0001-ioctl-Check-for-ioctl-signature-for-musl.patch b/meta-oe/recipes-support/libnvme/libnvme/0001-ioctl-Check-for-ioctl-signature-for-musl.patch
deleted file mode 100644
index 06f7b5712..000000000
--- a/meta-oe/recipes-support/libnvme/libnvme/0001-ioctl-Check-for-ioctl-signature-for-musl.patch
+++ /dev/null
@@ -1,38 +0,0 @@ 
-From ad1ac4215f051bd42b7ddf64dad63d8215cc3ac4 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Sat, 7 Oct 2023 17:50:54 -0700
-Subject: [PATCH] ioctl: Check for ioctl signature for musl
-
-Fixes
-../git/test/ioctl/mock.c:117:5: error: conflicting types for 'ioctl'
-  117 | int ioctl(int fd, unsigned long request, ...)
-      |     ^
-/mnt/b/yoe/master/build/tmp/work/cortexa15t2hf-neon-yoe-linux-musleabi/libnvme/1.6/recipe-sysroot/usr/include/sys/ioctl.h:115:5: note: previous declaration is here
-  115 | int ioctl (int, int, ...);
-      |     ^
-
-Upstream-Status: Pending
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- test/ioctl/mock.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/test/ioctl/mock.c b/test/ioctl/mock.c
-index e917244..7d5c983 100644
---- a/test/ioctl/mock.c
-+++ b/test/ioctl/mock.c
-@@ -114,7 +114,11 @@ void end_mock_cmds(void)
- 	} \
- })
- 
-+#if defined(__linux__) && !defined(__GLIBC__)
-+int ioctl(int fd, int request, ...)
-+#else
- int ioctl(int fd, unsigned long request, ...)
-+#endif
- {
- 	struct mock_cmds *mock_cmds;
- 	bool result64;
--- 
-2.42.0
-
diff --git a/meta-oe/recipes-support/libnvme/libnvme/0001-test-handle-POSIX-ioctl-prototype.patch b/meta-oe/recipes-support/libnvme/libnvme/0001-test-handle-POSIX-ioctl-prototype.patch
new file mode 100644
index 000000000..ef9cc47d2
--- /dev/null
+++ b/meta-oe/recipes-support/libnvme/libnvme/0001-test-handle-POSIX-ioctl-prototype.patch
@@ -0,0 +1,68 @@ 
+From ca47ba3119365eafac0ab25a86cab9d9a1b29bd4 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Sat, 30 Sep 2023 06:38:53 +0100
+Subject: [PATCH] test: handle POSIX ioctl prototype
+
+glibc has the following prototype for ioctl: int ioctl(int fd, unsigned long request, ...)
+POSIX (inc. musl) has the following for ioctl: int ioctl(int fd, int request, ...)
+
+Check which prototype is used in <sys/ioctl.h> to avoid a conflict and conditionally
+define the right one for the system.
+
+Bug: https://bugs.gentoo.org/914921
+Signed-off-by: Sam James <sam@gentoo.org>
+Upstream-Status: Backport [https://github.com/linux-nvme/libnvme/commit/ca47ba3119365eafac0ab25a86cab9d9a1b29bd4]
+---
+ meson.build       | 10 ++++++++++
+ test/ioctl/mock.c |  6 +++++-
+ 2 files changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 6fcf1da..2c979cc 100644
+--- a/meson.build
++++ b/meson.build
+@@ -230,6 +230,16 @@ conf.set(
+     ),
+     description: 'Is network address and service translation available'
+ )
++conf.set(
++    'HAVE_GLIBC_IOCTL',
++    cc.compiles(
++        '''#include <sys/ioctl.h>
++        int ioctl(int fd, unsigned long request, ...);
++        ''',
++        name: 'ioctl has glibc-style prototype'
++    ),
++    description: 'Is ioctl the glibc interface (rather than POSIX)'
++)
+ 
+ if cc.has_function_attribute('fallthrough')
+   conf.set('fallthrough', '__attribute__((__fallthrough__))')
+diff --git a/test/ioctl/mock.c b/test/ioctl/mock.c
+index e917244..5d2ac94 100644
+--- a/test/ioctl/mock.c
++++ b/test/ioctl/mock.c
+@@ -114,7 +114,11 @@ void end_mock_cmds(void)
+ 	} \
+ })
+ 
++#ifdef HAVE_GLIBC_IOCTL
+ int ioctl(int fd, unsigned long request, ...)
++#else
++int ioctl(int fd, int request, ...)
++#endif
+ {
+ 	struct mock_cmds *mock_cmds;
+ 	bool result64;
+@@ -141,7 +145,7 @@ int ioctl(int fd, unsigned long request, ...)
+ 		result64 = true;
+ 		break;
+ 	default:
+-		fail("unexpected %s %lu", __func__, request);
++		fail("unexpected %s %lu", __func__, (unsigned long) request);
+ 	}
+ 	check(mock_cmds->remaining_cmds,
+ 	      "unexpected %s command", mock_cmds->name);
+-- 
+2.40.1
+
diff --git a/meta-oe/recipes-support/libnvme/libnvme_1.6.bb b/meta-oe/recipes-support/libnvme/libnvme_1.6.bb
index 26ad36d7d..802edac50 100644
--- a/meta-oe/recipes-support/libnvme/libnvme_1.6.bb
+++ b/meta-oe/recipes-support/libnvme/libnvme_1.6.bb
@@ -14,7 +14,7 @@  DEPENDS = "json-c"
 SRCREV = "37a803cf77e224f66d86b1e1d9e74a15f55ea600"
 
 SRC_URI = "git://github.com/linux-nvme/libnvme;protocol=https;branch=master \
-           file://0001-ioctl-Check-for-ioctl-signature-for-musl.patch \
+           file://0001-test-handle-POSIX-ioctl-prototype.patch \
 "
 
 S = "${WORKDIR}/git"