diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index 33186ead9c..cc5c0bc85d 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -398,8 +398,12 @@ def __getstate__(self): def add_include_dirs(self, dirs): self.include_dirs = filter_ordered(self.include_dirs + as_list(dirs)) - def add_library_dirs(self, dirs): + def add_library_dirs(self, dirs, rpath=False): self.library_dirs = filter_ordered(self.library_dirs + as_list(dirs)) + if rpath: + # Add rpath flag to embed library dir + for d in as_list(dirs): + self.ldflags.append('-Wl,-rpath,%s' % d) def add_libraries(self, libs): self.libraries = filter_ordered(self.libraries + as_list(libs)) diff --git a/devito/passes/iet/engine.py b/devito/passes/iet/engine.py index 7e95a99220..7221e985d5 100644 --- a/devito/passes/iet/engine.py +++ b/devito/passes/iet/engine.py @@ -127,7 +127,8 @@ def apply(self, func, **kwargs): compiler = kwargs['compiler'] compiler.add_include_dirs(as_tuple(metadata.get('include_dirs'))) compiler.add_libraries(as_tuple(metadata.get('libs'))) - compiler.add_library_dirs(as_tuple(metadata.get('lib_dirs'))) + compiler.add_library_dirs(as_tuple(metadata.get('lib_dirs')), + rpath=metadata.get('rpath', False)) except KeyError: pass