Skip to content

Commit

Permalink
Deduplicate build-tree RPATHs on macOS
Browse files Browse the repository at this point in the history
* Currently, RPATHs coming from dependencies and
  `build_rpath` provided by the user might contain
  the same path. Apple's `install_name` tool is
  allergic to providing the same argument twice
  when removing RPATHs:

    error: install_name_tool: "-delete_rpath /usr/lib" specified more than once
  • Loading branch information
SoapGentoo authored and nirbheek committed Aug 29, 2018
1 parent 8dd2e42 commit cc37a66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .. import coredata
from .. import mlog
from .. import mesonlib
from ..mesonlib import EnvironmentException, MesonException, version_compare, Popen_safe
from ..mesonlib import EnvironmentException, MesonException, OrderedSet, version_compare, Popen_safe

"""This file contains the data files of all compilers Meson knows
about. To support a new compiler, add its information below.
Expand Down Expand Up @@ -1064,7 +1064,9 @@ def build_osx_rpath_args(self, build_dir, rpath_paths, build_rpath):
abs_rpaths.append(build_rpath)
# Ensure that there is enough space for large RPATHs
args = ['-Wl,-headerpad_max_install_names']
args += ['-Wl,-rpath,' + rp for rp in abs_rpaths]
# Need to deduplicate abs_rpaths, as rpath_paths and
# build_rpath are not guaranteed to be disjoint sets
args += ['-Wl,-rpath,' + rp for rp in OrderedSet(abs_rpaths)]
return args

def build_unix_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath):
Expand Down
6 changes: 6 additions & 0 deletions test cases/osx/2 library versions/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
project('library versions', 'c')

zlib_dep = dependency('zlib')

some = shared_library('some', 'lib.c',
# duplicate the rpath again, in order
# to test Meson's RPATH deduplication
build_rpath : zlib_dep.get_pkgconfig_variable('libdir'),
dependencies : zlib_dep,
version : '1.2.3',
soversion : '0',
install : true)
Expand Down

0 comments on commit cc37a66

Please sign in to comment.