mm selftests rely on IOURING_EXTRA_LIBS (typically from local_config.mk) to link io_uring-based tests (cow and gup_longterm). On some systems with liburing installed, IOURING_EXTRA_LIBS can still be empty, causing link failures with unresolved io_uring symbols.
Add a fallback detection: IOURING_EXTRA_LIBS := $(shell pkg-config --libs liburing) when IOURING_EXTRA_LIBS was not set by local_config.mk. Also gate io_uring-dependent test binaries (cow and gup_longterm) on IOURING_EXTRA_LIBS being non-empty, so missing liburing support cleanly skips those tests instead of failing the build. Signed-off-by: Li Wang <[email protected]> --- tools/testing/selftests/mm/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 78496f705386..01bdd25e04e4 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -10,6 +10,11 @@ LOCAL_HDRS += $(selfdir)/mm/mseal_helpers.h include local_config.mk +PKG_CONFIG ?= pkg-config +ifeq ($(IOURING_EXTRA_LIBS),) +IOURING_EXTRA_LIBS := $(shell $(PKG_CONFIG) --libs liburing 2>/dev/null) +endif + ifeq ($(ARCH),) ifeq ($(CROSS_COMPILE),) @@ -55,10 +60,12 @@ else PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first" endif -TEST_GEN_FILES = cow -TEST_GEN_FILES += compaction_test -TEST_GEN_FILES += gup_longterm +TEST_GEN_FILES = compaction_test TEST_GEN_FILES += gup_test +ifneq ($(IOURING_EXTRA_LIBS),) +TEST_GEN_FILES += cow +TEST_GEN_FILES += gup_longterm +endif TEST_GEN_FILES += hmm-tests TEST_GEN_FILES += hugetlb-madvise TEST_GEN_FILES += hugetlb-read-hwpoison -- 2.53.0

