aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-10-18 09:15:48 -0700
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-07-23 09:58:24 +0000
commit7eb1d89095054286391565a23c6a4d27465dd617 (patch)
tree9fa2b9bf1231eef0ddd8587bad2b6dfc6a853afb
parent32c57ca7822fcba084afed8268789552b7ef11c3 (diff)
downloadmeson-7eb1d89095054286391565a23c6a4d27465dd617.zip
meson-7eb1d89095054286391565a23c6a4d27465dd617.tar.gz
meson-7eb1d89095054286391565a23c6a4d27465dd617.tar.bz2
compilers: Move lto args into compiler class
There are two problems, one is that it assumes -flto is the argument to do LTO/WPO, which isn't true of ICC and MSVC (and presumably) others. It's also incorrect because it assumes that the compiler and linker will always be the same, which isn't necessarily true. You could combine GCC with Apple's linker, or clang with link.exe, which use different arguments.
-rw-r--r--mesonbuild/compilers/compilers.py14
-rw-r--r--mesonbuild/compilers/mixins/gnu.py6
2 files changed, 15 insertions, 5 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index df448f0..4ab4dc6 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -13,7 +13,7 @@
# limitations under the License.
import contextlib, enum, os.path, re, tempfile, shlex
-from typing import Optional, Tuple
+from typing import Optional, Tuple, List
from ..linkers import StaticLinker
from .. import coredata
@@ -278,10 +278,9 @@ def option_enabled(boptions, options, option):
def get_base_compile_args(options, compiler):
args = []
- # FIXME, gcc/clang specific.
try:
if options['b_lto'].value:
- args.append('-flto')
+ args.extend(compiler.get_lto_compile_args())
except KeyError:
pass
try:
@@ -328,10 +327,9 @@ def get_base_compile_args(options, compiler):
def get_base_link_args(options, linker, is_shared_module):
args = []
- # FIXME, gcc/clang specific.
try:
if options['b_lto'].value:
- args.append('-flto')
+ args.extend(linker.get_lto_link_args())
except KeyError:
pass
try:
@@ -1197,6 +1195,12 @@ class Compiler:
def remove_linkerlike_args(self, args):
return [x for x in args if not x.startswith('-Wl')]
+ def get_lto_compile_args(self) -> List[str]:
+ return []
+
+ def get_lto_link_args(self) -> List[str]:
+ return []
+
@enum.unique
class CompilerType(enum.Enum):
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index 46f04c4..c575045 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -366,6 +366,12 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
return self._split_fetch_real_dirs(line.split('=', 1)[1])
return []
+ def get_lto_compile_args(self) -> typing.List[str]:
+ return ['-flto']
+
+ def get_lto_link_args(self) -> typing.List[str]:
+ return ['-flto']
+
class GnuCompiler(GnuLikeCompiler):
"""