From e184fc84b32cc2597efd950123df36038c6ee1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 13 Apr 2023 19:10:49 +0300 Subject: [PATCH] rust: Link staticlib/cdylib link targets like link targets from any other language staticlib/cdylib only provide a C ABI, i.e. contain no Rust metadata, and can be linked like a link target from any other language. --- mesonbuild/backend/ninjabackend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d55600971..cd860b81c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1904,7 +1904,10 @@ class NinjaBackend(backends.Backend): # TODO: we likely need to use verbatim to handle name_prefix and name_suffix for d in target.link_targets: linkdirs.add(d.subdir) - if d.uses_rust(): + # staticlib and cdylib provide a plain C ABI, i.e. contain no Rust + # metadata. As such they should be treated like any other external + # link target + if d.uses_rust() and d.rust_crate_type not in ['staticlib', 'cdylib']: # specify `extern CRATE_NAME=OUTPUT_FILE` for each Rust # dependency, so that collisions with libraries in rustc's # sysroot don't cause ambiguity