From 8aeca8ab88eedf705e8ccbbe610648ee6d1169aa Mon Sep 17 00:00:00 2001 From: mloubout Date: Wed, 9 Oct 2024 10:48:50 -0400 Subject: [PATCH] arch: add rpath option to include_dirs --- devito/arch/compiler.py | 6 +++++- devito/passes/iet/engine.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) 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