diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-10-15 16:59:02 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-11-13 09:00:35 -0800 |
commit | 5afd608a755ebedd6b532dd82abefff205b9e997 (patch) | |
tree | b0730df976a38e86c92f52534c86e9bc74c1536a | |
parent | 5c74cccbb906ab92a75ae31262634a3e8b3f9dfa (diff) | |
download | meson-5afd608a755ebedd6b532dd82abefff205b9e997.zip meson-5afd608a755ebedd6b532dd82abefff205b9e997.tar.gz meson-5afd608a755ebedd6b532dd82abefff205b9e997.tar.bz2 |
compilers/rust: add and use an implementation of use_linker_args
-rw-r--r-- | mesonbuild/compilers/rust.py | 4 | ||||
-rw-r--r-- | mesonbuild/environment.py | 14 |
2 files changed, 11 insertions, 7 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 1be0cd8..312b3b6 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -125,6 +125,10 @@ class RustCompiler(Compiler): def get_output_args(self, outputname: str) -> T.List[str]: return ['-o', outputname] + @classmethod + def use_linker_args(cls, linker: str) -> T.List[str]: + return ['-C', 'linker={}'.format(linker)] + # Rust does not have a use_linker_args because it dispatches to a gcc-like # C compiler for dynamic linking, as such we invoke the C compiler's # use_linker_args method instead. diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 488c5af..941acdc 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -1655,12 +1655,12 @@ class Environment: extra_args = {} always_args = [] if is_link_exe: - compiler.extend(['-C', 'linker={}'.format(cc.linker.exelist[0])]) + compiler.extend(RustCompiler.use_linker_args(cc.linker.exelist[0])) extra_args['direct'] = True extra_args['machine'] = cc.linker.machine else: c = cc.linker.exelist[1] if cc.linker.exelist[0].endswith('ccache') else cc.linker.exelist[0] - compiler.extend(['-C', 'linker={}'.format(c)]) + compiler.extend(RustCompiler.use_linker_args(c)) # This trickery with type() gets us the class of the linker # so we can initialize a new copy for the Rust Compiler @@ -1677,21 +1677,21 @@ class Environment: # rustc takes linker arguments without a prefix, and # inserts the correct prefix itself. linker.direct = True - compiler.extend(['-C', 'linker={}'.format(linker.exelist[0])]) + compiler.extend(RustCompiler.use_linker_args(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 # another way to handle this, because rustc is actually # invoking the c compiler as it's linker. + breakpoint() b = type('b', (type(cc), ), {}) - b.language = RustCompiler.language - linker = self._guess_nix_linker(cc.exelist, b, for_machine) + linker = self._guess_nix_linker(override, b, for_machine) + linker = cc.linker # Of course, we're not going to use any of that, we just # need it to get the proper arguments to pass to rustc c = cc.exelist[1] if cc.exelist[0].endswith('ccache') else cc.exelist[0] - compiler.extend(['-C', 'linker={}'.format(c)]) - compiler.extend(['-C', 'link-args={}'.format(' '.join(cc.use_linker_args(override[0])))]) + compiler.extend(RustCompiler.use_linker_args(c)) self.coredata.add_lang_args(RustCompiler.language, RustCompiler, for_machine, self) return RustCompiler( |