|
|
|
@ -16,6 +16,7 @@ from ... import mesonlib |
|
|
|
|
from ... import mlog |
|
|
|
|
from mesonbuild.compilers.compilers import CompileCheckMode |
|
|
|
|
from ...options import OptionKey |
|
|
|
|
from mesonbuild.linkers.linkers import ClangClDynamicLinker |
|
|
|
|
|
|
|
|
|
if T.TYPE_CHECKING: |
|
|
|
|
from ...environment import Environment |
|
|
|
@ -443,6 +444,10 @@ class ClangClCompiler(VisualStudioLikeCompiler): |
|
|
|
|
def __init__(self, target: str): |
|
|
|
|
super().__init__(target) |
|
|
|
|
|
|
|
|
|
self.base_options.update( |
|
|
|
|
{OptionKey('b_lto_threads'), OptionKey('b_lto'), OptionKey('b_lto_mode'), OptionKey('b_thinlto_cache'), |
|
|
|
|
OptionKey('b_thinlto_cache_dir')}) |
|
|
|
|
|
|
|
|
|
# Assembly |
|
|
|
|
self.can_compile_suffixes.add('s') |
|
|
|
|
self.can_compile_suffixes.add('sx') |
|
|
|
@ -494,3 +499,27 @@ class ClangClCompiler(VisualStudioLikeCompiler): |
|
|
|
|
if libs is None: |
|
|
|
|
raise mesonlib.MesonBugException('Could not find libomp') |
|
|
|
|
return super().openmp_link_flags(env) + libs |
|
|
|
|
|
|
|
|
|
def get_lto_compile_args(self, *, threads: int = 0, mode: str = 'default') -> T.List[str]: |
|
|
|
|
args: T.List[str] = [] |
|
|
|
|
if mode == 'thin': |
|
|
|
|
# LTO data generated by clang-cl is only usable by lld-link |
|
|
|
|
if not isinstance(self.linker, ClangClDynamicLinker): |
|
|
|
|
raise mesonlib.MesonException(f"LLVM's ThinLTO only works with lld-link, not {self.linker.id}") |
|
|
|
|
args.append(f'-flto={mode}') |
|
|
|
|
else: |
|
|
|
|
assert mode == 'default', 'someone forgot to wire something up' |
|
|
|
|
args.extend(super().get_lto_compile_args(threads=threads)) |
|
|
|
|
return args |
|
|
|
|
|
|
|
|
|
def get_lto_link_args(self, *, threads: int = 0, mode: str = 'default', |
|
|
|
|
thinlto_cache_dir: T.Optional[str] = None) -> T.List[str]: |
|
|
|
|
args = [] |
|
|
|
|
if mode == 'thin' and thinlto_cache_dir is not None: |
|
|
|
|
args.extend(self.linker.get_thinlto_cache_args(thinlto_cache_dir)) |
|
|
|
|
# lld-link /threads:N has the same behaviour as -flto-jobs=N in lld |
|
|
|
|
if threads > 0: |
|
|
|
|
# clang-cl was released after clang already had LTO support, so it |
|
|
|
|
# is safe to assume that all versions of clang-cl support LTO |
|
|
|
|
args.append(f'/threads:{threads}') |
|
|
|
|
return args |
|
|
|
|