diff --git a/op_builder/async_io.py b/op_builder/async_io.py index 78aa2fe92d67c2a307271e1a8af9f43ed8a333f7..fb55d9bb6f0239696d536b48f57ec2b43231048f 100644 --- a/op_builder/async_io.py +++ b/op_builder/async_io.py @@ -50,10 +50,14 @@ class AsyncIOBuilder(OpBuilder): return ['-laio'] def is_compatible(self): - aio_libraries = ['libaio-dev'] - aio_compatible = self.libraries_installed(aio_libraries) + # Check for the existence of libaio by using distutils + # to compile and link a test program that calls io_submit, + # which is a function provided by libaio that is used in the async_io op. + # If needed, one can define -I and -L entries in CFLAGS and LDFLAGS + # respectively to specify the directories for libaio.h and libaio.so. + aio_compatible = self.has_function('io_submit', ('aio', )) if not aio_compatible: self.warning( - f"{self.NAME} requires the libraries: {aio_libraries} but are missing. Can be fixed by: `apt install libaio-dev`." + f"{self.NAME} requires libaio but it is missing. Can be fixed by: `apt install libaio-dev`." ) return super().is_compatible() and aio_compatible diff --git a/op_builder/builder.py b/op_builder/builder.py index 3eeb4e4bfe749feb7a48c9973ecbb767d2de9fd5..5f0d1a638223921351fae6299b0e8d1c87572c7f 100644 --- a/op_builder/builder.py +++ b/op_builder/builder.py @@ -7,6 +7,7 @@ import time import importlib from pathlib import Path import subprocess +import distutils.ccompiler from abc import ABC, abstractmethod YELLOW = '\033[93m' @@ -160,6 +161,10 @@ class OpBuilder(ABC): valid = valid or result.wait() == 0 return valid + def has_function(self, funcname, libraries): + compiler = distutils.ccompiler.new_compiler() + return compiler.has_function(funcname, libraries=libraries) + def strip_empty_entries(self, args): ''' Drop any empty strings from the list of compile and link flags