aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorDan Kegel <dank@kegel.com>2020-05-12 09:28:01 -0700
committerDan Kegel <dank@kegel.com>2020-05-16 20:26:03 +0000
commitf8cfb74e9b084afb748e03aaed532679e9cf3948 (patch)
tree96d850ed9d07070eacf50dc4cbd0ff83b6d50ec7 /mesonbuild/backend
parentd7235c5905fa98207d90f3ad34bf590493498d5b (diff)
downloadmeson-f8cfb74e9b084afb748e03aaed532679e9cf3948.zip
meson-f8cfb74e9b084afb748e03aaed532679e9cf3948.tar.gz
meson-f8cfb74e9b084afb748e03aaed532679e9cf3948.tar.bz2
Let LDFLAGS specify rpath.
Fixes #2567
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 6f6d3db..5649909 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -444,6 +444,21 @@ class Backend:
return True
return False
+ def get_external_rpath_dirs(self, target):
+ dirs = set()
+ args = []
+ # FIXME: is there a better way?
+ for lang in ['c', 'cpp']:
+ try:
+ args.extend(self.environment.coredata.get_external_link_args(target.for_machine, lang))
+ except Exception:
+ pass
+ for arg in args:
+ if arg.startswith('-Wl,-rpath='):
+ for dir in arg.replace('-Wl,-rpath=','').split(':'):
+ dirs.add(dir)
+ return dirs
+
def rpaths_for_bundled_shared_libraries(self, target, exclude_system=True):
paths = []
for dep in target.external_deps:
@@ -458,6 +473,9 @@ class Backend:
if exclude_system and self._libdir_is_system(libdir, target.compilers, self.environment):
# No point in adding system paths.
continue
+ # Don't remove rpaths specified in LDFLAGS.
+ if libdir in self.get_external_rpath_dirs(target):
+ continue
# Windows doesn't support rpaths, but we use this function to
# emulate rpaths by setting PATH, so also accept DLLs here
if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so', '.dylib']: