From fa6f01d096fbf3d84d68070d6592cd8d5b761e1b Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 12 Nov 2017 23:31:45 +0200 Subject: [PATCH] Use absolute paths for rpaths on OSX. --- mesonbuild/backend/backends.py | 2 ++ mesonbuild/compilers/c.py | 2 ++ mesonbuild/compilers/compilers.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 61f753586..33d779a34 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -330,6 +330,8 @@ class Backend: link_deps = target.get_all_link_deps() result = [] for ld in link_deps: + if ld is target: + continue prospective = self.get_target_dir(ld) if prospective not in result: result.append(prospective) diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 021f5d734..317a4d738 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -90,6 +90,8 @@ class CCompiler(Compiler): # The default behavior is this, override in MSVC def build_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath): + if self.id == 'clang' and self.clang_type == compilers.CLANG_OSX: + return self.build_osx_rpath_args(build_dir, rpath_paths, build_rpath) return self.build_unix_rpath_args(build_dir, from_dir, rpath_paths, build_rpath, install_rpath) def get_dependency_gen_args(self, outtarget, outfile): diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 032ca6957..c2dbad763 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -817,6 +817,16 @@ class Compiler: def get_instruction_set_args(self, instruction_set): return None + def build_osx_rpath_args(self, build_dir, rpath_paths, build_rpath): + if not rpath_paths and not build_rpath: + return [] + # On OSX, rpaths must be absolute. + abs_rpaths = [os.path.join(build_dir, p) for p in rpath_paths] + if build_rpath != '': + abs_rpaths.append(build_rpath) + args = ['-Wl,-rpath,' + rp for rp in abs_rpaths] + return args + def build_unix_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath): if not rpath_paths and not install_rpath and not build_rpath: return [] @@ -879,7 +889,11 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, i elif gcc_type == GCC_OSX: if is_shared_module: return [] - return ['-install_name', os.path.join(path, 'lib' + shlib_name + '.dylib')] + install_name = prefix + shlib_name + if soversion is not None: + install_name += '.' + soversion + install_name += '.dylib' + return ['-install_name', os.path.join('@rpath', install_name)] else: raise RuntimeError('Not implemented yet.')