Add support for driving lld-link indirectly through clang on Windows

pull/7902/head
Laurin-Luis Lehning 4 years ago committed by GitHub
parent b8052f9e50
commit bab1087422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      mesonbuild/compilers/mixins/clang.py
  2. 6
      mesonbuild/environment.py
  3. 8
      mesonbuild/linkers.py

@ -19,7 +19,7 @@ import shutil
import typing as T
from ... import mesonlib
from ...linkers import AppleDynamicLinker
from ...linkers import AppleDynamicLinker, ClangClDynamicLinker
from ..compilers import CompileCheckMode
from .gnu import GnuLikeCompiler
@ -108,6 +108,12 @@ class ClangCompiler(GnuLikeCompiler):
else:
# Shouldn't work, but it'll be checked explicitly in the OpenMP dependency.
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
if self.info.is_windows() and not self.info.is_cygwin() and isinstance(self.linker, ClangClDynamicLinker):
return [f'-Wl,/subsystem:{value}']
return super().get_win_subsystem_args(value)
@classmethod
def use_linker_args(cls, linker: str) -> T.List[str]:

@ -940,6 +940,10 @@ class Environment:
return LLVMDynamicLinker(
compiler, for_machine, comp_class.LINKER_PREFIX,
override, version=search_version(o))
elif not invoked_directly:
return ClangClDynamicLinker(
for_machine, override, exelist=compiler, prefix=comp_class.LINKER_PREFIX,
version=search_version(o), direct=False, machine=None)
if value is not None and invoked_directly:
compiler = value
@ -1236,7 +1240,7 @@ class Environment:
# style ld, but for clang on "real" windows we'll use
# either link.exe or lld-link.exe
try:
linker = self._guess_win_linker(compiler, cls, for_machine)
linker = self._guess_win_linker(compiler, cls, for_machine, invoked_directly=False)
except MesonException:
pass
if linker is None:

@ -1164,6 +1164,14 @@ class ClangClDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):
super().__init__(exelist or ['lld-link.exe'], for_machine,
prefix, always_args, machine=machine, version=version, direct=direct)
def get_output_args(self, outputname: str) -> T.List[str]:
# If we're being driven indirectly by clang just skip /MACHINE
# as clang's target triple will handle the machine selection
if self.machine is None:
return self._apply_prefix([f"/OUT:{outputname}"])
return super().get_output_args(outputname)
class XilinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):

Loading…
Cancel
Save