aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-11-25 14:20:58 -0800
committerDylan Baker <dylan@pnwbakers.com>2019-12-12 10:57:27 -0800
commit47dfe34c8517747d51ef063474e3594c487fde82 (patch)
tree5f17ce21d886962533f48ffce024d451ccbb8ae7 /mesonbuild/environment.py
parent87766b37276164eaf359c9e99522dcd6a53be180 (diff)
downloadmeson-47dfe34c8517747d51ef063474e3594c487fde82.zip
meson-47dfe34c8517747d51ef063474e3594c487fde82.tar.gz
meson-47dfe34c8517747d51ef063474e3594c487fde82.tar.bz2
Consider compiler arguments in linker detection logic
If a user passes -fuse-ld=gold to gcc or clang, they expect that they'll get ld.gold, not whatever the default is. Meson currently doesn't do that, because it doesn't pass these arguments to the linker detection logic. This patch fixes that. Another case that this is needed is with clang's --target option This is a bad solution, honestly, and it would be better to use $LD or a cross/native file but this is needed for backwards compatability. Fixes #6057
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index dc269d2..26727ad 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -735,6 +735,8 @@ class Environment:
def _guess_win_linker(self, compiler: typing.List[str], comp_class: Compiler,
for_machine: MachineChoice, *,
use_linker_prefix: bool = True) -> 'DynamicLinker':
+ self.coredata.add_lang_args(comp_class.language, comp_class, for_machine, self)
+
# Explicitly pass logo here so that we can get the version of link.exe
if not use_linker_prefix or comp_class.LINKER_PREFIX is None:
check_args = ['/logo', '--version']
@@ -743,6 +745,8 @@ class Environment:
elif isinstance(comp_class.LINKER_PREFIX, list):
check_args = comp_class.LINKER_PREFIX + ['/logo'] + comp_class.LINKER_PREFIX + ['--version']
+ check_args += self.coredata.compiler_options[for_machine][comp_class.language + '_args'].value
+
override = [] # type: typing.List[str]
value = self.binaries[for_machine].lookup_entry('ld')
if value is not None:
@@ -797,7 +801,9 @@ class Environment:
:for_machine: which machine this linker targets
:extra_args: Any additional arguments required (such as a source file)
"""
+ self.coredata.add_lang_args(comp_class.language, comp_class, for_machine, self)
extra_args = typing.cast(typing.List[str], extra_args or [])
+ extra_args += self.coredata.compiler_options[for_machine][comp_class.language + '_args'].value
if isinstance(comp_class.LINKER_PREFIX, str):
check_args = [comp_class.LINKER_PREFIX + '--version'] + extra_args
@@ -1287,7 +1293,9 @@ class Environment:
parts = (err if 'javac' in err else out).split()
if len(parts) > 1:
version = parts[1]
- return JavaCompiler(exelist, version, for_machine, info)
+ comp_class = JavaCompiler
+ self.coredata.add_lang_args(comp_class.language, comp_class, for_machine, self)
+ return comp_class(exelist, version, for_machine, info)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
def detect_cs_compiler(self, for_machine):
@@ -1308,6 +1316,7 @@ class Environment:
cls = MonoCompiler
elif "Visual C#" in out:
cls = VisualStudioCsCompiler
+ self.coredata.add_lang_args(cls.language, cls, for_machine, self)
return cls(comp, version, for_machine, info)
self._handle_exceptions(popen_exceptions, compilers)
@@ -1326,7 +1335,9 @@ class Environment:
raise EnvironmentException('Could not execute Vala compiler "%s"' % ' '.join(exelist))
version = search_version(out)
if 'Vala' in out:
- return ValaCompiler(exelist, version, for_machine, info, is_cross)
+ comp_class = ValaCompiler
+ self.coredata.add_lang_args(comp_class.language, comp_class, for_machine, self)
+ return comp_class(exelist, version, for_machine, info, is_cross)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
def detect_rust_compiler(self, for_machine):
@@ -1538,7 +1549,6 @@ class Environment:
return comp
def detect_compiler_for(self, lang: str, for_machine: MachineChoice):
- self.coredata.add_lang_args(lang, for_machine, self)
comp = self.compiler_from_language(lang, for_machine)
if comp is not None:
assert comp.for_machine == for_machine