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.
pull/5700/head
Dylan Baker 6 years ago committed by Nirbheek Chauhan
parent 32c57ca782
commit 7eb1d89095
  1. 14
      mesonbuild/compilers/compilers.py
  2. 6
      mesonbuild/compilers/mixins/gnu.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):

@ -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):
"""

Loading…
Cancel
Save