From: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
Ammar Faizi <ammarfaizi2@gnuweeb.org>,
GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
io-uring Mailing List <io-uring@vger.kernel.org>
Subject: [PATCH liburing v2 1/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
Date: Wed, 16 Jul 2025 07:44:00 +0700 [thread overview]
Message-ID: <20250716004402.3902648-2-alviro.iskandar@gnuweeb.org> (raw)
In-Reply-To: <20250716004402.3902648-1-alviro.iskandar@gnuweeb.org>
This partially reverts commit:
732bf609b670 ("test/io_uring_register: kill old memfd test")
Bring back `CONFIG_HAVE_MEMFD_CREATE` to resolve Android build failures
caused by:
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);
| ^
```
This reversion is a preparation patch for a proper fix by ensuring
`memfd_create()` usage is guarded and portable. It's only a partial
revert because the test itself is not restored.
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@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
configure | 19 +++++++++++++++++++
test/io_uring_register.c | 11 +++++++++++
2 files changed, 30 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/test/io_uring_register.c b/test/io_uring_register.c
index b53a67d..405a812 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -32,6 +32,17 @@ static int pagesize;
static rlim_t mlock_limit;
static int devnull;
+#if !defined(CONFIG_HAVE_MEMFD_CREATE)
+#include <sys/syscall.h>
+#include <linux/memfd.h>
+
+int memfd_create(const char *name, unsigned int flags)
+{
+ return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
+
static int expect_fail(int fd, unsigned int opcode, void *arg,
unsigned int nr_args, int error, int error2)
{
--
Alviro Iskandar Setiawan
next prev parent reply other threads:[~2025-07-16 0:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 0:43 [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Alviro Iskandar Setiawan
2025-07-16 0:44 ` Alviro Iskandar Setiawan [this message]
2025-07-16 0:44 ` [PATCH liburing v2 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests Alviro Iskandar Setiawan
2025-07-16 0:44 ` [PATCH liburing v2 3/3] examples: Add `memfd_create()` helper Alviro Iskandar Setiawan
2025-07-16 12:41 ` [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error Jens Axboe
2025-07-16 14:28 ` Alviro Iskandar Setiawan
2025-07-16 14:30 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250716004402.3902648-2-alviro.iskandar@gnuweeb.org \
--to=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gnuweeb.org \
--cc=axboe@kernel.dk \
--cc=gwml@vger.gnuweeb.org \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.