diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 74994d0fd..f665e610a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1979,6 +1979,8 @@ class NinjaBackend(backends.Backend): for d in target_deps: linkdirs.add(d.subdir) deps.append(self.get_dependency_filename(d)) + if isinstance(d, build.StaticLibrary): + external_deps.extend(d.external_deps) if d.uses_rust_abi(): if d not in itertools.chain(target.link_targets, target.link_whole_targets): # Indirect Rust ABI dependency, we only need its path in linkdirs. @@ -1993,9 +1995,6 @@ class NinjaBackend(backends.Backend): # Link a C ABI library - if isinstance(d, build.StaticLibrary): - external_deps.extend(d.external_deps) - # Pass native libraries directly to the linker with "-C link-arg" # because rustc's "-l:+verbatim=" is not portable and we cannot rely # on linker to find the right library without using verbatim filename. diff --git a/test cases/rust/24 system deps/main.rs b/test cases/rust/24 system deps/main.rs new file mode 100644 index 000000000..cfa599ba6 --- /dev/null +++ b/test cases/rust/24 system deps/main.rs @@ -0,0 +1,5 @@ +extern crate wrapper; + +fn main() { + wrapper::func(); +} diff --git a/test cases/rust/24 system deps/meson.build b/test cases/rust/24 system deps/meson.build new file mode 100644 index 000000000..d9160f108 --- /dev/null +++ b/test cases/rust/24 system deps/meson.build @@ -0,0 +1,9 @@ +project('system deps', 'rust') + +glib = dependency('glib-2.0', required: false) +if not glib.found() + error('MESON_SKIP_TEST: Need glib system dependency') +endif + +rlib = static_library('wrapper', 'wrapper.rs', dependencies: glib) +exe = executable('main', 'main.rs', link_with: rlib) diff --git a/test cases/rust/24 system deps/wrapper.rs b/test cases/rust/24 system deps/wrapper.rs new file mode 100644 index 000000000..630cd7791 --- /dev/null +++ b/test cases/rust/24 system deps/wrapper.rs @@ -0,0 +1,9 @@ +extern "C" { + fn g_hash_table_new() -> *mut std::ffi::c_void; +} + +pub fn func() { + unsafe { + g_hash_table_new(); + } +}