block/io_uring: use pkg-config for liburing
PATCH 1/1 block/io_uring: use pkg-config for liburing
Now that liburing has pkg-config support, use it instead of hardcoding compiler flags in QEMU's build scripts. This way distros can customize the location of liburing's headers and libraries without requiring changes to QEMU.
---
Hi Aarushi,
This change is needed to take advantage of the pkg-config patch that I've just sent to liburing. It works like this:
$ cd liburing $ ./configure --libdir=/usr/lib64 # needed on Fedora x86_64 $ make && sudo make install
That puts liburing.pc into /usr/lib64/pkgconfig/ where QEMU's ./configure will find it:
$ cd qemu $ ./configure --target-list=x86_64-softmmu # it should detect liburing $ make -j$(nproc)
Feel free to squash this patch into your patches, I don't mind if the authorship information gets lost. It will be easier for reviewers if this is present from the start instead of added in a later patch.
configure | 12 ++++++------ block/Makefile.objs | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-)
configure +6 -6
@@ -3972,15 +3972,13 @@ fi # linux-io-uring probe if test "$linux_io_uring" != "no" ; then - cat > $TMPC <<EOF -#include <liburing.h> -int main(void) { io_uring_queue_init(0, NULL, 0); io_uring_submit(NULL); return 0; } -EOF - if compile_prog "" "-luring" ; then + if $pkg_config liburing; then + linux_io_uring_cflags=$($pkg_config --cflags liburing) + linux_io_uring_libs=$($pkg_config --libs liburing) linux_io_uring=yes else if test "$linux_io_uring" = "yes" ; then - feature_not_found "linux io_uring" "Install liburing" + feature_not_found "linux io_uring" "Install liburing devel" fi linux_io_uring=no fi
@@ -6884,6 +6882,8 @@ if test "$linux_aio" = "yes" ; then fi if test "$linux_io_uring" = "yes" ; then echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak + echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak + echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak fi if test "$attr" = "yes" ; then echo "CONFIG_ATTR=y" >> $config_host_mak
block/Makefile.objs +2 -1
@@ -62,6 +62,7 @@ block-obj-$(if $(CONFIG_LZFSE),m,n) += dmg-lzfse.o dmg-lzfse.o-libs := $(LZFSE_LIBS) qcow.o-libs := -lz linux-aio.o-libs := -laio -io_uring.o-libs := -luring +io_uring.o-flags := $(LINUX_IO_URING_CFLAGS) +io_uring.o-libs := $(LINUX_IO_URING_LIBS) parallels.o-cflags := $(LIBXML2_CFLAGS) parallels.o-libs := $(LIBXML2_LIBS)
Signature · 1 line
2.21.0
On Sat, May 25, 2019 at 10:07 AM Stefan Hajnoczi <[email protected]> wrote:
Based-on: <[email protected]>
"[RFC PATCH v2 0/9] Add support for io_uring"
block/Makefile.objs block-obj-$(if $(CONFIG_LZFSE),m,n) += dmg-lzfse.o · line 65
Quoted 10 lines
block/Makefile.objs +1
-1@@ -62,6 +62,7 @@ block-obj-$(if $(CONFIG_LZFSE),m,n) += dmg-lzfse.o dmg-lzfse.o-libs := $(LZFSE_LIBS) qcow.o-libs := -lz linux-aio.o-libs := -laio -io_uring.o-libs := -luring +io_uring.o-flags := $(LINUX_IO_URING_CFLAGS)
Oops, this should be -cflags instead of -flags. The current liburing.pc file doesn't define any special cflags so I didn't notice this problem.
Please fix this up when integrating this into your patch series, thanks!
Quoted 4 lines · Stefan Hajnoczi
Now that liburing has pkg-config support, use it instead of hardcoding compiler flags in QEMU's build scripts. This way distros can customize the location of liburing's headers and libraries without requiring changes to QEMU.
I was going to say that we should keep the existing code as a fallback for installs which lack the pkg-config support. It seems liburing is so new as a project that its not in distros yet. So on that basis we can justifiably just do pkg-config only and not worry about back compat.
Quoted 2 lines
Signed-off-by Stefan Hajnoczi <[email protected]>
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|