diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-11-19 09:30:46 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-12-02 16:39:06 -0800 |
commit | ef9aeb188ea2bc7353e59916c18901cde90fa2b3 (patch) | |
tree | d1525c3c53703d1adb4c077399ab39909863c7dc /mesonbuild/linkers.py | |
parent | 7658e67f92ba55e2d8e466f818293a001f34a65f (diff) | |
download | meson-ef9aeb188ea2bc7353e59916c18901cde90fa2b3.zip meson-ef9aeb188ea2bc7353e59916c18901cde90fa2b3.tar.gz meson-ef9aeb188ea2bc7353e59916c18901cde90fa2b3.tar.bz2 |
Allow selecting the dynamic linker
This uses the normal meson mechanisms, an LD environment variable or via
cross/native files.
Fixes: #6057
Diffstat (limited to 'mesonbuild/linkers.py')
-rw-r--r-- | mesonbuild/linkers.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index 57760f7..021134e 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -247,17 +247,21 @@ class DynamicLinker(metaclass=abc.ABCMeta): } # type: typing.Dict[str, typing.List[str]] def _apply_prefix(self, arg: str) -> typing.List[str]: - if isinstance(self.prefix_arg, str): + if self.prefix_arg is None: + return [arg] + elif isinstance(self.prefix_arg, str): return [self.prefix_arg + arg] return self.prefix_arg + [arg] def __init__(self, exelist: typing.List[str], for_machine: mesonlib.MachineChoice, - id_: str, prefix_arg: typing.Union[str, typing.List[str]], *, version: str = 'unknown version'): + id_: str, prefix_arg: typing.Union[str, typing.List[str]], + always_args: typing.List[str], *, version: str = 'unknown version'): self.exelist = exelist self.for_machine = for_machine self.version = version self.id = id_ self.prefix_arg = prefix_arg + self.always_args = always_args def __repr__(self) -> str: return '<{}: v{} `{}`>'.format(type(self).__name__, self.version, ' '.join(self.exelist)) @@ -276,7 +280,7 @@ class DynamicLinker(metaclass=abc.ABCMeta): return mesonlib.is_windows() def get_always_args(self) -> typing.List[str]: - return [] + return self.always_args.copy() def get_lib_prefix(self) -> str: return '' @@ -715,7 +719,7 @@ class ArmDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): def __init__(self, for_machine: mesonlib.MachineChoice, *, version: str = 'unknown version'): - super().__init__(['armlink'], for_machine, 'armlink', '', + super().__init__(['armlink'], for_machine, 'armlink', '', [], version=version) def get_accepts_rsp(self) -> bool: @@ -853,33 +857,33 @@ class MSVCDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker): """Microsoft's Link.exe.""" - def __init__(self, for_machine: mesonlib.MachineChoice, *, + def __init__(self, for_machine: mesonlib.MachineChoice, always_args: typing.List[str], *, exelist: typing.Optional[typing.List[str]] = None, prefix: typing.Union[str, typing.List[str]] = '', machine: str = 'x86', version: str = 'unknown version'): super().__init__(exelist or ['link.exe'], for_machine, 'link', - prefix, machine=machine, version=version) + prefix, always_args, machine=machine, version=version) class ClangClDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker): """Clang's lld-link.exe.""" - def __init__(self, for_machine: mesonlib.MachineChoice, *, + def __init__(self, for_machine: mesonlib.MachineChoice, always_args: typing.List[str], *, exelist: typing.Optional[typing.List[str]] = None, prefix: typing.Union[str, typing.List[str]] = '', version: str = 'unknown version'): - super().__init__(exelist or ['lld-link.exe'], for_machine, - 'lld-link', prefix, version=version) + super().__init__(exelist or ['lld-link.exe'], for_machine, 'lld-link', + prefix, always_args, version=version) class XilinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker): """Intel's Xilink.exe.""" - def __init__(self, for_machine: mesonlib.MachineChoice, + def __init__(self, for_machine: mesonlib.MachineChoice, always_args: typing.List[str], *, version: str = 'unknown version'): - super().__init__(['xilink.exe'], for_machine, 'xilink', '', version=version) + super().__init__(['xilink.exe'], for_machine, 'xilink', '', always_args, version=version) class SolarisDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker): @@ -936,7 +940,7 @@ class OptlinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker): *, version: str = 'unknown version'): # Use optlink instead of link so we don't interfer with other link.exe # implementations. - super().__init__(['optlink.exe'], for_machine, 'optlink', prefix_arg='', version=version) + super().__init__(['optlink.exe'], for_machine, 'optlink', '', [], version=version) def get_allow_undefined_args(self) -> typing.List[str]: return [] |