[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250716144610.3938579-1-alviro.iskandar@gnuweeb.org>
Date: Wed, 16 Jul 2025 21:46:10 +0700
From: Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>,
Ammar Faizi <ammarfaizi2@...weeb.org>,
GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
io-uring Mailing List <io-uring@...r.kernel.org>
Subject: [PATCH liburing v3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
Commit 732bf609b670 ("test/io_uring_register: kill old memfd test")
removed the `CONFIG_HAVE_MEMFD_CREATE`, which was previously used to
conditionally provide `memfd_create()` for an old test in
`test/io_uring_register.c`.
Reintroduce `CONFIG_HAVE_MEMFD_CREATE` to resolve Android build error
caused by commit:
93d3a7a70b4a ("examples/zcrx: udmabuf backed areas")
It added a call to `memfd_create()`, which is unavailable on some
Android toolchains, leading to the following build error:
```
zcrx.c:111:10: error: call to undeclared function 'memfd_create'; ISO C99 and \
later do not support implicit function declarations \
[-Wimplicit-function-declaration]
111 | memfd = memfd_create("udmabuf-test", MFD_ALLOW_SEALING);
| ^
```
Then, provide memfd_create() in examples/ if `CONFIG_HAVE_MEMFD_CREATE`
is not set to fix the build error.
v2 -> v3:
- Don't bother touching the test/ dir.
Link: https://lore.kernel.org/io-uring/3b28fddb-2171-4f2f-9729-0c0ed14d20cc@kernel.dk
v1 -> v2:
- Omit the old memfd test because it's not needed anymore.
Link: https://lore.kernel.org/io-uring/4bc75566-9cb5-42ec-a6b7-16e04062e0c6@kernel.dk
Co-authored-by: Ammar Faizi <ammarfaizi2@...weeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@...weeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>
---
configure | 19 +++++++++++++++++++
examples/helpers.c | 8 ++++++++
examples/helpers.h | 5 +++++
3 files changed, 32 insertions(+)
diff --git a/configure b/configure
index 552f8ae..3c95214 100755
--- a/configure
+++ b/configure
@@ -379,6 +379,22 @@ if compile_prog "" "" "has_ucontext"; then
fi
print_config "has_ucontext" "$has_ucontext"
+##########################################
+# check for memfd_create(2)
+has_memfd_create="no"
+cat > $TMPC << EOF
+#include <sys/mman.h>
+int main(int argc, char **argv)
+{
+ int memfd = memfd_create("test", 0);
+ return 0;
+}
+EOF
+if compile_prog "-Werror=implicit-function-declaration" "" "has_memfd_create"; then
+ has_memfd_create="yes"
+fi
+print_config "has_memfd_create" "$has_memfd_create"
+
##########################################
# Check NVME_URING_CMD support
nvme_uring_cmd="no"
@@ -539,6 +555,9 @@ fi
if test "$array_bounds" = "yes"; then
output_sym "CONFIG_HAVE_ARRAY_BOUNDS"
fi
+if test "$has_memfd_create" = "yes"; then
+ output_sym "CONFIG_HAVE_MEMFD_CREATE"
+fi
if test "$nvme_uring_cmd" = "yes"; then
output_sym "CONFIG_HAVE_NVME_URING"
fi
diff --git a/examples/helpers.c b/examples/helpers.c
index 483ddee..8c112f1 100644
--- a/examples/helpers.c
+++ b/examples/helpers.c
@@ -13,6 +13,14 @@
#include "helpers.h"
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <sys/syscall.h>
+int memfd_create(const char *name, unsigned int flags)
+{
+ return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
int setup_listening_socket(int port, int ipv6)
{
struct sockaddr_in srv_addr = { };
diff --git a/examples/helpers.h b/examples/helpers.h
index 44543e1..0b6f15f 100644
--- a/examples/helpers.h
+++ b/examples/helpers.h
@@ -17,4 +17,9 @@ void *t_aligned_alloc(size_t alignment, size_t size);
void t_error(int status, int errnum, const char *format, ...);
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#endif
+int memfd_create(const char *name, unsigned int flags);
+
#endif
base-commit: aa9a6b701aa65b575412476d35e813e48119fe23
--
Alviro Iskandar Setiawan
Powered by blists - more mailing lists