liburing header files are broken due to incompatible use of busybox mktemp during package build
The liburing-dev
header file liburing/compat.h
has redefined the struct __kernel_timespec
structure. This causes build failures for apps if they include a header file that pulls in linux/time_types.h
. For example, this short demo reproduces the build failure seen by QEMU on Alpine:
$ cat /u.c
#define _GNU_SOURCE
#include <fcntl.h>
#include <time.h>
#include <linux/errqueue.h>
#include <liburing.h>
int main(int argc, char **argv)
{
return 0;
}
$ gcc -o u /u.c
In file included from /usr/include/liburing.h:19,
from /u.c:6:
/usr/include/liburing/compat.h:9:8: error: redefinition of 'struct __kernel_timespec'
9 | struct __kernel_timespec {
| ^~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/errqueue.h:6,
from /u.c:5:
/usr/include/linux/time_types.h:7:8: note: originally defined here
7 | struct __kernel_timespec {
| ^~~~~~~~~~~~~~~~~
This is with Alpine Edge:
# apk info liburing-dev
liburing-dev-2.1-r0 description:
Linux kernel io_uring access library (development files)
liburing-dev-2.1-r0 webpage:
https://git.kernel.dk/cgit/liburing/
liburing-dev-2.1-r0 installed size:
92 KiB
The same problem affects older versions of liburing-dev in Alpine 3.15 and 3.14 at least
This is all becasue there is a bug in liburing configure script making it incompatible with busybox impl of mktemp. This is seen in the Alpine package build logs:
https://build.alpinelinux.org/buildlogs/build-edge-x86/main/liburing/liburing-2.1-r0.log https://build.alpinelinux.org/buildlogs/build-3-14-x86/main/liburing/liburing-2.0-r0.log
...snip...
>>> liburing: Unpacking /var/cache/distfiles/liburing-2.1.tar.gz...
mktemp: unrecognized option: tmpdir
BusyBox v1.34.0 (2021-09-11 06:16:55 UTC) multi-call binary.
Usage: mktemp [-dt] [-p DIR] [TEMPLATE]
Create a temporary file with name based on TEMPLATE and print its name.
TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).
Without TEMPLATE, -t tmp.XXXXXX is assumed.
-d Make directory, not file
-q Fail silently on errors
-t Prepend base directory name to TEMPLATE
-p DIR Use DIR as a base directory (implies -t)
-u Do not create anything; print a name
Base directory is: -p DIR, else $TMPDIR, else /tmp
...snip...
Upstream this has been fixed with
https://github.com/axboe/liburing/commit/cce3026ee45a86cfdd104fd1be270b759a161233
commit cce3026ee45a86cfdd104fd1be270b759a161233
Author: Nugra <richiisei@gmail.com>
Date: Tue Feb 15 22:36:50 2022 +0700
configure: Support busybox mktemp
Busybox mktemp does not support `--tmpdir`, it says:
mktemp: unrecognized option: tmpdir
It can be fixed with:
1. Create a temporary directory.
2. Use touch to create the temporary files inside the directory.
3. Clean up by deleting the temporary directory.
[ammarfaizi2: s/fio/liburing/]
Signed-off-by: Nugra <richiisei@gmail.com>
Link: https://t.me/GNUWeeb/530154
[ammarfaizi2: Rephrase the commit message and add touch command]
Co-authored-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220215153651.181319-2-ammarfaizi2@gnuweeb.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
The QEMU community would appreciate if this fix could be included in Alpine in all currently supported release streams.