[PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error

Alviro Iskandar Setiawan posted 3 patches 2 months, 3 weeks ago
There is a newer version of this series
configure          | 19 +++++++++++++++++++
examples/helpers.c |  8 ++++++++
examples/helpers.h |  5 +++++
test/helpers.c     |  8 ++++++++
test/helpers.h     |  5 +++++
5 files changed, 45 insertions(+)
[PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
Posted by Alviro Iskandar Setiawan 2 months, 3 weeks ago
Hello,

This is the v2 revision of the patch series to address the Android
build error related to `memfd_create()`. The series consists of three
patches:

1) Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error.

Partially reverts commit:

  732bf609b670 ("test/io_uring_register: kill old memfd test")

to 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.

2) Move `memfd_create()` to helpers.c, make it accessible for all tests.

Previously, the static definition of `memfd_create()` was limited to
io_uring_register.c. Now, promote it to a shared location accessible
to all test cases, ensuring that future tests using `memfd_create()`
do not trigger build failures on Android targets where the syscall
is undefined in the standard headers. It improves portability and
prevents regressions across test builds.

3) Also, add `memfd_create()` helper in the examples directory.

Changelog:
v1 -> v2:
  - Omit the old memfd test because it's not needed anymore (Jens Axboe)
    Link: https://lore.kernel.org/io-uring/4bc75566-9cb5-42ec-a6b7-16e04062e0c6@kernel.dk

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---

Alviro Iskandar Setiawan (3):
  Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build errors
  test: Move `memfd_create()` to helpers.c, make it accessible for all tests
  examples: Add `memfd_create()` helper

 configure          | 19 +++++++++++++++++++
 examples/helpers.c |  8 ++++++++
 examples/helpers.h |  5 +++++
 test/helpers.c     |  8 ++++++++
 test/helpers.h     |  5 +++++
 5 files changed, 45 insertions(+)


base-commit: 0272bfa96f02cc47c024ec510a764ef7e37b76bf
-- 
Alviro Iskandar Setiawan
Re: [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
Posted by Jens Axboe 2 months, 3 weeks ago
On 7/15/25 6:43 PM, Alviro Iskandar Setiawan wrote:
> Hello,
> 
> This is the v2 revision of the patch series to address the Android
> build error related to `memfd_create()`. The series consists of three
> patches:

Took a closer look at this. A few comments:

For patch 1, maybe just bring back the configure test and not bother
with a revert style commit? There is nothing in test/ that uses
memfd_create, so there's no point bringing it back in there.

IOW, patch 2 can be dropped, as it's really just dropping bits
that patch 1 re-added for some reason.

All that's needed is to add it to the examples/ helpers. If it's
needed for test/ later, then it can get added at that time.

All of that to say, I'd just add the configure bit and the examples/
helper in a single patch and not worry about test/ at all.

-- 
Jens Axboe
Re: [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
Posted by Alviro Iskandar Setiawan 2 months, 3 weeks ago
On Wed, Jul 16, 2025 at 7:41 PM Jens Axboe wrote:
> For patch 1, maybe just bring back the configure test and not bother
> with a revert style commit? There is nothing in test/ that uses
> memfd_create, so there's no point bringing it back in there.

Ah yea. That'd be easier. I'll copy the configure part instead of
modifying the git revert result 😆

> IOW, patch 2 can be dropped, as it's really just dropping bits
> that patch 1 re-added for some reason.
>
> All that's needed is to add it to the examples/ helpers. If it's
> needed for test/ later, then it can get added at that time.
>
> All of that to say, I'd just add the configure bit and the examples/
> helper in a single patch and not worry about test/ at all.

Understandable. I'll send a v3 revision shortly.

-- Viro
Re: [PATCH liburing v2 0/3] Bring back `CONFIG_HAVE_MEMFD_CREATE` to fix Android build error
Posted by Jens Axboe 2 months, 3 weeks ago
On 7/16/25 8:28 AM, Alviro Iskandar Setiawan wrote:
> On Wed, Jul 16, 2025 at 7:41?PM Jens Axboe wrote:
>> For patch 1, maybe just bring back the configure test and not bother
>> with a revert style commit? There is nothing in test/ that uses
>> memfd_create, so there's no point bringing it back in there.
> 
> Ah yea. That'd be easier. I'll copy the configure part instead of
> modifying the git revert result ?

Exactly, just make it that single patch.

>> IOW, patch 2 can be dropped, as it's really just dropping bits
>> that patch 1 re-added for some reason.
>>
>> All that's needed is to add it to the examples/ helpers. If it's
>> needed for test/ later, then it can get added at that time.
>>
>> All of that to say, I'd just add the configure bit and the examples/
>> helper in a single patch and not worry about test/ at all.
> 
> Understandable. I'll send a v3 revision shortly.

Thanks!

-- 
Jens Axboe