aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-05-11 14:41:22 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2020-05-14 02:16:35 +0300
commit57e55b1a9ddce282f0b5d0508139f0f06ce952e5 (patch)
tree88458aa2139c8c4749c4952e01c5fd3e59a51ef0
parent7ad8b5f221ed23ff9ca60349f76e91f79ecd211d (diff)
downloadmeson-57e55b1a9ddce282f0b5d0508139f0f06ce952e5.zip
meson-57e55b1a9ddce282f0b5d0508139f0f06ce952e5.tar.gz
meson-57e55b1a9ddce282f0b5d0508139f0f06ce952e5.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 6c1e466..b901ec9 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -1533,6 +1533,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):