diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-10-13 09:21:37 -0700 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2021-01-06 14:52:26 +0530 |
commit | ad381e272a5e330b5d79a9b07c576e40dfee6a6f (patch) | |
tree | 931f1d34e84f6bc752cd64bfd7667fe7d89ce25a | |
parent | b41e9aab83870ed6c54c66c1392155ac8765ddc7 (diff) | |
download | meson-ad381e272a5e330b5d79a9b07c576e40dfee6a6f.zip meson-ad381e272a5e330b5d79a9b07c576e40dfee6a6f.tar.gz meson-ad381e272a5e330b5d79a9b07c576e40dfee6a6f.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.py | 16 |
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 |