multi_target_crates += main_rs is not fine, that may repeat crates.
So we need collect crates from different $arch directly, and unique
them to a new list. then reuse 'rust_multi_target.rs' to generate it
properly

Signed-off-by: Yonggang Luo <[email protected]>
---
 meson.build | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 3460d031a95..f54687e19dc 100644
--- a/meson.build
+++ b/meson.build
@@ -4431,7 +4431,11 @@ foreach target : target_dirs
       multi_target_libs += lib
       multi_target_deps += arch_deps
       multi_target_deps += target_stubs
-      multi_target_crates += main_rs
+      foreach crate : crates
+        if crate not in multi_target_crates
+          multi_target_crates += crate
+        endif
+      endforeach
     endif
     execs = [{
       'name': 'qemu-system-' + target_name,
@@ -4516,6 +4520,18 @@ endforeach
 
 # Other build targets
 
+# Use collected crate names, not per-target main_rs sources, for the combined 
root.
+if multi_target_crates.length() > 0
+  multi_target_crates = custom_target(
+    'rust_multi_target.rs',
+    output: 'rust_multi_target.rs',
+    command: [rust_root_crate, multi_target_crates],
+    capture: true,
+    build_always_stale: true,
+  )
+  multi_target_crates = structured_sources(multi_target_crates)
+endif
+
 multi_target_objects = []
 foreach lib: multi_target_libs
   multi_target_objects += lib.extract_all_objects(recursive: true)
-- 
2.55.0.windows.3


Reply via email to