From 45629466a7959d73576ea9c0b2eb6cce16169735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 15 Apr 2023 15:01:57 +0300 Subject: [PATCH] rust: Don't use prefer-dynamic in case of proc-macro Rust dependencies They're only used at build-time and whether they exist or not should not have any effect on the final build artifact. --- mesonbuild/backend/ninjabackend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 7fce48e5c..54cf07c1e 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2006,9 +2006,10 @@ class NinjaBackend(backends.Backend): target_deps = target.get_dependencies() has_shared_deps = any(isinstance(dep, build.SharedLibrary) for dep in target_deps) if isinstance(target, build.SharedLibrary) or has_shared_deps: - has_rust_shared_deps = any(isinstance(dep, build.SharedLibrary) and dep.uses_rust() and dep.rust_crate_type != 'cdylib' + has_rust_shared_deps = any(isinstance(dep, build.SharedLibrary) and dep.uses_rust() + and dep.rust_crate_type not in {'cdylib', 'proc-macro'} for dep in target_deps) - if cratetype != 'cdylib' or has_rust_shared_deps: + if cratetype not in {'cdylib', 'proc-macro'} or has_rust_shared_deps: # add prefer-dynamic if any of the Rust libraries we link # against are dynamic or this is a dynamic library itself, # otherwise we'll end up with multiple implementations of crates