apple: -headerpad args are ignored when bitcode is enabled

Causes spammy warnings from the linker:

ld: warning: -headerpad_max_install_names is ignored when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)
pull/7300/head
Nirbheek Chauhan 4 years ago committed by Nirbheek Chauhan
parent 5b8a636504
commit 47c477711b
  1. 8
      mesonbuild/compilers/compilers.py
  2. 12
      mesonbuild/linkers.py

@ -377,9 +377,10 @@ def get_base_link_args(options, linker, is_shared_module):
# -Wl,-dead_strip_dylibs is incompatible with bitcode
args.extend(linker.get_asneeded_args())
# Apple's ld (the only one that supports bitcode) does not like any
# -undefined arguments at all, so don't pass these when using bitcode
# Apple's ld (the only one that supports bitcode) does not like -undefined
# arguments or -headerpad_max_install_names when bitcode is enabled
if not bitcode:
args.extend(linker.headerpad_args())
if (not is_shared_module and
option_enabled(linker.base_options, options, 'b_lundef')):
args.extend(linker.no_undefined_link_args())
@ -1203,6 +1204,9 @@ class Compiler:
def get_asneeded_args(self) -> T.List[str]:
return self.linker.get_asneeded_args()
def headerpad_args(self) -> T.List[str]:
return self.linker.headerpad_args()
def bitcode_args(self) -> T.List[str]:
return self.linker.bitcode_args()

@ -440,6 +440,10 @@ class DynamicLinker(LinkerEnvVarsMixin, metaclass=abc.ABCMeta):
"""Arguments to make all warnings errors."""
return []
def headerpad_args(self) -> T.List[str]:
# Only used by the Apple linker
return []
def bitcode_args(self) -> T.List[str]:
raise mesonlib.MesonException('This linker does not support bitcode bundles')
@ -659,8 +663,8 @@ class AppleDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
def no_undefined_args(self) -> T.List[str]:
return self._apply_prefix('-undefined,error')
def get_always_args(self) -> T.List[str]:
return self._apply_prefix('-headerpad_max_install_names') + super().get_always_args()
def headerpad_args(self) -> T.List[str]:
return self._apply_prefix('-headerpad_max_install_names')
def bitcode_args(self) -> T.List[str]:
return self._apply_prefix('-bitcode_bundle')
@ -688,9 +692,7 @@ class AppleDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
if not rpath_paths and not install_rpath and not build_rpath:
return ([], set())
# Ensure that there is enough space for install_name_tool in-place
# editing of large RPATHs
args = self._apply_prefix('-headerpad_max_install_names')
args = []
# @loader_path is the equivalent of $ORIGIN on macOS
# https://stackoverflow.com/q/26280738
origin_placeholder = '@loader_path'

Loading…
Cancel
Save