aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-05-11 14:41:22 +0200
committerNirbheek Chauhan <nirbheek@centricular.com>2020-05-14 17:28:31 +0530
commita72159e913767a1adb021f687b202ca82d0aa06a (patch)
tree581c332b751dc2707223319131ad1e542147bb71
parent0ac9c675c9b0171fdfabf03528cc1ac27e53dab6 (diff)
downloadmeson-a72159e913767a1adb021f687b202ca82d0aa06a.zip
meson-a72159e913767a1adb021f687b202ca82d0aa06a.tar.gz
meson-a72159e913767a1adb021f687b202ca82d0aa06a.tar.bz2
boost: Try finding libraries with the matching arch (fixes #7110)
-rw-r--r--mesonbuild/dependencies/boost.py47
-rw-r--r--mesonbuild/mesonlib.py10
2 files changed, 52 insertions, 5 deletions
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 3262d8b..2e84820 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -412,10 +412,19 @@ class BoostDependency(ExternalDependency):
break
def run_check(self, inc_dirs: T.List[BoostIncludeDir], lib_dirs: T.List[Path]) -> bool:
+ mlog.debug(' - potential library dirs: {}'.format([x.as_posix() for x in lib_dirs]))
+ mlog.debug(' - potential include dirs: {}'.format([x.path.as_posix() for x in inc_dirs]))
+
# 2. Find all boost libraries
libs = [] # type: T.List[BoostLibraryFile]
for i in lib_dirs:
- libs += self.detect_libraries(i)
+ libs = self.detect_libraries(i)
+ if libs:
+ mlog.debug(' - found boost library dir: {}'.format(i))
+ # mlog.debug(' - raw library list:')
+ # for j in libs:
+ # mlog.debug(' - {}'.format(j))
+ break
libs = sorted(set(libs))
modules = ['boost_' + x for x in self.modules]
@@ -423,9 +432,6 @@ class BoostDependency(ExternalDependency):
mlog.debug(' - found boost {} include dir: {}'.format(inc.version, inc.path))
f_libs = self.filter_libraries(libs, inc.version_lib)
- # mlog.debug(' - raw library list:')
- # for j in libs:
- # mlog.debug(' - {}'.format(j))
mlog.debug(' - filtered library list:')
for j in f_libs:
mlog.debug(' - {}'.format(j))
@@ -500,6 +506,19 @@ class BoostDependency(ExternalDependency):
return [self._include_dir_from_version_header(x) for x in candidates]
def detect_lib_dirs(self, root: Path) -> T.List[Path]:
+ # First check the system include paths. Only consider those within the
+ # given root path
+ system_dirs_t = self.clib_compiler.get_library_dirs(self.env)
+ system_dirs = [Path(x) for x in system_dirs_t]
+ system_dirs = [x.resolve() for x in system_dirs if x.exists()]
+ system_dirs = [x for x in system_dirs if mesonlib.path_is_in_root(x, root)]
+ system_dirs = list(mesonlib.OrderedSet(system_dirs))
+
+ if system_dirs:
+ return system_dirs
+
+ # No system include paths were found --> fall back to manually looking
+ # for library dirs in root
dirs = [] # type: T.List[Path]
subdirs = [] # type: T.List[Path]
for i in root.iterdir():
@@ -511,7 +530,25 @@ class BoostDependency(ExternalDependency):
for j in i.iterdir():
if j.is_dir() and j.name.endswith('-linux-gnu'):
subdirs += [j]
- return dirs + subdirs
+
+ # Filter out paths that don't match the target arch to avoid finding
+ # the wrong libraries. See https://github.com/mesonbuild/meson/issues/7110
+ if not self.arch:
+ return dirs + subdirs
+
+ arch_list_32 = ['32', 'i386']
+ arch_list_64 = ['64']
+
+ raw_list = dirs + subdirs
+ no_arch = [x for x in raw_list if not any([y in x.name for y in arch_list_32 + arch_list_64])]
+
+ matching_arch = [] # type: T.List[Path]
+ if '32' in self.arch:
+ matching_arch = [x for x in raw_list if any([y in x.name for y in arch_list_32])]
+ elif '64' in self.arch:
+ matching_arch = [x for x in raw_list if any([y in x.name for y in arch_list_64])]
+
+ return sorted(matching_arch) + sorted(no_arch)
def filter_libraries(self, libs: T.List[BoostLibraryFile], lib_vers: str) -> T.List[BoostLibraryFile]:
# MSVC is very picky with the library tags
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index c72197e..475ea09 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -1529,6 +1529,16 @@ def relpath(path: str, start: str) -> str:
except (TypeError, ValueError):
return path
+def path_is_in_root(path: Path, root: Path, resolve: bool = False) -> bool:
+ # Check wheter a path is within the root directory root
+ try:
+ if resolve:
+ path.resolve().relative_to(root.resolve())
+ else:
+ path.relative_to(root)
+ except ValueError:
+ return False
+ return True
class LibType(Enum):