From 06c7cef26ebe8b34658791adf4d6e7fcd02b173b Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 24 Nov 2015 17:49:12 +0200 Subject: [PATCH] Do not cache paths of found external libraries. Closes #312. --- coredata.py | 1 - interpreter.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/coredata.py b/coredata.py index 3c7744f17cc0..5bbb439c0fa8 100644 --- a/coredata.py +++ b/coredata.py @@ -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): diff --git a/interpreter.py b/interpreter.py index cb29c1688897..3da71a1ee9a8 100644 --- a/interpreter.py +++ b/interpreter.py @@ -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): @@ -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