Skip to content

Commit

Permalink
aio: test link against libaio using distutils (#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
adammoody authored Jul 24, 2021
1 parent 6ba9628 commit 6ec8496
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions op_builder/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ def extra_ldflags(self):
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
5 changes: 5 additions & 0 deletions op_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import importlib
from pathlib import Path
import subprocess
import distutils.ccompiler
from abc import ABC, abstractmethod

YELLOW = '\033[93m'
Expand Down Expand Up @@ -160,6 +161,10 @@ def libraries_installed(self, libraries):
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
Expand Down

0 comments on commit 6ec8496

Please sign in to comment.