From 97c4e9dea6ccc7772651533dc2afaf0fa43aca84 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 11 Aug 2025 13:16:17 +0200 Subject: ninjabackend: pass objects to doctests Fix my misunderstanding of the code before commit aede231ef ("ninjabackend: pass objects to generate_rust_target from non-Rust sources", 2025-07-29). Object files were added by get_rust_compiler_deps_and_args() to both the main target and the doctest command lines: objs, od = self.flatten_object_list(target) for o in objs: args.append(f'-Clink-arg={o}') deps.append(o) therefore they now need to be passed as the final argument of get_rust_compiler_deps_and_args() for both command lines as well. Failure to do so causes problems building doctests when the main target has objects as well. Add a regression test as well. Fixes: #14897 Signed-off-by: Paolo Bonzini --- test cases/rust/27 objects/lib1-dylib.rs | 9 +++++++++ test cases/rust/27 objects/meson.build | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'test cases') diff --git a/test cases/rust/27 objects/lib1-dylib.rs b/test cases/rust/27 objects/lib1-dylib.rs index 1dbf61422..858b121f9 100644 --- a/test cases/rust/27 objects/lib1-dylib.rs +++ b/test cases/rust/27 objects/lib1-dylib.rs @@ -13,3 +13,12 @@ pub extern "C" fn c_func() { unsafe { from_lib1(); } } + +/// ``` +/// use lib12::rust_func; +/// rust_func(); +/// ``` +pub fn rust_func() +{ + unsafe { from_lib1(); } +} diff --git a/test cases/rust/27 objects/meson.build b/test cases/rust/27 objects/meson.build index 78373e4b6..d6732d343 100644 --- a/test cases/rust/27 objects/meson.build +++ b/test cases/rust/27 objects/meson.build @@ -1,4 +1,5 @@ -project('staticlib group', 'c', 'rust', meson_version: '>=1.8.0') +project('staticlib group', 'c', 'rust', meson_version: '>=1.8.0', + default_options: ['rust_std=2021']) lib1 = static_library('lib1', 'lib1.c') dep1 = declare_dependency(objects: lib1.extract_all_objects(recursive: false)) @@ -26,3 +27,9 @@ lib12 = shared_library('dylib2objs_as_dep', 'lib1-dylib.rs', dependencies: dep2, rust_abi: 'c') executable('dylib_as_dep', 'main.rs', link_with: lib12) + +lib12_rlib = static_library('lib12', 'lib1-dylib.rs', + dependencies: dep2) + +rust = import('rust') +rust.doctest('rlib with dep', lib12_rlib) -- cgit v1.2.3