aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuyuki Ishi <ishitatsuyuki@gmail.com>2022-06-11 00:50:28 +0900
committerEli Schwartz <eschwartz93@gmail.com>2022-10-13 04:18:13 -0400
commita0032480d6707cdfda75987178a7c8ec0c33cbe9 (patch)
treec25e0ded82c61c7529fa00f771159417c22379ae
parentc693d0576b5a959693f4bf8bb506beb0cc759f63 (diff)
downloadmeson-a0032480d6707cdfda75987178a7c8ec0c33cbe9.zip
meson-a0032480d6707cdfda75987178a7c8ec0c33cbe9.tar.gz
meson-a0032480d6707cdfda75987178a7c8ec0c33cbe9.tar.bz2
clang: Support ThinLTO with mold
-rw-r--r--mesonbuild/compilers/mixins/clang.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py
index 4ac9b92..f9b66d5 100644
--- a/mesonbuild/compilers/mixins/clang.py
+++ b/mesonbuild/compilers/mixins/clang.py
@@ -19,7 +19,8 @@ import shutil
import typing as T
from ... import mesonlib
-from ...linkers import AppleDynamicLinker, ClangClDynamicLinker, LLVMDynamicLinker, GnuGoldDynamicLinker
+from ...linkers import AppleDynamicLinker, ClangClDynamicLinker, LLVMDynamicLinker, GnuGoldDynamicLinker, \
+ MoldDynamicLinker
from ...mesonlib import OptionKey
from ..compilers import CompileCheckMode
from .gnu import GnuLikeCompiler
@@ -149,9 +150,13 @@ class ClangCompiler(GnuLikeCompiler):
def get_lto_compile_args(self, *, threads: int = 0, mode: str = 'default') -> T.List[str]:
args: T.List[str] = []
if mode == 'thin':
- # Thin LTO requires the use of gold, lld, ld64, or lld-link
- if not isinstance(self.linker, (AppleDynamicLinker, ClangClDynamicLinker, LLVMDynamicLinker, GnuGoldDynamicLinker)):
- raise mesonlib.MesonException(f"LLVM's thinLTO only works with gnu gold, lld, lld-link, and ld64, not {self.linker.id}")
+ # ThinLTO requires the use of gold, lld, ld64, lld-link or mold 1.1+
+ if isinstance(self.linker, (MoldDynamicLinker)):
+ # https://github.com/rui314/mold/commit/46995bcfc3e3113133620bf16445c5f13cd76a18
+ if not mesonlib.version_compare(self.linker.version, '>=1.1'):
+ raise mesonlib.MesonException("LLVM's ThinLTO requires mold 1.1+")
+ elif not isinstance(self.linker, (AppleDynamicLinker, ClangClDynamicLinker, LLVMDynamicLinker, GnuGoldDynamicLinker)):
+ raise mesonlib.MesonException(f"LLVM's ThinLTO only works with gold, lld, lld-link, ld64 or mold, not {self.linker.id}")
args.append(f'-flto={mode}')
else:
assert mode == 'default', 'someone forgot to wire something up'