summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
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 /mesonbuild/compilers/compilers.py
parent32c57ca7822fcba084afed8268789552b7ef11c3 (diff)
downloadmeson-7eb1d89095054286391565a23c6a4d27465dd617.tar.gz
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.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index df448f039..4ab4dc661 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):