aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-04-13 18:58:24 +0300
committerXavier Claessens <xclaesse@gmail.com>2023-04-14 10:27:54 -0400
commita787b0cd5fdb0d0dce85148c4febde0806885085 (patch)
tree490d5b3761327d88268804a284564dffc7b88985
parent22960758aa215a2cda21fb3b5a162fcf2bce5d20 (diff)
downloadmeson-a787b0cd5fdb0d0dce85148c4febde0806885085.zip
meson-a787b0cd5fdb0d0dce85148c4febde0806885085.tar.gz
meson-a787b0cd5fdb0d0dce85148c4febde0806885085.tar.bz2
rust: Don't prefer dynamic linking of Rust libraries for cdylibs
cdylibs provide a plain C ABI to its consumers and should not be treated like dylib/proc-macro shared libraries that provide a Rust ABI.
-rw-r--r--mesonbuild/backend/ninjabackend.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index d0c63f2..d556009 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2000,12 +2000,16 @@ class NinjaBackend(backends.Backend):
if d == '':
d = '.'
args += ['-L', d]
- has_shared_deps = any(isinstance(dep, build.SharedLibrary) for dep in target.get_dependencies())
+ 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:
- # add prefer-dynamic if any of the Rust libraries we link
- # against are dynamic, otherwise we'll end up with
- # multiple implementations of crates
- args += ['-C', 'prefer-dynamic']
+ has_rust_shared_deps = any(isinstance(dep, build.SharedLibrary) and dep.uses_rust() and dep.rust_crate_type != 'cdylib'
+ for dep in target_deps)
+ if cratetype != 'cdylib' 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
+ args += ['-C', 'prefer-dynamic']
# build the usual rpath arguments as well...