diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-11-07 16:00:56 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-11-07 16:00:56 +0200 |
| commit | 8706b6db33e0582a4f210cbd3902e8989d229148 (patch) | |
| tree | 3170727f63758a7208ed31137a14cc62b42474fd /mesonbuild | |
| parent | b6dc4d5e5c6e838de0b52e62d982ba2547eb366d (diff) | |
| download | meson-thinlto.zip meson-thinlto.tar.gz meson-thinlto.tar.bz2 | |
Add thinlto support. Closes #7493.thinlto
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 9 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/clang.py | 7 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 6 |
3 files changed, 16 insertions, 6 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 0f074bb..f6912f1 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -266,7 +266,9 @@ clike_debug_args = {False: [], True: ['-g']} # type: T.Dict[bool, T.List[str]] base_options = {'b_pch': coredata.UserBooleanOption('Use precompiled headers', True), - 'b_lto': coredata.UserBooleanOption('Use link time optimization', False), + 'b_lto': coredata.UserComboOption('Use link time optimization', + ['false', 'true', 'thin'], + 'false'), 'b_sanitize': coredata.UserComboOption('Code sanitizer to use', ['none', 'address', 'thread', 'undefined', 'memory', 'address,undefined'], 'none'), @@ -307,8 +309,7 @@ def option_enabled(boptions: T.List[str], options: 'OptionDictType', def get_base_compile_args(options: 'OptionDictType', compiler: 'Compiler') -> T.List[str]: args = [] # type T.List[str] try: - if options['b_lto'].value: - args.extend(compiler.get_lto_compile_args()) + args.extend(compiler.get_lto_compile_args(options['b_lto'].value)) except KeyError: pass try: @@ -940,7 +941,7 @@ class Compiler(metaclass=abc.ABCMeta): ret.append(arg) return ret - def get_lto_compile_args(self) -> T.List[str]: + def get_lto_compile_args(self, lto_type: str) -> T.List[str]: return [] def get_lto_link_args(self) -> T.List[str]: diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index acdb352..773d9dc 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -77,6 +77,13 @@ class ClangCompiler(GnuLikeCompiler): # so it might change semantics at any time. return ['-include-pch', os.path.join(pch_dir, self.get_pch_name(header))] + def get_lto_compile_args(self, lto_type: str) -> T.List[str]: + if lto_type == 'thin': + return ['-flto=thin'] + if lto_type == 'true': + return ['-flto'] + return [] + def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]: myargs = [] # type: T.List[str] if mode is CompileCheckMode.COMPILE: diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index bb1fc66..5771ad8 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -295,8 +295,10 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta): return self._split_fetch_real_dirs(line.split('=', 1)[1]) return [] - def get_lto_compile_args(self) -> T.List[str]: - return ['-flto'] + def get_lto_compile_args(self, lto_type: str) -> T.List[str]: + if lto_type != 'false': + return ['-flto'] + return [] def sanitizer_compile_args(self, value: str) -> T.List[str]: if value == 'none': |
