diff mbox series

[RFC,v2,1/5] meson: move shared_module() calls where modules are already walked

Message ID 20240527104937.30443-2-pbonzini@redhat.com
State New
Headers show
Series meson: Pass objects to declare_dependency() | expand

Commit Message

Paolo Bonzini May 27, 2024, 10:49 a.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

Comments

Akihiko Odaki June 2, 2024, 6:06 a.m. UTC | #1
On 2024/05/27 19:49, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Philippe Mathieu-Daudé June 6, 2024, 12:51 p.m. UTC | #2
On 27/5/24 12:49, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   meson.build | 34 +++++++++++++++++++---------------
>   1 file changed, 19 insertions(+), 15 deletions(-)


> +  if emulator_modules.length() > 0
> +    alias_target('modules', emulator_modules)
> +  endif
>   endif
>   
>   nm = find_program('nm')
> @@ -3745,19 +3762,6 @@ common_ss.add(hwcore)
>   # Targets #
>   ###########
>   
> -emulator_modules = []
> -foreach m : block_mods + system_mods
> -  emulator_modules += shared_module(m.name(),
> -                build_by_default: true,
> -                name_prefix: '',
> -                link_whole: m,
> -                install: true,
> -                install_dir: qemu_moddir)
> -endforeach
> -if emulator_modules.length() > 0
> -  alias_target('modules', emulator_modules)
> -endif

In my experiment I moved this later after the qemu-system-FOO
meson targets, because I append libqemu-TARGET-softmmu objects;
but I guess this isn't a good start, and this patch LGTM.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index 63866071445..92ddbd17c32 100644
--- a/meson.build
+++ b/meson.build
@@ -3562,21 +3562,28 @@  modinfo_files = []
 
 block_mods = []
 system_mods = []
+emulator_modules = []
 foreach d, list : modules
   if not (d == 'block' ? have_block : have_system)
     continue
   endif
 
   foreach m, module_ss : list
+    module_ss.add(modulecommon)
     if enable_modules
       module_ss = module_ss.apply(config_all_devices, strict: false)
       sl = static_library(d + '-' + m, [genh, module_ss.sources()],
-                          dependencies: [modulecommon, module_ss.dependencies()], pic: true)
+                          dependencies: module_ss.dependencies(), pic: true)
       if d == 'block'
         block_mods += sl
       else
         system_mods += sl
       endif
+      emulator_modules += shared_module(sl.name(),
+                    name_prefix: '',
+                    link_whole: sl,
+                    install: true,
+                    install_dir: qemu_moddir)
       if module_ss.sources() != []
         # FIXME: Should use sl.extract_all_objects(recursive: true) as
         # input. Sources can be used multiple times but objects are
@@ -3601,6 +3608,7 @@  endforeach
 
 foreach d, list : target_modules
   foreach m, module_ss : list
+    module_ss.add(modulecommon)
     if enable_modules
       foreach target : target_dirs
         if target.endswith('-softmmu')
@@ -3614,11 +3622,16 @@  foreach d, list : target_modules
             module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
             sl = static_library(module_name,
                                 [genh, target_module_ss.sources()],
-                                dependencies: [modulecommon, target_module_ss.dependencies()],
+                                dependencies: target_module_ss.dependencies(),
                                 include_directories: target_inc,
                                 c_args: c_args,
                                 pic: true)
             system_mods += sl
+            emulator_modules += shared_module(sl.name(),
+                    name_prefix: '',
+                    link_whole: sl,
+                    install: true,
+                    install_dir: qemu_moddir)
             # FIXME: Should use sl.extract_all_objects(recursive: true) too.
             modinfo_files += custom_target(module_name + '.modinfo',
                                            output: module_name + '.modinfo',
@@ -3652,6 +3665,10 @@  if enable_modules
       hw_arch[arch].add(modinfo_dep)
     endif
   endforeach
+
+  if emulator_modules.length() > 0
+    alias_target('modules', emulator_modules)
+  endif
 endif
 
 nm = find_program('nm')
@@ -3745,19 +3762,6 @@  common_ss.add(hwcore)
 # Targets #
 ###########
 
-emulator_modules = []
-foreach m : block_mods + system_mods
-  emulator_modules += shared_module(m.name(),
-                build_by_default: true,
-                name_prefix: '',
-                link_whole: m,
-                install: true,
-                install_dir: qemu_moddir)
-endforeach
-if emulator_modules.length() > 0
-  alias_target('modules', emulator_modules)
-endif
-
 system_ss.add(authz, blockdev, chardev, crypto, io, qmp)
 common_ss.add(qom, qemuutil)