aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins/clang.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-10 13:50:31 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-02-02 12:42:48 -0800
commitbffc94b08f713cc9916009575664b132aee76bcf (patch)
tree416e0f7e8686cb3f5c17093664e0691edec7904f /mesonbuild/compilers/mixins/clang.py
parentf31ffaaf1754e4578127049844c14eba6bdda477 (diff)
downloadmeson-bffc94b08f713cc9916009575664b132aee76bcf.zip
meson-bffc94b08f713cc9916009575664b132aee76bcf.tar.gz
meson-bffc94b08f713cc9916009575664b132aee76bcf.tar.bz2
compilers: Add support for using multiple threads with lto
Both Clang and GCC support using multiple threads for preforming link time optimizaions, and they can now be configured using the `-Db_lto_threads` option. Fixes #7820
Diffstat (limited to 'mesonbuild/compilers/mixins/clang.py')
-rw-r--r--mesonbuild/compilers/mixins/clang.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py
index fcb2225..9c17a55 100644
--- a/mesonbuild/compilers/mixins/clang.py
+++ b/mesonbuild/compilers/mixins/clang.py
@@ -49,7 +49,8 @@ class ClangCompiler(GnuLikeCompiler):
super().__init__()
self.id = 'clang'
self.defines = defines or {}
- self.base_options.add(OptionKey('b_colorout'))
+ self.base_options.update({OptionKey('b_colorout'), OptionKey('b_lto_threads')})
+
# TODO: this really should be part of the linker base_options, but
# linkers don't have base_options.
if isinstance(self.linker, AppleDynamicLinker):
@@ -135,3 +136,10 @@ class ClangCompiler(GnuLikeCompiler):
def get_coverage_link_args(self) -> T.List[str]:
return ['--coverage']
+
+ def get_lto_compile_args(self, *, threads: int = 0) -> T.List[str]:
+ args = super().get_lto_compile_args(threads=threads)
+ # In clang -flto=0 means auto
+ if threads >= 0:
+ args.append(f'-flto-jobs={threads}')
+ return args