From 510f4c134a21b45ff3a5add9ebc6c6cf7e49aeab Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Thu, 25 Aug 2022 17:07:10 +0000 Subject: [PATCH] Make libvfio-user build reliable on ninja < 1.9 Sadly, before v1.9.0, ninja used per-second granularity timestamps. This had the unfortunate consequence that a "meson configure" immediately following a "meson setup" would not be picked up by ninja, thinking that no regeneration of the build config was needed during "meson compile". See https://github.com/mesonbuild/meson/issues/3992 for background and general dismay. This means that VFIO_USER_CFG_OPTS are ignored 50% of the time, depending on the wall clock. Unlucky builds would therefore end up with libvfio-user being built as a shared object (rather than a static archive) and for installation in /usr/local/lib64 (rather than /usr/local/lib, as per VFIO_USER_LIB_PREFIX). This is worked around by injecting a sleep between "meson setup" and "meson configure" when ninja < 1.9 is in use. Note that ninja v1.8.2 ships in el8, so suffers from this problem. Signed-off-by: Jonathan Davies Change-Id: I4d555dcc5bc63df4475ec6fd6014e3502123e92b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14236 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: John Levon Reviewed-by: Thanos Makatos Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins --- vfiouserbuild/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vfiouserbuild/Makefile b/vfiouserbuild/Makefile index 41258d495..af7b895d3 100644 --- a/vfiouserbuild/Makefile +++ b/vfiouserbuild/Makefile @@ -19,6 +19,9 @@ all: scan-build build: $(Q)test -d $(VFIO_USER_BUILD_DIR) || \ CC=$(SUB_CC) meson setup $(VFIO_USER_BUILD_DIR) $(VFIO_USER_SRC_DIR) + # Work around pre-v1.9 versions of ninja ignoring new configuration. + $(Q)[ $$((ninja --version; echo 1.9) | sort --version-sort | head -n 1) \ + = 1.9 ] || sleep 0.5 $(Q)meson configure $(VFIO_USER_BUILD_DIR) $(VFIO_USER_CFG_OPTS) $(Q)meson compile $(MESON_COMPILE_OPTS) -C $(VFIO_USER_BUILD_DIR) DESTDIR=$(VFIO_USER_INSTALL_DIR) meson install --quiet -C $(VFIO_USER_BUILD_DIR)