diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-11-08 12:18:02 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-11-12 14:56:22 -0800 |
| commit | c1e91e497ffbe1d795c3bb996f0a6c2e42fd5018 (patch) | |
| tree | c2c112e8eeea9956f21b8537edaeca5f022dab51 /mesonbuild | |
| parent | c53317f7580a3cb8d92e832159ae38a1a278dba0 (diff) | |
| download | meson-c1e91e497ffbe1d795c3bb996f0a6c2e42fd5018.tar.gz | |
rust: call compilers.get_base_link_args
The rustc invocation performs both compilation and linking, so it should include
link-phase arguments for LTO or sanitizers. RustCompiler has been taught how
to include these arguments, so now add them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/backend/ninjabackend.py | 12 | ||||
| -rw-r--r-- | mesonbuild/compilers/rust.py | 3 |
2 files changed, 4 insertions, 11 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 8e9089eab..02208ebc8 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2031,6 +2031,7 @@ class NinjaBackend(backends.Backend): # If we're dynamically linking, add those arguments if target.rust_crate_type in {'bin', 'dylib', 'cdylib'}: args.extend(rustc.get_linker_always_args()) + args += compilers.get_base_link_args(target, rustc, self.environment) args += self.generate_basic_compiler_args(target, rustc) args += ['--crate-name', self._get_rust_crate_name(target.name)] @@ -2047,17 +2048,6 @@ class NinjaBackend(backends.Backend): project_deps: T.List[RustDep] = [] args: T.List[str] = [] - # Rustc always use non-debug Windows runtime. Inject the one selected - # by Meson options instead. - # https://github.com/rust-lang/rust/issues/39016 - if not isinstance(target, build.StaticLibrary): - try: - buildtype = self.get_target_option(target, 'buildtype') - crt = self.get_target_option(target, 'b_vscrt') - args += rustc.get_crt_link_args(crt, buildtype) - except (KeyError, AttributeError): - pass - def _link_library(libname: str, static: bool, bundle: bool = False) -> None: orig_libname = libname type_ = 'static' if static else 'dylib' diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index a32499ce8..73c38148b 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -329,6 +329,9 @@ class RustCompiler(Compiler): def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]: if not isinstance(self.linker, VisualStudioLikeLinkerMixin): return [] + # Rustc always use non-debug Windows runtime. Inject the one selected + # by Meson options instead. + # https://github.com/rust-lang/rust/issues/39016 return self.MSVCRT_ARGS[self.get_crt_val(crt_val, buildtype)] def get_colorout_args(self, colortype: str) -> T.List[str]: |
