aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-10-19 20:40:25 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-10-20 13:17:57 +0300
commit31e6b7043499ab80b839265dc50a6b2506156b06 (patch)
tree8fa8dcffd7251149853b1c4b2099b50cfb22f5a9 /mesonbuild/compilers/compilers.py
parent4d7de6c1225ff7645be845c293769e3cf361b513 (diff)
downloadmeson-31e6b7043499ab80b839265dc50a6b2506156b06.zip
meson-31e6b7043499ab80b839265dc50a6b2506156b06.tar.gz
meson-31e6b7043499ab80b839265dc50a6b2506156b06.tar.bz2
Order rpaths so that internal ones come first.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 56d2ffe..fb03819 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -506,6 +506,22 @@ def get_base_link_args(options, linker, is_shared_module):
pass
return args
+def prepare_rpaths(raw_rpaths, build_dir, from_dir):
+ internal_format_rpaths = [evaluate_rpath(p, build_dir, from_dir) for p in raw_rpaths]
+ ordered_rpaths = order_rpaths(internal_format_rpaths)
+ return ordered_rpaths
+
+def order_rpaths(rpath_list):
+ # We want rpaths that point inside our build dir to always override
+ # those pointing to other places in the file system. This is so built
+ # binaries prefer our libraries to the ones that may lie somewhere
+ # in the file system, such as /lib/x86_64-linux-gnu.
+ #
+ # The correct thing to do here would be C++'s std::stable_partition.
+ # Python standard library does not have it, so replicate it with
+ # sort, which is guaranteed to be stable.
+ return sorted(rpath_list, key=os.path.isabs)
+
def evaluate_rpath(p, build_dir, from_dir):
if p == from_dir:
return '' # relpath errors out in this case
@@ -1115,7 +1131,7 @@ class Compiler:
# The rpaths we write must be relative if they point to the build dir,
# because otherwise they have different length depending on the build
# directory. This breaks reproducible builds.
- processed_rpaths = [evaluate_rpath(p, build_dir, from_dir) for p in rpath_paths]
+ processed_rpaths = prepare_rpaths(rpath_paths, build_dir, from_dir)
# Need to deduplicate rpaths, as macOS's install_name_tool
# is *very* allergic to duplicate -delete_rpath arguments
# when calling depfixer on installation.