aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-10-13 09:21:37 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-11-13 08:55:30 -0800
commit8640dbabc4afd45f4aa04cf9f42499443c0e603f (patch)
treed0fbda10753284f2ed6980a2a6d0b697b988af63
parent91876b40316962620c1705ae14075ab46f8dd644 (diff)
downloadmeson-8640dbabc4afd45f4aa04cf9f42499443c0e603f.zip
meson-8640dbabc4afd45f4aa04cf9f42499443c0e603f.tar.gz
meson-8640dbabc4afd45f4aa04cf9f42499443c0e603f.tar.bz2
environment: Properly pass linker to rustc
rustc is very different than other compilers, in that it doesn't generate object files, it just creates a final target out of the intermediate sources. As such, it needs to know about the linker args in the compiler invocation.
-rw-r--r--mesonbuild/environment.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 588005b..488c5af 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -1619,9 +1619,9 @@ class Environment:
return comp_class(exelist, version, for_machine, info, is_cross)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
- def detect_rust_compiler(self, for_machine):
- popen_exceptions = {}
- compilers, ccache, exe_wrap = self._get_compilers('rust', for_machine)
+ def detect_rust_compiler(self, for_machine: MachineChoice) -> RustCompiler:
+ popen_exceptions = {} # type: T.Dict[str, Exception]
+ compilers, _, exe_wrap = self._get_compilers('rust', for_machine)
is_cross = self.is_cross_build(for_machine)
info = self.machines[for_machine]
@@ -1634,7 +1634,7 @@ class Environment:
compiler = [compiler]
arg = ['--version']
try:
- p, out = Popen_safe(compiler + arg)[0:2]
+ out = Popen_safe(compiler + arg)[1]
except OSError as e:
popen_exceptions[' '.join(compiler + arg)] = e
continue
@@ -1658,9 +1658,8 @@ class Environment:
compiler.extend(['-C', 'linker={}'.format(cc.linker.exelist[0])])
extra_args['direct'] = True
extra_args['machine'] = cc.linker.machine
- elif not ((info.is_darwin() and isinstance(cc, AppleClangCCompiler)) or
- isinstance(cc, GnuCCompiler)):
- c = cc.exelist[1] if cc.exelist[0].endswith('ccache') else cc.exelist[0]
+ else:
+ c = cc.linker.exelist[1] if cc.linker.exelist[0].endswith('ccache') else cc.linker.exelist[0]
compiler.extend(['-C', 'linker={}'.format(c)])
# This trickery with type() gets us the class of the linker
@@ -1675,7 +1674,10 @@ class Environment:
elif 'link' in override[0]:
linker = self._guess_win_linker(
override, RustCompiler, for_machine, use_linker_prefix=False)
+ # rustc takes linker arguments without a prefix, and
+ # inserts the correct prefix itself.
linker.direct = True
+ compiler.extend(['-C', 'linker={}'.format(linker.exelist[0])])
else:
# We're creating a new type of "C" compiler, that has rust
# as it's language. This is gross, but I can't figure out