diff options
Diffstat (limited to 'lib/spack/llnl/util/filesystem.py')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index f4a1a9360c..ced29ad760 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -1389,7 +1389,25 @@ def find_libraries(libraries, root, shared=True, recursive=False): # List of libraries we are searching with suffixes libraries = ['{0}.{1}'.format(lib, suffix) for lib in libraries] - return LibraryList(find(root, libraries, recursive)) + if not recursive: + # If not recursive, look for the libraries directly in root + return LibraryList(find(root, libraries, False)) + + # To speedup the search for external packages configured e.g. in /usr, + # perform first non-recursive search in root/lib then in root/lib64 and + # finally search all of root recursively. The search stops when the first + # match is found. + for subdir in ('lib', 'lib64'): + dirname = join_path(root, subdir) + if not os.path.isdir(dirname): + continue + found_libs = find(dirname, libraries, False) + if found_libs: + break + else: + found_libs = find(root, libraries, True) + + return LibraryList(found_libs) @memoized |