diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-10-15 16:59:02 -0700 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2021-01-06 14:52:26 +0530 |
commit | 453f5e83537bd341dee9a8f54671195ab3c5dec2 (patch) | |
tree | f2fad6957848f3f84dd2878bd194944bc36c0fc9 | |
parent | 589dbb0ee6e1e77384c2697da07c17a289bdcebe (diff) | |
download | meson-453f5e83537bd341dee9a8f54671195ab3c5dec2.zip meson-453f5e83537bd341dee9a8f54671195ab3c5dec2.tar.gz meson-453f5e83537bd341dee9a8f54671195ab3c5dec2.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 02bc791..33ffa77 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -119,6 +119,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( |