Skip to content

Commit

Permalink
Do not cache paths of found external libraries. Closes #312.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Nov 24, 2015
1 parent 1caf7e6 commit 06c7cef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion coredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def __init__(self, options):
self.cross_compilers = {}
self.deps = {}
self.ext_progs = {}
self.ext_libs = {}
self.modules = {}

def init_builtins(self, options):
Expand Down
12 changes: 8 additions & 4 deletions interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,14 @@ def func_find_library(self, node, args, kwargs):
if not isinstance(required, bool):
raise InvalidArguments('"required" argument must be a boolean.')
libname = args[0]
if libname in self.coredata.ext_libs and\
self.coredata.ext_libs[libname].found():
return ExternalLibraryHolder(self.coredata.ext_libs[libname])
# We do not cache found libraries because they can come
# and go between invocations wildly. As an example we
# may find the 64 bit version but need instead the 32 bit
# one that is not installed. If we cache the found path
# then we will never found the new one if it get installed.
# This causes a bit of a slowdown as libraries are rechecked
# on every regen, but since it is a fast operation it should be
# ok.
if 'dirs' in kwargs:
search_dirs = kwargs['dirs']
if not isinstance(search_dirs, list):
Expand All @@ -1544,7 +1549,6 @@ def func_find_library(self, node, args, kwargs):
result = self.environment.find_library(libname, search_dirs)
extlib = dependencies.ExternalLibrary(libname, result)
libobj = ExternalLibraryHolder(extlib)
self.coredata.ext_libs[libname] = extlib
if required and not libobj.found():
raise InvalidArguments('External library "%s" not found.' % libname)
return libobj
Expand Down

0 comments on commit 06c7cef

Please sign in to comment.